eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
158 stars 126 forks source link

Search engine does not find annotation type references in required plug-ins #1297

Closed subyssurendran666 closed 11 months ago

subyssurendran666 commented 1 year ago

Using the search engine to find references of an annotation type does not produce any findings in the required plug-ins of a plug-in project. Take a look at the following search configuration:

SearchPattern pattern = SearchPattern.createPattern(myAnnotationName, IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE, SearchPattern.R_EXACT_MATCH);

IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {myJavaProject}, true);

The above configuration does not find the expected matches of myAnnotationName inside the required plug-ins of myJavaProject. The required plug-ins are binary.

The strange thing is that all references are found when extending the scope to the entire workspace searching for type references:

SearchPattern pattern = SearchPattern.createPattern(myAnnotationName, IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, SearchPattern.R_EXACT_MATCH);

IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

So it seems that broadening the search space leads to more findings, although IMHO all matches should also be found when the search space is restricted to the respective project only.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=578102

subyssurendran666 commented 11 months ago

The JUnit test case is operating without any issues, so we are now closing the ticket.