From 08828738706a900b17cfc6b5dacc7be03e5abfac Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Thu, 15 Mar 2018 22:36:09 -0500 Subject: [PATCH] Add source offsets for fields, properties and bare ellipsis #412 --- .../apache/groovy/parser/antlr4/AstBuilder.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/base/org.codehaus.groovy26/src/org/apache/groovy/parser/antlr4/AstBuilder.java b/base/org.codehaus.groovy26/src/org/apache/groovy/parser/antlr4/AstBuilder.java index 31b096911b..2c32a35381 100644 --- a/base/org.codehaus.groovy26/src/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/base/org.codehaus.groovy26/src/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -2151,6 +2151,12 @@ private void declareProperty(VariableDeclarationContext ctx, ModifierManager mod configureAST(fieldNode, variableExpression, initialValue); configureAST(propertyNode, variableExpression, initialValue); } + // GRECLIPSE add + fieldNode.setNameStart(variableExpression.getStart()); + fieldNode.setNameEnd(variableExpression.getEnd() - 1); + propertyNode.setNameStart(variableExpression.getStart()); + propertyNode.setNameEnd(variableExpression.getEnd() - 1); + // GRECLIPSE end } private void declareField(VariableDeclarationContext ctx, ModifierManager modifierManager, ClassNode variableType, ClassNode classNode, int i, VariableExpression variableExpression, String fieldName, int modifiers, Expression initialValue) { @@ -2184,6 +2190,10 @@ private void declareField(VariableDeclarationContext ctx, ModifierManager modifi } else { configureAST(fieldNode, variableExpression, initialValue); } + // GRECLIPSE add + fieldNode.setNameStart(variableExpression.getStart()); + fieldNode.setNameEnd(variableExpression.getEnd() - 1); + // GRECLIPSE end } private boolean isFieldDeclaration(ModifierManager modifierManager, ClassNode classNode) { @@ -4608,7 +4618,11 @@ private Parameter processFormalParameter(GroovyParserRuleContext ctx, if (asBoolean(ellipsis)) { // GRECLIPSE edit //classNode = configureAST(classNode.makeArray(), classNode); - classNode = configureAST(classNode.makeArray(), typeContext); + if (asBoolean(typeContext)) { + classNode = configureAST(classNode.makeArray(), typeContext); + } else { + classNode = configureAST(classNode.makeArray(), ellipsis); + } // GRECLIPSE end }