Community
Participate
Working Groups
While creating a new Java file Ive got into a state where a recurring "AST Creation Error" dialog pops up. Closing the dialog just causes it to immediately reappear. Restarting Eclipse didnt help. I can continue by closing the offending file (attached to this report), but the error recurrs if I open it. The file includes source fragments Ive just pasted in from an article and its undoubtedly invalid, but it shouldn't crash eclipse like this.
Created attachment 16282 [details] file that causes AST error
An internal error occurred during: "Java AST creation". java.lang.IllegalArgumentException org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2583) org.eclipse.jdt.core.dom.ASTConverter.updateInnerPositions (ASTConverter.java:2863) org.eclipse.jdt.core.dom.ASTConverter.setTypeForField(ASTConverter.java:2847) org.eclipse.jdt.core.dom.ASTConverter.convertToFieldDeclaration (ASTConverter.java:2779) org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleFieldDeclaration (ASTConverter.java:370) org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations (ASTConverter.java:330) org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:274) org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:152) org.eclipse.jdt.core.dom.ASTParser.convert(ASTParser.java:711) org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:681) org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:574) org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST (ASTProvider.java:439) org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:391) org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartLis tenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:159) org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run (SelectionListenerWithASTManager.java:136) org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
The problem is a syntax error in the file. David, why the dimensions are not included in the source positions of the type. With latest code, it doesn't crash anymore, but the positions are incorrect.
David, could you please investigate why the positions don't include the brackets? Once done, please move it back to me. I will ensure that the DOM/AST nodes have the proper positions.
This is a recovery problem. 1) If there is no syntax error then the declarationSourceEnd is at ';' location. 2) If there is a syntax error and the field have an initiliazer then the declarationSourceEnd is at the end of the initiliazer. 3) If there is a syntax error and the field have no initiliazer then the declarationSourceEnd is at the end of the field name. But the bracket are after the field name.
Created attachment 16321 [details] Released patch for positions problem Released patch for positions problem
Thanks, David. I will check that this fixed it for the ASTConverter. The converter assumes that the brackets are inside the positions as it scans the declaration to find the right positions for the brackets.
Fixed and released in HEAD. Regression test added. The type of the field declaration is a simple type "d" and the fragments has an extra dimension of 2.
Verified for 3.1 M4 using build I200412142000 + ASTView 1.0.2.