Community
Participate
Working Groups
Version: 3.1.0 Build id: I20050509-2010 Steps to reproduce: 1.) Create a new Class "Foo" 2.) Add two empty Methods "public void foo()" and "public void bar()" 3.) Refactor > Rename Method "bar()" into "foo" ignoring the Warning 4.) Refactor > Rename Method "foo" back to "bar" Actual Results: The error log shows an Internal Error (see Attachment) Expected Results: - Regards, Ben
Created attachment 20886 [details] Error Log
Markus, can you investigate? Is this a special case or should this be a M7 candidate?
Strange. After playing around a bit, the duplicated method can be renamed again. Need to debug. I assume there's some stale working copy lying around.
Moving to JDT/Core. This is a problem of the search engine. We search for declarations of foo() in workspace and get two matches with correct source ranges for the two methods. However, for both matches, getElement() returns an IMethod with occurrenceCount 1. Expected: the second match's element has occurrenceCount 2. Caveat: you have to select the second foo() to reproduce this - from the first foo(), it always works.
Problem comes from handle creation while reporting match. For a method, we get method from it's parent type using selector and type arguments. As it's a duplicate method we get twice the same handle... Do you need it for M7 or may be done for RC1?
This only happens when you have duplicate methods and try to refactor the second one. RC1 is fine with me.
OK, thanks
Fixed and released in HEAD. Duplicate methods are now correctly handled by search engine. [jdt-core internal] Changes done in MatchLocator: - add cache allHandleOccurences - modify method createHandle(AbstractMethodDeclaration,IJavaElement) - add createMethodHandle(...) - modify reportMatching(CompilationUnitDeclaration,boolean) Test case added in JavaSearchBugsTests
Verified in I20050526-2000