Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Fastest way to find all subtypes
Fastest way to find all subtypes [message #1133587] Sat, 12 October 2013 00:05 Go to next message
Marcel Bruch is currently offline Marcel BruchFriend
Messages: 289
Registered: July 2009
Senior Member

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
Marcel Bruch is currently offline Marcel BruchFriend
Messages: 289
Registered: July 2009
Senior Member

I'm struggling with some (I thought) trivial search. But apparently I miss something Sad

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
Previous Topic:Composition of Refactorings
Next Topic:Problem Exporting Signed Application Package for Android
Goto Forum:
  


Current Time: Thu Apr 18 18:47:03 GMT 2024

Powered by FUDForum. Page generated in 0.01981 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top