Search in sources :

Example 1 with QueryExecutor

use of com.intellij.util.QueryExecutor in project intellij-community by JetBrains.

the class ClassesWithAnnotatedMembersSearcher method processQuery.

@Override
public void processQuery(@NotNull ClassesWithAnnotatedMembersSearch.Parameters queryParameters, @NotNull final Processor<PsiClass> consumer) {
    SearchScope scope = queryParameters.getScope();
    for (QueryExecutor executor : Extensions.getExtensions(ClassesWithAnnotatedMembersSearch.EP_NAME)) {
        if (executor instanceof ScopedQueryExecutor) {
            scope = scope.intersectWith(GlobalSearchScope.notScope(((ScopedQueryExecutor) executor).getScope(queryParameters)));
        }
    }
    final Set<PsiClass> processed = new HashSet<>();
    AnnotatedElementsSearch.searchPsiMembers(queryParameters.getAnnotationClass(), scope).forEach(member -> {
        PsiClass psiClass;
        AccessToken token = ReadAction.start();
        try {
            psiClass = member instanceof PsiClass ? (PsiClass) member : member.getContainingClass();
        } finally {
            token.finish();
        }
        if (psiClass != null && processed.add(psiClass)) {
            consumer.process(psiClass);
        }
        return true;
    });
}
Also used : QueryExecutor(com.intellij.util.QueryExecutor) ScopedQueryExecutor(com.intellij.psi.search.searches.ScopedQueryExecutor) AccessToken(com.intellij.openapi.application.AccessToken) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) SearchScope(com.intellij.psi.search.SearchScope) PsiClass(com.intellij.psi.PsiClass) ScopedQueryExecutor(com.intellij.psi.search.searches.ScopedQueryExecutor) HashSet(com.intellij.util.containers.hash.HashSet)

Aggregations

AccessToken (com.intellij.openapi.application.AccessToken)1 PsiClass (com.intellij.psi.PsiClass)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 SearchScope (com.intellij.psi.search.SearchScope)1 ScopedQueryExecutor (com.intellij.psi.search.searches.ScopedQueryExecutor)1 QueryExecutor (com.intellij.util.QueryExecutor)1 HashSet (com.intellij.util.containers.hash.HashSet)1