Community
Participate
Working Groups
given the source: -----------start---------- //cannot rename to i, i package p; class A{ int m(){ int i, /*[*/int j/*]*/; return 0; }; } -----------end---------- AST.parseCompilationUnit(cu, true) results in an exception: java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:1018) at org.eclipse.jdt.core.dom.ASTConverter.convertPackage (ASTConverter.java:98) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:57) at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:230) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTempRefactoring.initial izeAst(RenameTempRefactoring.java:151) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTempRefactoring.checkAc tivation(RenameTempRefactoring.java:123) at org.eclipse.jdt.internal.corext.refactoring.base.Refactoring.checkPreconditions (Refactoring.java:80) at org.eclipse.jdt.ui.tests.refactoring.RefactoringTest.performRefactoring (RefactoringTest.java:107) at org.eclipse.jdt.ui.tests.refactoring.RenameTempTests.helper2 (RenameTempTests.java:97) at org.eclipse.jdt.ui.tests.refactoring.RenameTempTests.helper2 (RenameTempTests.java:102) at org.eclipse.jdt.ui.tests.refactoring.RenameTempTests.testFail2 (RenameTempTests.java:272) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:42) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:28) at java.lang.reflect.Method.invoke(Method.java:327) at junit.framework.TestCase.runTest(TestCase.java:166) at junit.framework.TestCase.runBare(TestCase.java:140) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:23) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:319) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:215) at org.eclipse.pde.internal.junit.ui.RemotePluginTestRunner.main (RemotePluginTestRunner.java:30) at org.eclipse.pde.internal.junit.ui.UITestApplication.runEventLoop (UITestApplication.java:34) at org.eclipse.ui.internal.Workbench.run(Workbench.java:771) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:42) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:28) at java.lang.reflect.Method.invoke(Method.java:327) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
Did you use the code I released on Friday to get this error? I could not reproduce with latest code.
I cannot reproduce with latest code. I found a problem in the given code. This code is syntaxically incorrect. It should be: package p; class A{ int m(){ int i, /*[*/j/*]*/; return 0; }; } otherwise you have a syntax error on the second 'int'. You get "identifier expected". I close this PR.
The problem comes from the comment line at the beginning of the code. In this case the import declarationEnd is not set (equals to 0) and then the settings of the source range for the package declaration fails.
This is fixed now. The problem was due to the syntax error. In the recovery mode, one of the positions stored in the import reference (package declaration) was missing. Fixed and released in HEAD.