Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 2.1.0Release
-
Fix Version/s: 2.1.1Release
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
From the mailing list:
I have only been able to reproduce this with a new/empty project.
------
Here is a test case:
1. Fresh install of Eclipse 3.6.1 with Greclipse 2.1.0 (or dev build for 3.6)
2. Add an import statement (e.g. 'import java.lang.*'):
- 'Preferences' > 'Java' > 'Code Style' > 'Code Templates'
- Edit template under 'Code' and 'New Java files'
- add the import statement
3. New Groovy project, then new Groovy class
We get an error dialog 'Creation of element failed. See error log for more details'. See the stack trace below.
Is this a known problem? Is there a fix or patch for that, which I can use upon 2.1.0? (That's a blocker for me ATM).
Thanks in advance.
Cheers,
Patrick
—
Root exception:
java.lang.IllegalArgumentException
at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2617)
at org.eclipse.jdt.core.dom.ASTConverter.setQualifiedNameNameAndSourceRanges(ASTConverter.java:4949)
at org.eclipse.jdt.core.dom.ASTConverter.convertImport(ASTConverter.java:2885)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1326)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:291)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1201)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801)
at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createASTForImports(NewTypeWizardPage.java:2112)
at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType(NewTypeWizardPage.java:1978)
at org.codehaus.groovy.eclipse.wizards.NewClassWizardPage.createType(NewClassWizardPage.java:111)
at org.codehaus.groovy.eclipse.wizards.NewClassWizard.finishPage(NewClassWizard.java:64)
at org.eclipse.jdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:117)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4777)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:106)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
The problem comes about since the source locations for package imports is incorrect. The groovy parser is inconsistent when it creates source locations for import statements.
We were incorrectly calculating start locations for import* imports based on the assumption that the ASTNode started with the type name, not the 'import' keyword. Our tests didn't catch this since all of them use package statements and this problem was hidden. Writing a new test case now.
Note that the exception above only occurs in the default package.