The FieldExpression as well as the PropertyExpression had no source position information. Also the ConstantExpression that represents the method name in a MethodPointerExpression had no source position information.
The following fixes are made:
- in rule pathElement of the grammar: use the create() method of the GroovyRecognizer to create the root node for each operator (SPREAD_DOT, OPTIONAL_DOT, MEMBER_POINTER and DOT) and use the prefix to set the start position of the operator node. The end position is set by using the start position of the next token to parse (LT(1)). Doing that leads to correct source position information for the operator node. This node is later used to set the source position of the PropertyExpression and FieldExpression.
- in the StaticImportVisitor: set the source position from the PropertyExpression before the transformation, to the newly created.
- in the AntlrParserPlugin: call configureAST() to set the source position of the ConstantExpression which represents the method name in a MethodPointerExpression
Tests that verify these changes are also included.