Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 3ea409a

Browse files
committed
Add: Add new expression type arguments to AST
1 parent 58c8377 commit 3ea409a

File tree

3 files changed

+369
-0
lines changed

3 files changed

+369
-0
lines changed

lib/ast-converter.js

+3
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,9 @@ module.exports = function(ast, extra) {
18241824
callee: convertChild(node.expression),
18251825
arguments: (node.arguments) ? node.arguments.map(convertChild) : []
18261826
});
1827+
if (node.typeArguments && node.typeArguments.length) {
1828+
result.typeParameters = convertTypeArgumentsToTypeParameters(node.typeArguments);
1829+
}
18271830
}
18281831
break;
18291832

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,365 @@
1+
module.exports = {
2+
"body": [
3+
{
4+
"declarations": [
5+
{
6+
"id": {
7+
"loc": {
8+
"end": {
9+
"column": 7,
10+
"line": 1
11+
},
12+
"start": {
13+
"column": 6,
14+
"line": 1
15+
}
16+
},
17+
"name": "a",
18+
"range": [
19+
6,
20+
7
21+
],
22+
"type": "Identifier"
23+
},
24+
"init": {
25+
"arguments": [],
26+
"callee": {
27+
"loc": {
28+
"end": {
29+
"column": 15,
30+
"line": 1
31+
},
32+
"start": {
33+
"column": 14,
34+
"line": 1
35+
}
36+
},
37+
"name": "A",
38+
"range": [
39+
14,
40+
15
41+
],
42+
"type": "Identifier"
43+
},
44+
"loc": {
45+
"end": {
46+
"column": 20,
47+
"line": 1
48+
},
49+
"start": {
50+
"column": 10,
51+
"line": 1
52+
}
53+
},
54+
"range": [
55+
10,
56+
20
57+
],
58+
"type": "NewExpression",
59+
"typeParameters": {
60+
"loc": {
61+
"end": {
62+
"column": 18,
63+
"line": 1
64+
},
65+
"start": {
66+
"column": 15,
67+
"line": 1
68+
}
69+
},
70+
"params": [
71+
{
72+
"id": {
73+
"loc": {
74+
"end": {
75+
"column": 17,
76+
"line": 1
77+
},
78+
"start": {
79+
"column": 16,
80+
"line": 1
81+
}
82+
},
83+
"name": "B",
84+
"range": [
85+
16,
86+
17
87+
],
88+
"type": "Identifier"
89+
},
90+
"loc": {
91+
"end": {
92+
"column": 17,
93+
"line": 1
94+
},
95+
"start": {
96+
"column": 16,
97+
"line": 1
98+
}
99+
},
100+
"range": [
101+
16,
102+
17
103+
],
104+
"type": "GenericTypeAnnotation"
105+
}
106+
],
107+
"range": [
108+
15,
109+
18
110+
],
111+
"type": "TypeParameterInstantiation"
112+
}
113+
},
114+
"loc": {
115+
"end": {
116+
"column": 20,
117+
"line": 1
118+
},
119+
"start": {
120+
"column": 6,
121+
"line": 1
122+
}
123+
},
124+
"range": [
125+
6,
126+
20
127+
],
128+
"type": "VariableDeclarator"
129+
}
130+
],
131+
"kind": "const",
132+
"loc": {
133+
"end": {
134+
"column": 21,
135+
"line": 1
136+
},
137+
"start": {
138+
"column": 0,
139+
"line": 1
140+
}
141+
},
142+
"range": [
143+
0,
144+
21
145+
],
146+
"type": "VariableDeclaration"
147+
}
148+
],
149+
"loc": {
150+
"end": {
151+
"column": 21,
152+
"line": 1
153+
},
154+
"start": {
155+
"column": 0,
156+
"line": 1
157+
}
158+
},
159+
"range": [
160+
0,
161+
21
162+
],
163+
"sourceType": "script",
164+
"tokens": [
165+
{
166+
"loc": {
167+
"end": {
168+
"column": 5,
169+
"line": 1
170+
},
171+
"start": {
172+
"column": 0,
173+
"line": 1
174+
}
175+
},
176+
"range": [
177+
0,
178+
5
179+
],
180+
"type": "Keyword",
181+
"value": "const"
182+
},
183+
{
184+
"loc": {
185+
"end": {
186+
"column": 7,
187+
"line": 1
188+
},
189+
"start": {
190+
"column": 6,
191+
"line": 1
192+
}
193+
},
194+
"range": [
195+
6,
196+
7
197+
],
198+
"type": "Identifier",
199+
"value": "a"
200+
},
201+
{
202+
"loc": {
203+
"end": {
204+
"column": 9,
205+
"line": 1
206+
},
207+
"start": {
208+
"column": 8,
209+
"line": 1
210+
}
211+
},
212+
"range": [
213+
8,
214+
9
215+
],
216+
"type": "Punctuator",
217+
"value": "="
218+
},
219+
{
220+
"loc": {
221+
"end": {
222+
"column": 13,
223+
"line": 1
224+
},
225+
"start": {
226+
"column": 10,
227+
"line": 1
228+
}
229+
},
230+
"range": [
231+
10,
232+
13
233+
],
234+
"type": "Keyword",
235+
"value": "new"
236+
},
237+
{
238+
"loc": {
239+
"end": {
240+
"column": 15,
241+
"line": 1
242+
},
243+
"start": {
244+
"column": 14,
245+
"line": 1
246+
}
247+
},
248+
"range": [
249+
14,
250+
15
251+
],
252+
"type": "Identifier",
253+
"value": "A"
254+
},
255+
{
256+
"loc": {
257+
"end": {
258+
"column": 16,
259+
"line": 1
260+
},
261+
"start": {
262+
"column": 15,
263+
"line": 1
264+
}
265+
},
266+
"range": [
267+
15,
268+
16
269+
],
270+
"type": "Punctuator",
271+
"value": "<"
272+
},
273+
{
274+
"loc": {
275+
"end": {
276+
"column": 17,
277+
"line": 1
278+
},
279+
"start": {
280+
"column": 16,
281+
"line": 1
282+
}
283+
},
284+
"range": [
285+
16,
286+
17
287+
],
288+
"type": "Identifier",
289+
"value": "B"
290+
},
291+
{
292+
"loc": {
293+
"end": {
294+
"column": 18,
295+
"line": 1
296+
},
297+
"start": {
298+
"column": 17,
299+
"line": 1
300+
}
301+
},
302+
"range": [
303+
17,
304+
18
305+
],
306+
"type": "Punctuator",
307+
"value": ">"
308+
},
309+
{
310+
"loc": {
311+
"end": {
312+
"column": 19,
313+
"line": 1
314+
},
315+
"start": {
316+
"column": 18,
317+
"line": 1
318+
}
319+
},
320+
"range": [
321+
18,
322+
19
323+
],
324+
"type": "Punctuator",
325+
"value": "("
326+
},
327+
{
328+
"loc": {
329+
"end": {
330+
"column": 20,
331+
"line": 1
332+
},
333+
"start": {
334+
"column": 19,
335+
"line": 1
336+
}
337+
},
338+
"range": [
339+
19,
340+
20
341+
],
342+
"type": "Punctuator",
343+
"value": ")"
344+
},
345+
{
346+
"loc": {
347+
"end": {
348+
"column": 21,
349+
"line": 1
350+
},
351+
"start": {
352+
"column": 20,
353+
"line": 1
354+
}
355+
},
356+
"range": [
357+
20,
358+
21
359+
],
360+
"type": "Punctuator",
361+
"value": ";"
362+
}
363+
],
364+
"type": "Program"
365+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const a = new A<B>();

0 commit comments

Comments
 (0)