Community
Participate
Working Groups
M4 test pass (I20041214-2000-gtk) - Have the class below - Rename fList to fElements Expected: the field and the reference in the ctor are renamed Actual: only the field is renamed; no warning in preview Note: the same operation succeeds when not a nested type is used as parameter (e.g. String). --------- snip ----------- package com.example.m4testing; import java.util.List; public class Test { static class Element{ } static class Inner { private final List<Element> fList; public Inner(List<Element> list) { fList= list; } } }
*** Bug 81085 has been marked as a duplicate of this bug. ***
Works if fList is declared as List. However searching for fList in the given test cases correctly reports a match. So it seems to be a refactoring problem, not a search problem. Not critical for M4.
Moving to JDT/Core for comments. In RenameFieldProcessor#getReferences(..), we search for references to fList without giving a matchRule. I would expect that the matchRule has no effect on field searches, but without giving a matchRule, the reference is not found. When I supply match Rule R_EXACT_MATCH | R_CASE_SENSITIVE | R_ERASURE_MATCH, the field reference is found. See also bug 81376.
Markus, Searching for reference with default match rule (ie. calling createPattern(IJavaElement element, int limitTo) should find field references. You don't need to precise R_ERASURE_MATCH to find them. The problem here comes from the fact that type argument is a member type. There's a bug in name comparison which does not take into account enclosing type(s) and that's why the exact match fails. So, this bug does not change the fact that R_ERASURE_MATCH match rule is only meaningful for types, not for fields search. I will precise this point in Javadocs while fixing bug 81376).
You can see that modifying initial test case as follow: package com.example.m4testing; import java.util.List; public class Test { static class Element{ } static class Inner { private final List<Test.Element> fList; public Inner(List<Element> list) { fList= list; } } } ...and then refactor will work properly.
Fixed. Now search engine finds references to this field even if R_ERASURE_MATCH is not set. [jdt-core-internal] Change done in PatternLocator.resolveLevelForType (char[], char[], char[][][], int, TypeBinding). Test cases added in JavaSearchBugsTests
Verified for 3.1M5