Bug 95262

Summary: ASTParser fails with K_CLASS_BODY_DECLARATIONS
Product: [Eclipse Project] JDT Reporter: julien <yang_ying_min>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description julien CLA 2005-05-14 07:07:11 EDT
I download M7 and noticed an error with ASTParser. Here is the code:

ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
parser.setSource("private static Category[] values = new Category[]{v1, v2, 
v3};".toCharArray());
ASTNode root = (ASTNode) parser.createAST(null);

It gives the following exception:

java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2583)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:769)
	at org.eclipse.jdt.core.dom.ASTConverter.convert
(ASTConverter.java:1443)
	at 
org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationFragment
(ASTConverter.java:2789)
	at org.eclipse.jdt.core.dom.ASTConverter.convertToFieldDeclaration
(ASTConverter.java:2692)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:874)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTForKind
(ASTParser.java:949)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST
(ASTParser.java:716)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:570)
Comment 1 Olivier Thomann CLA 2005-05-16 15:53:59 EDT
Fixed and released in HEAD.
Regression test in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test607.
Comment 2 Frederic Fusier CLA 2005-05-27 06:43:19 EDT
Verified for 3.1 RC1 with build I20050527-0010.