Bug 79953 - AST Creation Error while editing Java file
Summary: AST Creation Error while editing Java file
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-01 20:09 EST by BenH CLA
Modified: 2004-12-15 12:49 EST (History)
1 user (show)

See Also:


Attachments
file that causes AST error (3.37 KB, application/octet-stream)
2004-12-01 20:11 EST, BenH CLA
no flags Details
Released patch for positions problem (1.35 KB, text/plain)
2004-12-03 05:30 EST, David Audel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description BenH CLA 2004-12-01 20:09:51 EST
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.
Comment 1 BenH CLA 2004-12-01 20:11:09 EST
Created attachment 16282 [details]
file that causes AST error
Comment 2 BenH CLA 2004-12-01 20:15:23 EST
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)
Comment 3 Olivier Thomann CLA 2004-12-02 11:16:10 EST
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.
Comment 4 Olivier Thomann CLA 2004-12-02 19:59:32 EST
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.
Comment 5 David Audel CLA 2004-12-03 05:23:05 EST
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.
Comment 6 David Audel CLA 2004-12-03 05:30:36 EST
Created attachment 16321 [details]
Released patch for positions problem

Released patch for positions problem
Comment 7 Olivier Thomann CLA 2004-12-03 10:00:53 EST
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.
Comment 8 Olivier Thomann CLA 2004-12-08 14:32:01 EST
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.
Comment 9 Frederic Fusier CLA 2004-12-15 12:49:16 EST
Verified for 3.1 M4 using build I200412142000 + ASTView 1.0.2.