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

Commit 0ff19dd

Browse files
soda0289JamesHenry
authored andcommitted
Fix: Exception thrown when space occurs after function name (fixes #123) (#124)
1 parent ff283aa commit 0ff19dd

File tree

4 files changed

+325
-4
lines changed

4 files changed

+325
-4
lines changed

lib/ast-converter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ module.exports = function(ast, extra) {
10581058
generator: false,
10591059
expression: false,
10601060
body: convertChild(node.body),
1061-
range: [ node.name.end, result.range[1]],
1061+
range: [ node.parameters.pos - 1, result.range[1]],
10621062
loc: {
10631063
start: {
10641064
line: methodLoc.line + 1,
Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
module.exports = {
2+
"type": "Program",
3+
"range": [
4+
0,
5+
25
6+
],
7+
"loc": {
8+
"start": {
9+
"line": 1,
10+
"column": 0
11+
},
12+
"end": {
13+
"line": 1,
14+
"column": 25
15+
}
16+
},
17+
"body": [
18+
{
19+
"type": "ClassDeclaration",
20+
"range": [
21+
0,
22+
25
23+
],
24+
"loc": {
25+
"start": {
26+
"line": 1,
27+
"column": 0
28+
},
29+
"end": {
30+
"line": 1,
31+
"column": 25
32+
}
33+
},
34+
"id": {
35+
"type": "Identifier",
36+
"range": [
37+
6,
38+
7
39+
],
40+
"loc": {
41+
"start": {
42+
"line": 1,
43+
"column": 6
44+
},
45+
"end": {
46+
"line": 1,
47+
"column": 7
48+
}
49+
},
50+
"name": "A"
51+
},
52+
"body": {
53+
"type": "ClassBody",
54+
"body": [
55+
{
56+
"type": "MethodDefinition",
57+
"range": [
58+
9,
59+
24
60+
],
61+
"loc": {
62+
"start": {
63+
"line": 1,
64+
"column": 9
65+
},
66+
"end": {
67+
"line": 1,
68+
"column": 24
69+
}
70+
},
71+
"key": {
72+
"type": "Identifier",
73+
"range": [
74+
9,
75+
18
76+
],
77+
"loc": {
78+
"start": {
79+
"line": 1,
80+
"column": 9
81+
},
82+
"end": {
83+
"line": 1,
84+
"column": 18
85+
}
86+
},
87+
"name": "withSpace"
88+
},
89+
"value": {
90+
"type": "FunctionExpression",
91+
"id": null,
92+
"generator": false,
93+
"expression": false,
94+
"body": {
95+
"type": "BlockStatement",
96+
"range": [
97+
22,
98+
24
99+
],
100+
"loc": {
101+
"start": {
102+
"line": 1,
103+
"column": 22
104+
},
105+
"end": {
106+
"line": 1,
107+
"column": 24
108+
}
109+
},
110+
"body": []
111+
},
112+
"range": [
113+
19,
114+
24
115+
],
116+
"loc": {
117+
"start": {
118+
"line": 1,
119+
"column": 18
120+
},
121+
"end": {
122+
"line": 1,
123+
"column": 24
124+
}
125+
},
126+
"params": []
127+
},
128+
"computed": false,
129+
"static": false,
130+
"kind": "method",
131+
"accessibility": null,
132+
"decorators": []
133+
}
134+
],
135+
"range": [
136+
8,
137+
25
138+
],
139+
"loc": {
140+
"start": {
141+
"line": 1,
142+
"column": 8
143+
},
144+
"end": {
145+
"line": 1,
146+
"column": 25
147+
}
148+
}
149+
},
150+
"superClass": null,
151+
"implements": [],
152+
"decorators": []
153+
}
154+
],
155+
"sourceType": "script",
156+
"tokens": [
157+
{
158+
"type": "Keyword",
159+
"value": "class",
160+
"range": [
161+
0,
162+
5
163+
],
164+
"loc": {
165+
"start": {
166+
"line": 1,
167+
"column": 0
168+
},
169+
"end": {
170+
"line": 1,
171+
"column": 5
172+
}
173+
}
174+
},
175+
{
176+
"type": "Identifier",
177+
"value": "A",
178+
"range": [
179+
6,
180+
7
181+
],
182+
"loc": {
183+
"start": {
184+
"line": 1,
185+
"column": 6
186+
},
187+
"end": {
188+
"line": 1,
189+
"column": 7
190+
}
191+
}
192+
},
193+
{
194+
"type": "Punctuator",
195+
"value": "{",
196+
"range": [
197+
8,
198+
9
199+
],
200+
"loc": {
201+
"start": {
202+
"line": 1,
203+
"column": 8
204+
},
205+
"end": {
206+
"line": 1,
207+
"column": 9
208+
}
209+
}
210+
},
211+
{
212+
"type": "Identifier",
213+
"value": "withSpace",
214+
"range": [
215+
9,
216+
18
217+
],
218+
"loc": {
219+
"start": {
220+
"line": 1,
221+
"column": 9
222+
},
223+
"end": {
224+
"line": 1,
225+
"column": 18
226+
}
227+
}
228+
},
229+
{
230+
"type": "Punctuator",
231+
"value": "(",
232+
"range": [
233+
19,
234+
20
235+
],
236+
"loc": {
237+
"start": {
238+
"line": 1,
239+
"column": 19
240+
},
241+
"end": {
242+
"line": 1,
243+
"column": 20
244+
}
245+
}
246+
},
247+
{
248+
"type": "Punctuator",
249+
"value": ")",
250+
"range": [
251+
20,
252+
21
253+
],
254+
"loc": {
255+
"start": {
256+
"line": 1,
257+
"column": 20
258+
},
259+
"end": {
260+
"line": 1,
261+
"column": 21
262+
}
263+
}
264+
},
265+
{
266+
"type": "Punctuator",
267+
"value": "{",
268+
"range": [
269+
22,
270+
23
271+
],
272+
"loc": {
273+
"start": {
274+
"line": 1,
275+
"column": 22
276+
},
277+
"end": {
278+
"line": 1,
279+
"column": 23
280+
}
281+
}
282+
},
283+
{
284+
"type": "Punctuator",
285+
"value": "}",
286+
"range": [
287+
23,
288+
24
289+
],
290+
"loc": {
291+
"start": {
292+
"line": 1,
293+
"column": 23
294+
},
295+
"end": {
296+
"line": 1,
297+
"column": 24
298+
}
299+
}
300+
},
301+
{
302+
"type": "Punctuator",
303+
"value": "}",
304+
"range": [
305+
24,
306+
25
307+
],
308+
"loc": {
309+
"start": {
310+
"line": 1,
311+
"column": 24
312+
},
313+
"end": {
314+
"line": 1,
315+
"column": 25
316+
}
317+
}
318+
}
319+
]
320+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class A {withSpace () {}}

tests/fixtures/typescript/basics/class-with-accessibility-modifiers.result.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ module.exports = {
261261
]
262262
},
263263
"range": [
264-
81,
264+
82,
265265
111
266266
],
267267
"loc": {
@@ -447,7 +447,7 @@ module.exports = {
447447
]
448448
},
449449
"range": [
450-
130,
450+
131,
451451
171
452452
],
453453
"loc": {
@@ -1284,4 +1284,4 @@ module.exports = {
12841284
}
12851285
}
12861286
]
1287-
};
1287+
};

0 commit comments

Comments
 (0)