Skip to content

Commit

Permalink
Fix for #1169: adjust length of script run method
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 8, 2020
1 parent 07044bb commit 4325ec1
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,10 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
// GROOVY add
else end = (methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (start > 0)

if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,10 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
// GROOVY add
else end = (methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (start > 0)

if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,12 @@ public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.as
//int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd)
: methodDeclaration.scope != null ? methodDeclaration.getCompilationUnitDeclaration().sourceEnds.get(methodDeclaration) : -1);
if (end == start && "run".equals(methodName.getIdentifier())) //$NON-NLS-1$
end -= 1; // script run method has zero-length identifier
else if (start > 0)
// GROOVY end
if (end < start)
end = start + methodDeclaration.selector.length;// naive recovery with method name
end = start + methodDeclaration.selector.length - 1; // naive recovery with method name
methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
Expand Down

0 comments on commit 4325ec1

Please sign in to comment.