diff --git a/base/org.codehaus.groovy24/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/base/org.codehaus.groovy24/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java index abe603e1fe..1671fd39f7 100644 --- a/base/org.codehaus.groovy24/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java +++ b/base/org.codehaus.groovy24/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java @@ -1448,13 +1448,13 @@ protected Parameter parameter(AST paramNode) { ClassNode type = ClassHelper.DYNAMIC_TYPE; if (isType(TYPE, node)) { type = makeTypeWithArguments(node); - // GROOVY edit + // GRECLIPSE edit //if (variableParameterDef) type = type.makeArray(); if (variableParameterDef) { type = type.makeArray(); configureAST(type, node); } - // GROOVY end + // GRECLIPSE end node = node.getNextSibling(); } @@ -3594,6 +3594,26 @@ protected ClassNode makeType(AST typeNode) { // GRECLIPSE edit -- retain generics //answer = makeType(node).makeArray(); answer = makeTypeWithArguments(node).makeArray(); + configureAST(answer, node); + if (getController() != null) { + // check for trailing whitespace + GroovySourceAST root = (GroovySourceAST) node; + int start = locations.findOffset(root.getLine(), root.getColumn()); + int until = locations.findOffset(root.getLineLast(), root.getColumnLast()); + char[] sourceChars = getController().readSourceRange(start, until - start); + if (sourceChars != null) { + int idx = (sourceChars.length - 1), off = until; + while (idx >= 0 && Character.isWhitespace(sourceChars[idx])) { + idx -= 1; off -= 1; + } + if (off < until) { + int[] row_col = locations.getRowCol(off); + answer.setEnd(off); + answer.setLastLineNumber(row_col[0]); + answer.setLastColumnNumber(row_col[1]); + } + } + } // GRECLIPSE end } else { answer = ClassHelper.make(qualifiedName(node)); @@ -3602,27 +3622,19 @@ protected ClassNode makeType(AST typeNode) { newAnswer.setRedirect(answer); answer = newAnswer; } - } - // GRECLIPSE add - if (getController() != null) { - // check for trailing whitespace - GroovySourceAST root = (GroovySourceAST) node; - int start = locations.findOffset(root.getLine(), root.getColumn()); - int until = locations.findOffset(root.getLineLast(), root.getColumnLast()); - char[] sourceChars = getController().readSourceRange(start, until - start); - if (sourceChars != null) { - int idx = (sourceChars.length - 1), off = until; - while (idx >= 0 && Character.isWhitespace(sourceChars[idx])) { - idx -= 1; off -= 1; - } - if (off < until) { - int[] row_col = locations.getRowCol(off); - root.setLineLast(row_col[0]); root.setColumnLast(row_col[1]); - } + // GRECLIPSE add + configureAST(answer, node); + if (isType(DOT, node)) { // exclude generics from end position + GroovySourceAST type = (GroovySourceAST) node.getFirstChild().getNextSibling(); + answer.setLastLineNumber(type.getLineLast()); + answer.setLastColumnNumber(type.getColumnLast()); + answer.setEnd(locations.findOffset(type.getLineLast(), type.getColumnLast())); } + // GRECLIPSE end } - // GRECLIPSE end + /* GRECLIPSE edit configureAST(answer, node); + */ } return answer; } diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java index d5cd27af15..7b00d934b1 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java @@ -1457,13 +1457,13 @@ protected Parameter parameter(AST paramNode) { ClassNode type = ClassHelper.DYNAMIC_TYPE; if (isType(TYPE, node)) { type = makeTypeWithArguments(node); - // GROOVY edit + // GRECLIPSE edit //if (variableParameterDef) type = type.makeArray(); if (variableParameterDef) { type = type.makeArray(); configureAST(type, node); } - // GROOVY end + // GRECLIPSE end node = node.getNextSibling(); } @@ -3611,6 +3611,26 @@ protected ClassNode makeType(AST typeNode) { // GRECLIPSE edit -- retain generics //answer = makeType(node).makeArray(); answer = makeTypeWithArguments(node).makeArray(); + configureAST(answer, node); + if (getController() != null) { + // check for trailing whitespace + GroovySourceAST root = (GroovySourceAST) node; + int start = locations.findOffset(root.getLine(), root.getColumn()); + int until = locations.findOffset(root.getLineLast(), root.getColumnLast()); + char[] sourceChars = getController().readSourceRange(start, until - start); + if (sourceChars != null) { + int idx = (sourceChars.length - 1), off = until; + while (idx >= 0 && Character.isWhitespace(sourceChars[idx])) { + idx -= 1; off -= 1; + } + if (off < until) { + int[] row_col = locations.getRowCol(off); + answer.setEnd(off); + answer.setLastLineNumber(row_col[0]); + answer.setLastColumnNumber(row_col[1]); + } + } + } // GRECLIPSE end } else { checkTypeArgs(node, false); @@ -3620,27 +3640,19 @@ protected ClassNode makeType(AST typeNode) { newAnswer.setRedirect(answer); answer = newAnswer; } - } - // GRECLIPSE add - if (getController() != null) { - // check for trailing whitespace - GroovySourceAST root = (GroovySourceAST) node; - int start = locations.findOffset(root.getLine(), root.getColumn()); - int until = locations.findOffset(root.getLineLast(), root.getColumnLast()); - char[] sourceChars = getController().readSourceRange(start, until - start); - if (sourceChars != null) { - int idx = (sourceChars.length - 1), off = until; - while (idx >= 0 && Character.isWhitespace(sourceChars[idx])) { - idx -= 1; off -= 1; - } - if (off < until) { - int[] row_col = locations.getRowCol(off); - root.setLineLast(row_col[0]); root.setColumnLast(row_col[1]); - } + // GRECLIPSE add + configureAST(answer, node); + if (isType(DOT, node)) { // exclude generics from end position + GroovySourceAST type = (GroovySourceAST) node.getFirstChild().getNextSibling(); + answer.setLastLineNumber(type.getLineLast()); + answer.setLastColumnNumber(type.getColumnLast()); + answer.setEnd(locations.findOffset(type.getLineLast(), type.getColumnLast())); } + // GRECLIPSE end } - // GRECLIPSE end + /* GRECLIPSE edit configureAST(answer, node); + */ } return answer; } diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java index 698d419415..40bcccfa7b 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java @@ -1219,9 +1219,10 @@ protected void methodDef(AST methodDef) { methodNode = new MethodNode(name, modifiers, returnType, parameters, exceptions, code); if ((modifiers & Opcodes.ACC_ABSTRACT) == 0) { if (node == null) { - // GRECLIPSE edit - // throw new ASTRuntimeException(methodDef, "You defined a method without body. Try adding a body, or declare it abstract."); - //} + /* GRECLIPSE edit + throw new ASTRuntimeException(methodDef, "You defined a method without body. Try adding a body, or declare it abstract."); + } + */ if (getController() != null) getController().addError(new SyntaxException( "You defined a method without body. Try adding a body, or declare it abstract.", methodDef.getLine(), methodDef.getColumn())); // create a fake node that can pretend to be the body @@ -3707,6 +3708,26 @@ protected ClassNode makeType(AST typeNode) { // GRECLIPSE edit -- retain generics //answer = makeType(node).makeArray(); answer = makeTypeWithArguments(node).makeArray(); + configureAST(answer, node); + if (getController() != null) { + // check for trailing whitespace + GroovySourceAST root = (GroovySourceAST) node; + int start = locations.findOffset(root.getLine(), root.getColumn()); + int until = locations.findOffset(root.getLineLast(), root.getColumnLast()); + char[] sourceChars = getController().readSourceRange(start, until - start); + if (sourceChars != null) { + int idx = (sourceChars.length - 1), off = until; + while (idx >= 0 && Character.isWhitespace(sourceChars[idx])) { + idx -= 1; off -= 1; + } + if (off < until) { + int[] row_col = locations.getRowCol(off); + answer.setEnd(off); + answer.setLastLineNumber(row_col[0]); + answer.setLastColumnNumber(row_col[1]); + } + } + } // GRECLIPSE end } else { checkTypeArgs(node, false); @@ -3716,27 +3737,19 @@ protected ClassNode makeType(AST typeNode) { newAnswer.setRedirect(answer); answer = newAnswer; } - } - // GRECLIPSE add - if (getController() != null) { - // check for trailing whitespace - GroovySourceAST root = (GroovySourceAST) node; - int start = locations.findOffset(root.getLine(), root.getColumn()); - int until = locations.findOffset(root.getLineLast(), root.getColumnLast()); - char[] sourceChars = getController().readSourceRange(start, until - start); - if (sourceChars != null) { - int idx = (sourceChars.length - 1), off = until; - while (idx >= 0 && Character.isWhitespace(sourceChars[idx])) { - idx -= 1; off -= 1; - } - if (off < until) { - int[] row_col = locations.getRowCol(off); - root.setLineLast(row_col[0]); root.setColumnLast(row_col[1]); - } + // GRECLIPSE add + configureAST(answer, node); + if (isType(DOT, node)) { // exclude generics from end position + GroovySourceAST type = (GroovySourceAST) node.getFirstChild().getNextSibling(); + answer.setLastLineNumber(type.getLineLast()); + answer.setLastColumnNumber(type.getColumnLast()); + answer.setEnd(locations.findOffset(type.getLineLast(), type.getColumnLast())); } + // GRECLIPSE end } - // GRECLIPSE end + /* GRECLIPSE edit configureAST(answer, node); + */ } return answer; }