Community
Participate
Working Groups
Hi, first let me show you the stacktrace: [java] Caused by: java.lang.ArrayIndexOutOfBoundsException: -1 [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.getIndentOfLine(ASTRewriteAnalyzer.java:228) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.getIndent(ASTRewriteAnalyzer.java:1016) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.rewriteRequiredNode(ASTRewriteAnalyzer.java:582) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:2443) [java] at org.eclipse.jdt.core.dom.SingleVariableDeclaration.accept0(SingleVariableDeclaration.java:364) [java] at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2466) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:314) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:320) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitUnchangedChildren(ASTRewriteAnalyzer.java:335) [java] at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1812) [java] at org.eclipse.jdt.core.dom.CatchClause.accept0(CatchClause.java:160) [java] at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2466) [java] at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.internalRewriteAST(ASTRewrite.java:255) [java] at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.rewriteAST(ASTRewrite.java:188) [java] at ***.VisitorHandler.handle(VisitorHandler.java:183) I looked quickly at the code and got the impression that ListLineTracker.getLineOffset(line) returns -1 and so the method breaks. It might be investigated, why it returns -1 at all... I have a hard time reproducing the problem, as it only occurs on the production system, but not in my test environment. For know I hope that you see something in the code which could explain that -1 at this point. As soon as I find a way to reproduce the problem, I add the info here. Thanks, Daniel
Created attachment 56535 [details] AST Parser test Use this file to reproduce the issue.
I encountered this problem and it turned out to be caused by the fact that the Document I created for the rewrite was empty when I should have initialized it with the contents of the compilation unit from before the changes were made to the ASTNode's. Obviously, the deeply nested ArrayIndexOutOfBoundsException is not the best way to report that programming error.
fixed > 20070212
Verified for 3.3 M6 using build I20070320-0010