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

Commit

Permalink
update the fixture and remove empty noops
Browse files Browse the repository at this point in the history
Signed-off-by: Denys Smirnov <[email protected]>
  • Loading branch information
Denys Smirnov authored and dennwc committed Apr 8, 2019
1 parent 52267bf commit 5698501
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions driver/normalizer/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ var Normalizers = []Mapping{
CommentNode(false, "comm", nil),
)),

// remove empty noops
Map(Obj{
uast.KeyType: String("NoopSameLine"),
uast.KeyPos: Any(),
"s": String(""),
}, Is(nil)),
Map(Obj{
uast.KeyType: String("SameLineNoops"),
uast.KeyPos: Any(),
"noop_lines": Check(All(Is(nil)), Any()),
}, Is(nil)),

// FIXME: no positions for keywords in the native AST
AnnotateType("keyword", MapObj(
Fields{
Expand Down
13 changes: 13 additions & 0 deletions fixtures/unicode.py.native
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
'end_col_offset': 4,
'end_lineno': 1,
lineno: 1,
'noops_sameline': {
'ast_type': "SameLineNoops",
'col_offset': 3,
'end_col_offset': 4,
'end_lineno': 1,
lineno: 1,
'noop_lines': [
{
'ast_type': "NoopSameLine",
s: "",
},
],
},
s: "𝓏",
},
},
Expand Down
1 change: 1 addition & 0 deletions fixtures/unicode.py.sem.uast
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Format: "",
Value: "𝓏",
},
'noops_sameline': ~,
},
},
],
Expand Down
23 changes: 23 additions & 0 deletions fixtures/unicode.py.uast
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@
col: 4,
},
},
'noops_sameline': { '@type': "SameLineNoops",
'@role': [Comment],
'@pos': { '@type': "uast:Positions",
start: { '@type': "uast:Position",
offset: 2,
line: 1,
col: 3,
},
end: { '@type': "uast:Position",
offset: 3,
line: 1,
col: 4,
},
},
'noop_lines': [
{ '@type': "NoopSameLine",
'@token': "",
'@role': [Comment, Noop],
'@pos': { '@type': "uast:Positions",
},
},
],
},
},
},
],
Expand Down

0 comments on commit 5698501

Please sign in to comment.