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

Fix string literal escapes #115

Merged
merged 5 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions driver/normalizer/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ var Normalize = Transformers([][]Transformer{

var Normalizers = []Mapping{
MapSemantic("StringLiteral", uast.String{}, MapObj(
Obj{
"escapedValue": Quote(Var("val")),
Fields{
{Name: "unescapedValue", Op: Var("val")},
{Name: "escapedValue", Drop: true, Op: Any()}, // only used in Annotated
},
Obj{
"Value": Var("val"),
Expand Down
1 change: 1 addition & 0 deletions fixtures/hello_world.java.native
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
},
},
escapedValue: "\"Hello world\"",
unescapedValue: "Hello world",
},
],
expression: { '@type': "QualifiedName",
Expand Down
1 change: 1 addition & 0 deletions fixtures/hello_world.java.uast
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
col: 35,
},
},
unescapedValue: "Hello world",
},
],
expression: { '@type': "QualifiedName",
Expand Down
1 change: 1 addition & 0 deletions fixtures/member_value_pair.java.native
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
},
},
escapedValue: "\"\"",
unescapedValue: "",
},
},
],
Expand Down
1 change: 1 addition & 0 deletions fixtures/member_value_pair.java.uast
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
col: 8,
},
},
unescapedValue: "",
},
},
],
Expand Down
6 changes: 6 additions & 0 deletions fixtures/string_literals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Code {
String bn = "b\nc";
String zero = "\0";
String doubleDigitOctalEscape = "\41";
String unicodeEscape = "\u1D306";
}
Loading