use of org.eclipse.jdt.core.search.SearchEngine in project eclipse.jdt.ls by eclipse.
the class ReferenceFinderUtil method getTypeReferencesIn.
private static List<SearchMatch> getTypeReferencesIn(IJavaElement element, WorkingCopyOwner owner, IProgressMonitor pm) throws JavaModelException {
CollectingSearchRequestor requestor = new CollectingSearchRequestor();
SearchEngine engine = owner != null ? new SearchEngine(owner) : new SearchEngine();
engine.searchDeclarationsOfReferencedTypes(element, requestor, pm);
return requestor.getResults();
}
use of org.eclipse.jdt.core.search.SearchEngine in project eclipse.jdt.ls by eclipse.
the class ReferenceFinderUtil method getFieldReferencesIn.
private static List<SearchMatch> getFieldReferencesIn(IJavaElement element, WorkingCopyOwner owner, IProgressMonitor pm) throws JavaModelException {
CollectingSearchRequestor requestor = new CollectingSearchRequestor();
SearchEngine engine = owner != null ? new SearchEngine(owner) : new SearchEngine();
engine.searchDeclarationsOfAccessedFields(element, requestor, pm);
return requestor.getResults();
}
use of org.eclipse.jdt.core.search.SearchEngine in project eclipse.jdt.ls by eclipse.
the class ReferenceFinderUtil method getMethodReferencesIn.
private static List<SearchMatch> getMethodReferencesIn(IJavaElement element, WorkingCopyOwner owner, IProgressMonitor pm) throws JavaModelException {
CollectingSearchRequestor requestor = new CollectingSearchRequestor();
SearchEngine engine = owner != null ? new SearchEngine(owner) : new SearchEngine();
engine.searchDeclarationsOfSentMessages(element, requestor, pm);
return requestor.getResults();
}
use of org.eclipse.jdt.core.search.SearchEngine in project eclipse.jdt.ls by eclipse.
the class RippleMethodFinder2 method findAllDeclarations.
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException {
fDeclarations = new ArrayList<>();
class MethodRequestor extends SearchRequestor {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IMethod method = (IMethod) match.getElement();
boolean isBinary = method.isBinary();
if (fBinaryRefs != null || !(fExcludeBinaries && isBinary)) {
fDeclarations.add(method);
}
if (isBinary && fBinaryRefs != null) {
fDeclarationToMatch.put(method, match);
}
}
}
int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE;
int matchRule = SearchPattern.R_ERASURE_MATCH | SearchPattern.R_CASE_SENSITIVE;
SearchPattern pattern = SearchPattern.createPattern(fMethod, limitTo, matchRule);
SearchParticipant[] participants = SearchUtils.getDefaultSearchParticipants();
IJavaSearchScope scope = RefactoringScopeFactory.createRelatedProjectsScope(fMethod.getJavaProject(), IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SYSTEM_LIBRARIES);
MethodRequestor requestor = new MethodRequestor();
SearchEngine searchEngine = owner != null ? new SearchEngine(owner) : new SearchEngine();
searchEngine.search(pattern, participants, scope, requestor, monitor);
}
use of org.eclipse.jdt.core.search.SearchEngine in project eclipse.jdt.ls by eclipse.
the class ClassFileUtil method getURI.
public static String getURI(IProject project, String fqcn) throws JavaModelException {
Assert.isNotNull(project, "Project can't be null");
Assert.isNotNull(fqcn, "FQCN can't be null");
IJavaProject javaProject = JavaCore.create(project);
int lastDot = fqcn.lastIndexOf(".");
String packageName = lastDot > 0 ? fqcn.substring(0, lastDot) : "";
String className = lastDot > 0 ? fqcn.substring(lastDot + 1) : fqcn;
ClassUriExtractor extractor = new ClassUriExtractor();
new SearchEngine().searchAllTypeNames(packageName.toCharArray(), SearchPattern.R_EXACT_MATCH, className.toCharArray(), SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, JDTUtils.createSearchScope(javaProject, JavaLanguageServerPlugin.getPreferencesManager()), extractor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
return extractor.uri;
}
Aggregations