Bug 87350 - IllegalArgumentException when converting AST with invalid enum body declaration
Summary: IllegalArgumentException when converting AST with invalid enum body declaration
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-08 04:12 EST by Markus Keller CLA
Modified: 2005-03-30 23:21 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-03-08 04:12:59 EST
JDT/Core v_539

package xy;

public enum Color {
    RED, GREEN(), BLUE(17), PINK(1) {/*anon*};
    Color() {}
    Color(int i) {}
}

Error 2005-03-08 10:12:45.838 An internal error occurred during: "Requesting
Java AST from selection".
java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2586)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1292)
	at
org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:238)
	at
org.eclipse.jdt.core.dom.ASTConverter.convertToEnumDeclaration(ASTConverter.java:2612)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2369)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1147)
	at
org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:249)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:787)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:575)
	at
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:565)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:496)
	at
org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:165)
	at
org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:142)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:67)
Comment 1 Olivier Thomann CLA 2005-03-08 11:20:48 EST
I am investigating.
Comment 2 Olivier Thomann CLA 2005-03-08 11:53:59 EST
The problem is in the recovery. The anonymous type for PINK is not closed.
Comment 3 David Audel CLA 2005-03-10 10:36:29 EST
Fixed.

If the declarationSourceEnd of the last enum constant body is 0 then this
declarationSourceEnd must be set to the value of the declarationSourceEnd of the
enum constant.
Comment 4 Olivier Thomann CLA 2005-03-10 11:12:28 EST
Regression test added in ASTConverter15Test.test0145.
Comment 5 Olivier Thomann CLA 2005-03-11 10:53:41 EST
Reopen.
If the test case is:
package xy;

public enum Color {
    RED, GREEN(), BLUE(17), PINK(1) {/*anon*};
    Color() {}
    Color(int i) {}

It doesn't work.
I am investigating.
Comment 6 Olivier Thomann CLA 2005-03-11 11:20:46 EST
Fixed and released in HEAD.
New test case added in ASTConverter15Test.test0148.
Comment 7 Olivier Thomann CLA 2005-03-30 23:21:22 EST
Verified in 20050330-0500