Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 3f397ff

Browse files
authored
Merge pull request #60 from bzz/fix-59-old-sdk
sem: drop 'leadingComments' inside import 'specifiers'
2 parents f632724 + 889c6b0 commit 3f397ff

File tree

5 files changed

+739
-0
lines changed

5 files changed

+739
-0
lines changed

driver/normalizer/normalizer.go

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ var Preprocessors = []Mapping{
6464
Part("_", Obj{"extra": AnyNode(nil)}),
6565
Part("_", Obj{}),
6666
),
67+
// FIXME(bzz): make sure such comments are mapped properly
68+
Map(
69+
Part("_", Obj{
70+
uast.KeyType: String("ImportNamespaceSpecifier"),
71+
"leadingComments": Any(),
72+
}),
73+
Part("_", Obj{
74+
uast.KeyType: String("ImportNamespaceSpecifier"),
75+
}),
76+
),
6777
}
6878

6979
// Normalizers is the main block of normalization rules to convert native AST to semantic UAST.

fixtures/59-jsx-flow.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @flow strict
2+
import * as React from "react";
3+
4+
// 1
5+
import foo from "mod";

fixtures/59-jsx-flow.js.native

+266
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
{
2+
comments: [
3+
{
4+
end: 15,
5+
loc: {
6+
end: {
7+
column: 15,
8+
line: 1,
9+
},
10+
start: {
11+
column: 0,
12+
line: 1,
13+
},
14+
},
15+
start: 0,
16+
type: "CommentLine",
17+
value: " @flow strict",
18+
},
19+
{
20+
end: 53,
21+
loc: {
22+
end: {
23+
column: 4,
24+
line: 4,
25+
},
26+
start: {
27+
column: 0,
28+
line: 4,
29+
},
30+
},
31+
start: 49,
32+
type: "CommentLine",
33+
value: " 1",
34+
},
35+
],
36+
end: 76,
37+
loc: {
38+
end: {
39+
column: 22,
40+
line: 5,
41+
},
42+
start: {
43+
column: 0,
44+
line: 1,
45+
},
46+
},
47+
program: {
48+
body: [
49+
{
50+
end: 47,
51+
importKind: "value",
52+
leadingComments: [
53+
{
54+
end: 15,
55+
loc: {
56+
end: {
57+
column: 15,
58+
line: 1,
59+
},
60+
start: {
61+
column: 0,
62+
line: 1,
63+
},
64+
},
65+
start: 0,
66+
type: "CommentLine",
67+
value: " @flow strict",
68+
},
69+
],
70+
loc: {
71+
end: {
72+
column: 31,
73+
line: 2,
74+
},
75+
start: {
76+
column: 0,
77+
line: 2,
78+
},
79+
},
80+
source: {
81+
end: 46,
82+
extra: {
83+
raw: "\"react\"",
84+
rawValue: "react",
85+
},
86+
loc: {
87+
end: {
88+
column: 30,
89+
line: 2,
90+
},
91+
start: {
92+
column: 23,
93+
line: 2,
94+
},
95+
},
96+
start: 39,
97+
type: "StringLiteral",
98+
value: "react",
99+
},
100+
specifiers: [
101+
{
102+
end: 33,
103+
leadingComments: ~,
104+
loc: {
105+
end: {
106+
column: 17,
107+
line: 2,
108+
},
109+
start: {
110+
column: 7,
111+
line: 2,
112+
},
113+
},
114+
local: {
115+
end: 33,
116+
leadingComments: ~,
117+
loc: {
118+
end: {
119+
column: 17,
120+
line: 2,
121+
},
122+
identifierName: "React",
123+
start: {
124+
column: 12,
125+
line: 2,
126+
},
127+
},
128+
name: "React",
129+
start: 28,
130+
type: "Identifier",
131+
},
132+
start: 23,
133+
type: "ImportNamespaceSpecifier",
134+
},
135+
],
136+
start: 16,
137+
trailingComments: [
138+
{
139+
end: 53,
140+
loc: {
141+
end: {
142+
column: 4,
143+
line: 4,
144+
},
145+
start: {
146+
column: 0,
147+
line: 4,
148+
},
149+
},
150+
start: 49,
151+
type: "CommentLine",
152+
value: " 1",
153+
},
154+
],
155+
type: "ImportDeclaration",
156+
},
157+
{
158+
end: 76,
159+
importKind: "value",
160+
leadingComments: [
161+
{
162+
end: 53,
163+
loc: {
164+
end: {
165+
column: 4,
166+
line: 4,
167+
},
168+
start: {
169+
column: 0,
170+
line: 4,
171+
},
172+
},
173+
start: 49,
174+
type: "CommentLine",
175+
value: " 1",
176+
},
177+
],
178+
loc: {
179+
end: {
180+
column: 22,
181+
line: 5,
182+
},
183+
start: {
184+
column: 0,
185+
line: 5,
186+
},
187+
},
188+
source: {
189+
end: 75,
190+
extra: {
191+
raw: "\"mod\"",
192+
rawValue: "mod",
193+
},
194+
loc: {
195+
end: {
196+
column: 21,
197+
line: 5,
198+
},
199+
start: {
200+
column: 16,
201+
line: 5,
202+
},
203+
},
204+
start: 70,
205+
type: "StringLiteral",
206+
value: "mod",
207+
},
208+
specifiers: [
209+
{
210+
end: 64,
211+
leadingComments: ~,
212+
loc: {
213+
end: {
214+
column: 10,
215+
line: 5,
216+
},
217+
start: {
218+
column: 7,
219+
line: 5,
220+
},
221+
},
222+
local: {
223+
end: 64,
224+
leadingComments: ~,
225+
loc: {
226+
end: {
227+
column: 10,
228+
line: 5,
229+
},
230+
identifierName: "foo",
231+
start: {
232+
column: 7,
233+
line: 5,
234+
},
235+
},
236+
name: "foo",
237+
start: 61,
238+
type: "Identifier",
239+
},
240+
start: 61,
241+
type: "ImportDefaultSpecifier",
242+
},
243+
],
244+
start: 54,
245+
type: "ImportDeclaration",
246+
},
247+
],
248+
directives: [],
249+
end: 76,
250+
loc: {
251+
end: {
252+
column: 22,
253+
line: 5,
254+
},
255+
start: {
256+
column: 0,
257+
line: 1,
258+
},
259+
},
260+
sourceType: "module",
261+
start: 0,
262+
type: "Program",
263+
},
264+
start: 0,
265+
type: "File",
266+
}

0 commit comments

Comments
 (0)