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

Commit ecfc603

Browse files
Denys Smirnovdennwc
authored andcommitted
fix unicode and eof positions; enable token verification; fixes #122
Signed-off-by: Denys Smirnov <[email protected]>
1 parent 71798fa commit ecfc603

File tree

205 files changed

+473
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+473
-241
lines changed

driver/fixtures/fixtures_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/bblfsh/sdk/v3/driver"
99
"github.com/bblfsh/sdk/v3/driver/fixtures"
1010
"github.com/bblfsh/sdk/v3/driver/native"
11+
"github.com/bblfsh/sdk/v3/uast/transformer/positioner"
1112
)
1213

1314
const projectRoot = "../../"
@@ -33,6 +34,12 @@ var Suite = &fixtures.Suite{
3334
"MethodDeclaration",
3435
},
3536
},
37+
VerifyTokens: []positioner.VerifyToken{
38+
{Types: []string{
39+
"SimpleName",
40+
"StringLiteral",
41+
}},
42+
},
3643
}
3744

3845
func TestJavaDriver(t *testing.T) {

driver/normalizer/normalizer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ package normalizer
33
import (
44
"github.com/bblfsh/sdk/v3/uast"
55
. "github.com/bblfsh/sdk/v3/uast/transformer"
6+
"github.com/bblfsh/sdk/v3/uast/transformer/positioner"
67
)
78

89
var Preprocess []Transformer
910

1011
// PreprocessCode is a preprocessor stage that can use the source code to
1112
// fix tokens and positional information.
1213
// Java already provides all the information we need.
13-
var PreprocessCode []CodeTransformer
14+
var PreprocessCode = []CodeTransformer{
15+
positioner.FromUTF16Offset(),
16+
}
1417

1518
var Normalize = Transformers([][]Transformer{
1619
// The main block of normalization rules.

fixtures/_integration.java.legacy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ CompilationUnit {
77
. }
88
. EndPosition: {
99
. . Offset: 18
10-
. . Line: 0
11-
. . Col: 0
10+
. . Line: 2
11+
. . Col: 1
1212
. }
1313
. Children: {
1414
. . 0: TypeDeclaration {

fixtures/_integration.java.sem.uast

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 18,
11-
col: 0,
11+
line: 2,
12+
col: 1,
1213
},
1314
},
1415
imports: ~,

fixtures/_integration.java.uast

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 18,
11-
col: 0,
11+
line: 2,
12+
col: 1,
1213
},
1314
},
1415
imports: ~,

fixtures/annotation_type_member_declaration.java.sem.uast

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 37,
11-
col: 0,
11+
line: 3,
12+
col: 2,
1213
},
1314
},
1415
imports: ~,
@@ -24,7 +25,8 @@
2425
},
2526
end: { '@type': "uast:Position",
2627
offset: 37,
27-
col: 0,
28+
line: 3,
29+
col: 2,
2830
},
2931
},
3032
bodyDeclarations: [

fixtures/annotation_type_member_declaration.java.uast

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 37,
11-
col: 0,
11+
line: 3,
12+
col: 2,
1213
},
1314
},
1415
imports: ~,
@@ -24,7 +25,8 @@
2425
},
2526
end: { '@type': "uast:Position",
2627
offset: 37,
27-
col: 0,
28+
line: 3,
29+
col: 2,
2830
},
2931
},
3032
bodyDeclarations: [

fixtures/anonymous_class_declaration.java.sem.uast

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 86,
11-
col: 0,
11+
line: 5,
12+
col: 1,
1213
},
1314
},
1415
imports: ~,

fixtures/anonymous_class_declaration.java.uast

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 86,
11-
col: 0,
11+
line: 5,
12+
col: 1,
1213
},
1314
},
1415
imports: ~,

fixtures/array.java.sem.uast

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
end: { '@type': "uast:Position",
1010
offset: 77,
11-
col: 0,
11+
line: 7,
12+
col: 1,
1213
},
1314
},
1415
imports: ~,

0 commit comments

Comments
 (0)