javalang
javalang copied to clipboard
It cannot parse things like ((Type1) Var1).Method1()
the Node type Cast only have attributes "type" and "expression", thus it cannot parse ((Type1) Var1).Method1().
Is it possible to fix this? thanks.
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)]
>>>