Community
Participate
Working Groups
For the new RippleMethodFinder, we need to search for all declarations of a given method signature in the workspace. This search should *not* take the declaring type into account, only the signature must match. The current behaviour of search for method declarations of an IMethod in workspace does not make much sense, since it is exactly the same search as when searching in the hierarchy of the declaring type. Therefore, I think that search for method declarations in workspace should be changed to only consider the method signature of a given IMethod, and not its declaring type. Note that a string pattern search does not help here, since it only takes strings as parameter types, but we need the real type reference in the method parameters.
As discussed on the phone, this "ignore declaring type but consider exact parameter types" will be implemented by an additional flag for a SearchPattern.
Should also consider a flag for ignoring return type.
Could be carried only by pattern factory using element as a variation on limitTo parameter.
For the RippleMethodFinder, the return type should also be ignored. Otherwise, we won't find methods with covariant return types. See also bug 87778.
Proposal is to add 2 new constants in IJavaSearchConstants: /** * Ignore declaring type while searching result. * Can be used in conjunction with any of the nature of match. * @since 3.1 */ int IGNORE_DECLARING_TYPE = 0x10; /** * Ignore return type while searching result. * Can be used in conjunction with any of the nature of match. * Note that for fields search, pattern will ignore field type. * This value will have no effect for types search. * @since 3.1 */ int IGNORE_RETURN_TYPE = 0x20; Then client will have to set these flags on limitTo value while creating pattern and search engine will ignore corresponding types. Using bug 87778 example + class C: class A { A stable() { return null; } A covariant() { return null; } } class B extends A { A stable() { return null; } B covariant() { return null; } } class C { A stable() { return null; } A covariant() { return null; } } Search for declarations of A.covariant will return: Normal: 2 matches (in A and in B) IGNORE_DECLARING_TYPE: 2 match (in A and in C) IGNORE_RETURN_TYPE: 2 matches (in A and in B) IGNORE_DECLARING_TYPE+IGNORE_RETURN_TYPE: 3 matches (in A, in B and in C) Let me know if this behavior matches your requirement.
That's perfect.
Fixed. Implementation is described in comment 5. [jdt-core-internal] Changes done in IJavaSearchConstants and SearchPattern. Test cases added in JavaSearchBugsTests
Verified in I20050330-0500