Bug 80264 - [search] Search for method declarations in workspace, disregarding declaring type
Summary: [search] Search for method declarations in workspace, disregarding declaring ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 76014 79976
  Show dependency tree
 
Reported: 2004-12-06 09:23 EST by Markus Keller CLA
Modified: 2005-03-31 03:35 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2004-12-06 09:23:36 EST
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.
Comment 1 Markus Keller CLA 2004-12-07 11:06:54 EST
As discussed on the phone, this "ignore declaring type but consider exact
parameter types" will be implemented by an additional flag for a SearchPattern.
Comment 2 Philipe Mulet CLA 2005-01-10 10:49:35 EST
Should also consider a flag for ignoring return type.
Comment 3 Philipe Mulet CLA 2005-03-11 09:52:27 EST
Could be carried only by pattern factory using element as a variation on limitTo
parameter.
Comment 4 Markus Keller CLA 2005-03-11 10:42:57 EST
For the RippleMethodFinder, the return type should also be ignored. Otherwise,
we won't find methods with covariant return types. See also bug 87778.
Comment 5 Frederic Fusier CLA 2005-03-11 13:07:02 EST
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.
Comment 6 Markus Keller CLA 2005-03-14 03:41:21 EST
That's perfect.
Comment 7 Frederic Fusier CLA 2005-03-14 09:44:21 EST
Fixed.

Implementation is described in comment 5.

[jdt-core-internal]
Changes done in IJavaSearchConstants and SearchPattern.
Test cases added in JavaSearchBugsTests
Comment 8 David Audel CLA 2005-03-31 03:35:30 EST
Verified in I20050330-0500