I want to programmatically get a model of an anonymous class or locally declared type (i.e. an IType instance) from the JDT Java Search Engine, known by its fully qualified name. So far, I have done well with the following when searching for "regular" types that were not nested in other types:
SearchPattern pattern = SearchPattern.createPattern(this.fullyQualifiedName, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
SearchRequestor requestor = new TypeSearchRequestor(this);
SearchEngine searchEngine = new SearchEngine();
searchEngine.search(pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, scope, requestor, null);
Why is it interrupted for anonymous classes and locally declared types, and how can I fix it? I suspect that I need to modify SearchPattern, but have not found anything convincing in JavaDoc.
Any recommendations are greatly appreciated.
Regards, Chris
Chris source
share