-
Notifications
You must be signed in to change notification settings - Fork 16
Fill offset. Fix some linenums and columns with 0 value. #37
Conversation
- Use a TransformationParser with a FillOffset function to add the offset. - Fix bug with some columns showing at 0.
driver/normalizer/parser.go
Outdated
|
|
||
| // ASTParserBuilder creates a parser that transform source code files into *uast.Node. | ||
| func UASTParserBuilder(opts driver.UASTParserOptions) (driver.UASTParser, error) { | ||
| // transUASTParserBuilder creates a parser that transform source code files into *uast.Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name doesn't match with real one. I'd suggest to remove the function name from the documentation, since it's redundant and error-prone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
tests/comprehension_dict.py.uast
Outdated
| @@ -1,5 +1,6 @@ | |||
| Status: ok | |||
| Status: error | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this status change expected? The same question applies to the next UAST files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh f*ck I was so centered on the non zero column number and offset that skipped these ones, good catch, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. I added line numbers to some nodes that didn't have them in the native AST (which set them at 0 in the UAST). This fixes all of the previous errors except for the new empty.* test (expected, since it's empty, it's tests that the Python driver doesn't crash on this case like happened with a previous solved issue) and the string_fstring.*.
This last one does the curious thing of setting the line numbers the code inside the fstring's {...} as starting from line 1. Shouldn't matter much because the next PR should check and fix all those "questionable" locations of the native AST.
This adds the offset to the Python nodes, using the transformation parser. It also fixes bug #35 that was a requirement for the former to work. This fixes 2 of the 3 tasks required for fixing #30.
For the next PR I will fork pydetector into bblfsh as @abeaumont suggested some time ago because it will require extensive changes.
PR includes: