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

Commit 34b290f

Browse files
authored
Merge pull request #37 from juanjux/feature/pos_offset
Fill offset. Fix some linenums and columns with 0 value.
2 parents 146ff41 + 942802c commit 34b290f

File tree

85 files changed

+1160
-764
lines changed

Some content is hidden

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

85 files changed

+1160
-764
lines changed

driver/normalizer/parser.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,23 @@ var ToNoder = &native.ObjectToNoder{
7575
// FIXME: test[ast_type=Compare].comparators is a list?? (should be "right")
7676
}
7777

78-
// ASTParserBuilder creates a parser that transform source code files into *uast.Node.
79-
func UASTParserBuilder(opts driver.UASTParserOptions) (driver.UASTParser, error) {
78+
func transformationParser(opts driver.UASTParserOptions) (tr driver.UASTParser, err error) {
8079
parser, err := native.ExecParser(ToNoder, opts.NativeBin)
80+
if err != nil {
81+
return tr, err
82+
}
83+
84+
tr = &driver.TransformationUASTParser{
85+
UASTParser: parser,
86+
Transformation: driver.FillOffsetFromLineCol,
87+
}
88+
89+
return tr, nil
90+
}
91+
92+
// UASTParserBuilder creates a parser that transform source code files into *uast.Node.
93+
func UASTParserBuilder(opts driver.UASTParserOptions) (driver.UASTParser, error) {
94+
parser, err := transformationParser(opts)
8195
if err != nil {
8296
return nil, err
8397
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
msgpack-python==0.4.8
2-
pydetector==0.6.1
2+
pydetector==0.8.1
33
-e git+git://github.com/python/mypy.git@0bb2d1680e8b9522108b38d203cb73021a617e64#egg=mypy-lang
44
typed-ast==1.0.1

native/python_package/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
install_requires=[
3434
"msgpack-python==0.4.8",
35-
"pydetector==0.6.1"
35+
"pydetector==0.8.1"
3636
],
3737
classifiers=[
3838
"Development Status :: 4 - Beta",

tests/aritmeticops.py.native

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"lineno": 1,
2323
"op": {
2424
"ast_type": "Add",
25+
"col_offset": 1,
2526
"lineno": 1
2627
},
2728
"right": {
@@ -50,6 +51,7 @@
5051
"lineno": 2,
5152
"op": {
5253
"ast_type": "Sub",
54+
"col_offset": 1,
5355
"lineno": 2
5456
},
5557
"right": {
@@ -78,6 +80,7 @@
7880
"lineno": 3,
7981
"op": {
8082
"ast_type": "Mult",
83+
"col_offset": 1,
8184
"lineno": 3
8285
},
8386
"right": {
@@ -106,6 +109,7 @@
106109
"lineno": 4,
107110
"op": {
108111
"ast_type": "Div",
112+
"col_offset": 1,
109113
"lineno": 4
110114
},
111115
"right": {
@@ -134,6 +138,7 @@
134138
"lineno": 5,
135139
"op": {
136140
"ast_type": "FloorDiv",
141+
"col_offset": 1,
137142
"lineno": 5
138143
},
139144
"right": {
@@ -162,6 +167,7 @@
162167
"lineno": 6,
163168
"op": {
164169
"ast_type": "Mod",
170+
"col_offset": 1,
165171
"lineno": 6
166172
},
167173
"right": {
@@ -190,6 +196,7 @@
190196
"lineno": 7,
191197
"op": {
192198
"ast_type": "Pow",
199+
"col_offset": 1,
193200
"lineno": 7
194201
},
195202
"right": {

0 commit comments

Comments
 (0)