[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.jdt] Searching for classes that extend other classes, bug #2?
|
- From: Eddie Galvez <eddie@xxxxxxxxxxxxxx>
- Date: Wed, 25 Jul 2007 16:14:21 -0400
- Newsgroups: eclipse.tools.jdt
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.4 (Windows/20070604)
I saw Mairtin's recent post, and I have a bug in the same vicinity, but
not the same thing:
In Eclipse 3.2(.2):
I am trying to use the JDT search engine to find implementors of a few
classes at the same time. After a lot and a lot of debugging, it seemed
to me that the jdt search code contradicts the javadoc contract when
using the IMPLEMENTORS flag:
Doing what the javadoc suggests for a standard class pattern search,
SearchPattern.createPattern("package1.Class1",
IJavaSearchConstants.CLASS, IJavaSearchConstants.IMPLEMENTORS,
SearchPattern.R_EXACT_MATCH)
will actually not properly return you all subclasses; deep in the code
there is a moment whereby if the class being searched for is not an
interface, the result matches are not passed on as a result match. (that
is, improper flags are given to internal searchpattern classes, namely
SuperTypeReferencePattern which is given a flag that precludes it from
accepting class types)
The workaround in our product today is to reach in and use the
implementation patterns that do work when the correct arguments are used:
SearchPattern inp = new
SuperTypeReferencePattern("package1".toCharArray(),
"Class1".toCharArray(), SuperTypeReferencePattern.ONLY_SUPER_CLASSES,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
SearchPattern outp = new
SuperTypeReferencePattern("package1".toCharArray(),
"Class2".toCharArray(), SuperTypeReferencePattern.ONLY_SUPER_CLASSES,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
SearchPattern op = new
SuperTypeReferencePattern("package2".toCharArray(),
"Class3".toCharArray(), SuperTypeReferencePattern.ONLY_SUPER_CLASSES,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
SearchPattern or1 = SearchPattern.createOrPattern(inp, outp);
SearchPattern pattern = SearchPattern.createOrPattern(op, or1);
This works properly.
In particular, note that the bug manifests in that the search engine
fails to find all classes in the java project build path when there is a
mix of:
source classes
binary classes contained in a library file (jar)
It will find some, but not all. That may be a hint as to when the bug
manifests. Unfortunately I don't have handy the exact search patterns
that would fail (and what they would display given a test case), but I
could retrieve them if needed.
One could also observe the bug when using the JDT search engine UI from
eclipse itself.
As a reminder, this is against 3.2.
Thank you!