javalang icon indicating copy to clipboard operation
javalang copied to clipboard

It cannot parse things like ((Type1) Var1).Method1()

Open jiang719 opened this issue 4 years ago • 1 comments

the Node type Cast only have attributes "type" and "expression", thus it cannot parse ((Type1) Var1).Method1().

Is it possible to fix this? thanks.

jiang719 avatar Oct 15 '21 21:10 jiang719

It's not explicitly declared, but a Cast will have selectors assigned if necessary, e.g.

$ python3
Python 3.9.6 (default, Jun 28 2021, 19:24:41)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import javalang.parse
>>> javalang.parse.parse_expression("((Type1) Var1).Method1()")
Cast(expression=MemberReference(member=Var1, postfix_operators=[], prefix_operators=[], qualifier=, selectors=[]), type=ReferenceType(arguments=None, dimensions=[], name=Type1, sub_type=None))
>>> javalang.parse.parse_expression("((Type1) Var1).Method1()").selectors
[MethodInvocation(arguments=[], member=Method1, postfix_operators=None, prefix_operators=None, qualifier=None, selectors=None, type_arguments=None)]
>>>

c2nes avatar Oct 18 '21 13:10 c2nes