Summary: | Rename operation during refactoring fails | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Martin Kersten <Martin.Kersten> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | jpljpl |
Version: | 2.1 | ||
Target Milestone: | 3.0 M3 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Martin Kersten
2003-04-15 02:46:49 EDT
Please provide reproduceable steps for further investigation After solving some errors in other classes which occured during movement, I can rename all classes. Therefor I changed the severity to normal because It didn't gave me a big headache. Thanks again, Martin Well I don't know how to reproduce it. Maybe it helps to describe what I have done. Projects: normal - Containing code. normal.test - Containing JUnit tests, uses exactly the same package structure as normal. Class: Cache - Implements a guarded cache. Cache.Key - Implements a simple Key class to hide that from callers Aspect - Particular Aspect of database informations using the Cache (was extracted from their for better reuse). TestClasses: TestCache TestCacheKey TestAspect First of all after extracting the Cache from Aspect I rerun the test suite, everything fine. Then after realising that Cache.Key (private class of cache) is used by Aspect and TestAspect I decided to create package *.cache and move the Cache class to it. The TestCache and TestCacheKey were also moved to a package *.cache within the test project. Problem was Cache.Key is package level so I excluded it from Cache class and tried to rename it in order to introduce other Key types. That was when the error occured. I think that the problem may be caused by a non-exsisting Cache.Key class but everyone referred to it. And then trying to rename a class Key had blown up the scene. Renaming Cache class also produced the same error footprint. Solution: Created a new Class with the new key name. Deleting the Key class, and moving its content to the new class, correcting all the bad references allowed me to rename the class Cache. I will try to reproduce the error again to ease your work. looks like a problem in org.eclipse.jdt.internal.core.search.matching. TypeReferencePattern - moving to jcore Got the cause: Having the following situation will cause the problem. Same project: package pack1: class A package pack1.sub: class B class C Adding a cast to a method of class A: ((B.C)new Object()).hashCode(); Then trying to rename B or C will fail producing the error and either B nor C can be renamed but deleted. Sharper Version: as above but without C (only having A and B) again add a cast of B to A like: (NonExsisting.B); Again rename of B, will fail. Other more weird try: Add ((Unknown.Key)new Object()).hashCode(); to a class of any package. Even if the class does not import Key or the package of Key or any other class from its package, renaming Key will fail. But only adding lines like Unknown.Key a; will do nothing. So it seams to doing a cast and using a method of the casted instance will cause an error while renaming a class named the same like the non exsisting inherited class of an non-exsisting class. Hope that helped. Martin Thanks for the test cases Martin. Fixed TypeReferencePattern.matchReportReference(QualifiedNameReference, ...) to check for the case of a ProblemBinding. Made the same change to DeclarationOfReferencedTypesPattern.matchReportReference (AstNode, ...) and PackageReferencePattern.matchLevel and matchReportReference. Added regression test JavaSearchTests.testTypeReferenceWithProblem() *** Bug 41821 has been marked as a duplicate of this bug. *** Verified. |