Fastest way to find all subtypes [message #1133587] |
Sat, 12 October 2013 00:05 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
I'm currently testing how to improve Eclipse default proposal sorting. One feature we take into account for ranking proposals is whether the type/return type of a type/field/method proposal is a subtype of the expected type.
Essentially we do:
expectedType = context.getExpectedType().orNull();
TimeDelimitedProgressMonitor monitor = new TimeDelimitedProgressMonitor(null, 300);
subtypes = expectedType.newTypeHierarchy(monitor).getAllSubtypes(expectedType);
Using that feature gives good results. However, it fails often because we have to terminate the subtype calculation after 300ms.
I wonder whether there is a (much faster) way of calculating all subtypes of a given type?
It doesn't have to return ITypes. Any signature would work in our case.
Thanks for pointers.
Marcel
|
|
|
Re: Fastest way to find all subtypes [message #1134488 is a reply to message #1133587] |
Sat, 12 October 2013 14:38 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
I'm struggling with some (I thought) trivial search. But apparently I miss something ![Sad](images/smiley_icons/icon_sad.gif)
I'm trying to find all subtypes of a given itype in a given java project. My understanding was that the code below should find all direct subtypes of "Composite". However, it only finds my source files in my project that extend composite but does not find any binary subtypes:
SearchPattern pattern = SearchPattern.createPattern("org.eclipse.swt.widgets.Composite",
IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS, R_EXACT_MATCH);
IJavaElement[] cp = new IJavaElement[] { context.getCompilationUnit().getJavaProject() };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(cp);
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) {
System.out.println(match.getElement());
}
};
SearchEngine searchEngine = new SearchEngine();
searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
scope, requestor, null /* progress monitor is not used here */);
Is there something obvious wrong with my code that explains why it fails to list binary types? When debugging into the search engine, I see that it actually finds all binary subtypes of Composite but they get filtered in org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(PossibleMatch, boolean), line 1706 where, after reading the binary info from the class file, the method simply returns instead of continuing. This looks suspicious but I definitely don't know enough to understand this fully. But maybe my failure is somewhere before that point?
Thanks,
Marcel
|
|
|
Powered by
FUDForum. Page generated in 0.02722 seconds