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

Commit 8350cc8

Browse files
author
Juanjo Alvarez
committed
checkpoint
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 40398d6 commit 8350cc8

File tree

7 files changed

+55
-1895
lines changed

7 files changed

+55
-1895
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ build
44
fixtures/*_got
55
.local/*
66
.cache/*
7+
vendor/*
78
__pycache__
89
makebuild.sh

driver/normalizer/normalizer.go

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,39 @@ var Normalizers = []Mapping{
142142
CommentNode(false, "comm", nil),
143143
)),
144144

145-
MapSemantic("NoopSameLine", uast.Comment{}, MapObj(
146-
Obj{"s": CommentText([2]string{}, "comm")},
145+
//SameLineNoops like the other comment container nodes hold an array of lines, but by
146+
//definition it can only hold one, thus we copy the position from the parent to the (only) child
147+
//that doesn't have it
148+
MapSemantic("SameLineNoops", uast.Comment{}, MapObj(
149+
Obj{
150+
"noop_lines": Arr(
151+
Obj{
152+
uast.KeyType: String("NoopSameLine"),
153+
uast.KeyPos: Var("foo"),
154+
"s": CommentText([2]string{}, "comm"),
155+
},
156+
),
157+
},
158+
CommentNode(false, "comm", nil),
159+
)),
160+
MapSemantic("SameLineNoops", uast.Comment{}, MapObj(
161+
Obj{
162+
"noop_lines": Arr(
163+
Obj{
164+
uast.KeyType: String("NoopSameLine"),
165+
"s": CommentText([2]string{}, "comm"),
166+
},
167+
),
168+
},
147169
CommentNode(false, "comm", nil),
148170
)),
149171

172+
// XXX remove
173+
//MapSemantic("NoopSameLine", uast.Comment{}, MapObj(
174+
// Obj{"s": CommentText([2]string{}, "comm")},
175+
// CommentNode(false, "comm", nil),
176+
//)),
177+
150178
MapSemantic("arg", uast.Argument{}, MapObj(
151179
Obj{
152180
uast.KeyToken: Var("name"),
@@ -201,35 +229,6 @@ var Normalizers = []Mapping{
201229
funcDefMap("FunctionDef", false),
202230
funcDefMap("AsyncFunctionDef", true),
203231

204-
AnnotateType("ClassDef", MapObj(Obj{
205-
"decorator_list": Var("decors"),
206-
"body": Var("body_stmts"),
207-
"bases": Var("bases"),
208-
"name": Var("name"),
209-
uast.KeyPos: Obj{
210-
uast.KeyType: String(uast.KeyPos),
211-
uast.KeyStart: Var(uast.KeyStart),
212-
uast.KeyEnd: Var(uast.KeyEnd),
213-
},
214-
}, Obj{
215-
uast.KeyToken: identifierWithPos("name"),
216-
"decorator_list": Obj{
217-
uast.KeyType: String("ClassDef.decorator_list"),
218-
uast.KeyRoles: Roles(role.Type, role.Declaration, role.Call, role.Incomplete),
219-
"decorators": Var("decors"),
220-
},
221-
"body": Obj{
222-
uast.KeyType: String("ClassDef.body"),
223-
uast.KeyRoles: Roles(role.Type, role.Declaration, role.Body),
224-
"body_stmts": Var("body_stmts"),
225-
},
226-
"bases": Obj{
227-
uast.KeyType: String("ClassDef.bases"),
228-
uast.KeyRoles: Roles(role.Type, role.Declaration, role.Base),
229-
"bases": Var("bases"),
230-
},
231-
}), role.Type, role.Declaration, role.Identifier, role.Statement),
232-
233232
AnnotateType("Import", MapObj(
234233
Obj{
235234
"names": Each("vals", Var("name")),
@@ -261,7 +260,6 @@ var Normalizers = []Mapping{
261260
Objs{
262261
{"Node": Obj{}},
263262
{
264-
//"Node": identifierWithPos("name"),
265263
"Node": UASTType(uast.Identifier{}, Obj{ "Name": Var("alias"), }),
266264
}},
267265
))),

0 commit comments

Comments
 (0)