c2nes / javalang

Pure Python Java parser and tools
MIT License
737 stars 161 forks source link

`AssertStatement` doesn't have a position #73

Closed tribals closed 4 years ago

tribals commented 4 years ago

Here is simple example:

// Foo.java
class Foo {
    void foo(int x) {
        assert x > 42;
    }
}

Let's parse it:

from javalang.parse import parse
from javalang.tree import AssertStatement

with open('Foo.java') as f:
    tree = parse(f.read())

path, assert_stmt = next(tree.filter(AssertStatement))

print(repr(assert_stmt.position))

Expected output:

Position(line=4, column=9)

Actual output:

None

Is there any reason why an AssertStatement doesn't have a position?

c2nes commented 4 years ago

@tribals if you haven't already, could you test against master? https://github.com/c2nes/javalang/pull/70 added position information for a number of AST nodes, but hasn't been included in a release yet

tribals commented 4 years ago

@c2nes I've tested it against master. Yes, now AssertStatement does have a position.

tribals commented 4 years ago

Do you plan to release new version? If yes, how soon?

c2nes commented 4 years ago

I've published 0.13.0 to PyPI which includes #70

tribals commented 4 years ago

Thank you!