File tree Expand file tree Collapse file tree 6 files changed +207
-3
lines changed
test/Esprima.Tests/Fixtures Expand file tree Collapse file tree 6 files changed +207
-3
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,19 @@ namespace Esprima.Ast
55 public sealed class ExportAllDeclaration : ExportDeclaration
66 {
77 public readonly Literal Source ;
8+ public readonly Identifier ? Exported ;
89
9- public ExportAllDeclaration ( Literal source ) : base ( Nodes . ExportAllDeclaration )
10+ public ExportAllDeclaration ( Literal source ) : this ( source , null )
11+ {
12+ }
13+
14+ public ExportAllDeclaration ( Literal source , Identifier ? exported ) : base ( Nodes . ExportAllDeclaration )
1015 {
1116 Source = source ;
17+ Exported = exported ;
1218 }
1319
14- public override NodeCollection ChildNodes => new NodeCollection ( Source ) ;
20+ public override NodeCollection ChildNodes => new NodeCollection ( Source , Exported ) ;
1521
1622 protected internal override void Accept ( AstVisitor visitor ) => visitor . VisitExportAllDeclaration ( this ) ;
1723 }
Original file line number Diff line number Diff line change @@ -4667,6 +4667,15 @@ private ExportDeclaration ParseExportDeclaration()
46674667 {
46684668 // export * from 'foo';
46694669 NextToken ( ) ;
4670+
4671+ //export * as ns from 'foo'
4672+ Identifier ? exported = null ;
4673+ if ( MatchContextualKeyword ( "as" ) )
4674+ {
4675+ NextToken ( ) ;
4676+ exported = ParseIdentifierName ( ) ;
4677+ }
4678+
46704679 if ( ! MatchContextualKeyword ( "from" ) )
46714680 {
46724681 var message = _lookahead . Value != null ? Messages . UnexpectedToken : Messages . MissingFromClause ;
@@ -4675,7 +4684,7 @@ private ExportDeclaration ParseExportDeclaration()
46754684 NextToken ( ) ;
46764685 var src = ParseModuleSpecifier ( ) ;
46774686 ConsumeSemicolon ( ) ;
4678- exportDeclaration = Finalize ( node , new ExportAllDeclaration ( src ) ) ;
4687+ exportDeclaration = Finalize ( node , new ExportAllDeclaration ( src , exported ) ) ;
46794688
46804689 }
46814690 else if ( _lookahead . Type == TokenType . Keyword )
Original file line number Diff line number Diff line change @@ -624,7 +624,10 @@ protected internal override void VisitExportDefaultDeclaration(ExportDefaultDecl
624624 protected internal override void VisitExportAllDeclaration ( ExportAllDeclaration exportAllDeclaration )
625625 {
626626 using ( StartNodeObject ( exportAllDeclaration ) )
627+ {
627628 Member ( "source" , exportAllDeclaration . Source ) ;
629+ Member ( "exported" , exportAllDeclaration . Exported ) ;
630+ }
628631 }
629632
630633 protected internal override void VisitExportNamedDeclaration ( ExportNamedDeclaration exportNamedDeclaration )
Original file line number Diff line number Diff line change 2222 }
2323 }
2424 },
25+ "exported" : null ,
2526 "range" : [
2627 0 ,
2728 20
Original file line number Diff line number Diff line change 1+ export * as someIdentifier from "someModule"
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " Program" ,
3+ "body" : [
4+ {
5+ "type" : " ExportAllDeclaration" ,
6+ "source" : {
7+ "type" : " Literal" ,
8+ "value" : " someModule" ,
9+ "raw" : " \" someModule\" " ,
10+ "range" : [
11+ 32 ,
12+ 44
13+ ],
14+ "loc" : {
15+ "start" : {
16+ "line" : 1 ,
17+ "column" : 32
18+ },
19+ "end" : {
20+ "line" : 1 ,
21+ "column" : 44
22+ }
23+ }
24+ },
25+ "exported" : {
26+ "type" : " Identifier" ,
27+ "name" : " someIdentifier" ,
28+ "range" : [
29+ 12 ,
30+ 26
31+ ],
32+ "loc" : {
33+ "start" : {
34+ "line" : 1 ,
35+ "column" : 12
36+ },
37+ "end" : {
38+ "line" : 1 ,
39+ "column" : 26
40+ }
41+ }
42+ },
43+ "range" : [
44+ 0 ,
45+ 44
46+ ],
47+ "loc" : {
48+ "start" : {
49+ "line" : 1 ,
50+ "column" : 0
51+ },
52+ "end" : {
53+ "line" : 1 ,
54+ "column" : 44
55+ }
56+ }
57+ }
58+ ],
59+ "sourceType" : " module" ,
60+ "range" : [
61+ 0 ,
62+ 44
63+ ],
64+ "loc" : {
65+ "start" : {
66+ "line" : 1 ,
67+ "column" : 0
68+ },
69+ "end" : {
70+ "line" : 1 ,
71+ "column" : 44
72+ }
73+ },
74+ "tokens" : [
75+ {
76+ "type" : " Keyword" ,
77+ "value" : " export" ,
78+ "range" : [
79+ 0 ,
80+ 6
81+ ],
82+ "loc" : {
83+ "start" : {
84+ "line" : 1 ,
85+ "column" : 0
86+ },
87+ "end" : {
88+ "line" : 1 ,
89+ "column" : 6
90+ }
91+ }
92+ },
93+ {
94+ "type" : " Punctuator" ,
95+ "value" : " *" ,
96+ "range" : [
97+ 7 ,
98+ 8
99+ ],
100+ "loc" : {
101+ "start" : {
102+ "line" : 1 ,
103+ "column" : 7
104+ },
105+ "end" : {
106+ "line" : 1 ,
107+ "column" : 8
108+ }
109+ }
110+ },
111+ {
112+ "type" : " Identifier" ,
113+ "value" : " as" ,
114+ "range" : [
115+ 9 ,
116+ 11
117+ ],
118+ "loc" : {
119+ "start" : {
120+ "line" : 1 ,
121+ "column" : 9
122+ },
123+ "end" : {
124+ "line" : 1 ,
125+ "column" : 11
126+ }
127+ }
128+ },
129+ {
130+ "type" : " Identifier" ,
131+ "value" : " someIdentifier" ,
132+ "range" : [
133+ 12 ,
134+ 26
135+ ],
136+ "loc" : {
137+ "start" : {
138+ "line" : 1 ,
139+ "column" : 12
140+ },
141+ "end" : {
142+ "line" : 1 ,
143+ "column" : 26
144+ }
145+ }
146+ },
147+ {
148+ "type" : " Identifier" ,
149+ "value" : " from" ,
150+ "range" : [
151+ 27 ,
152+ 31
153+ ],
154+ "loc" : {
155+ "start" : {
156+ "line" : 1 ,
157+ "column" : 27
158+ },
159+ "end" : {
160+ "line" : 1 ,
161+ "column" : 31
162+ }
163+ }
164+ },
165+ {
166+ "type" : " String" ,
167+ "value" : " \" someModule\" " ,
168+ "range" : [
169+ 32 ,
170+ 44
171+ ],
172+ "loc" : {
173+ "start" : {
174+ "line" : 1 ,
175+ "column" : 32
176+ },
177+ "end" : {
178+ "line" : 1 ,
179+ "column" : 44
180+ }
181+ }
182+ }
183+ ]
184+ }
You can’t perform that action at this time.
0 commit comments