diff options
Diffstat (limited to 'java/java-indexing-api/src/com')
8 files changed, 42 insertions, 23 deletions
diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/AllOverridingMethodsSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/AllOverridingMethodsSearch.java index 4cc0cdf9642f..32067d077a48 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/AllOverridingMethodsSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/AllOverridingMethodsSearch.java @@ -23,6 +23,7 @@ import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiModifier; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.EmptyQuery; import com.intellij.util.Query; import com.intellij.util.QueryExecutor; @@ -63,6 +64,6 @@ public class AllOverridingMethodsSearch extends ExtensibleQueryFactory<Pair<PsiM } public static Query<Pair<PsiMethod, PsiMethod>> search(final PsiClass aClass) { - return search(aClass, GlobalSearchScope.allScope(aClass.getProject())); + return search(aClass, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(aClass))); } } diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedMembersSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedMembersSearch.java index 14e37a51b86f..f6003eb12fb5 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedMembersSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedMembersSearch.java @@ -19,6 +19,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMember; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.Query; import org.jetbrains.annotations.NotNull; @@ -34,6 +35,6 @@ public class AnnotatedMembersSearch { } public static Query<PsiMember> search(@NotNull PsiClass annotationClass) { - return search(annotationClass, GlobalSearchScope.allScope(annotationClass.getProject())); + return search(annotationClass, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(annotationClass))); } } diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedPackagesSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedPackagesSearch.java index 17e3fa0f617c..69548d5ff317 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedPackagesSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotatedPackagesSearch.java @@ -19,6 +19,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiPackage; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.Query; import org.jetbrains.annotations.NotNull; @@ -53,6 +54,6 @@ public class AnnotatedPackagesSearch extends ExtensibleQueryFactory<PsiPackage, } public static Query<PsiPackage> search(@NotNull PsiClass annotationClass) { - return search(annotationClass, GlobalSearchScope.allScope(annotationClass.getProject())); + return search(annotationClass, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(annotationClass))); } }
\ No newline at end of file diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotationTargetsSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotationTargetsSearch.java index c177985396a9..0b42ceae1709 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotationTargetsSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/AnnotationTargetsSearch.java @@ -21,6 +21,7 @@ import com.intellij.psi.PsiModifierListOwner; import com.intellij.psi.PsiPackage; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.MergeQuery; import com.intellij.util.Query; import org.jetbrains.annotations.NotNull; @@ -58,6 +59,6 @@ public class AnnotationTargetsSearch { } public static Query<PsiModifierListOwner> search(@NotNull PsiClass annotationClass) { - return search(annotationClass, GlobalSearchScope.allScope(annotationClass.getProject())); + return search(annotationClass, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(annotationClass))); } }
\ No newline at end of file diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java index e07692008ff9..cc6bf9d3044d 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressIndicatorProvider; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; @@ -28,6 +29,7 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PsiSearchScopeUtil; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.reference.SoftReference; import com.intellij.util.Processor; import com.intellij.util.Query; @@ -188,7 +190,8 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas } }); if (CommonClassNames.JAVA_LANG_OBJECT.equals(qname)) { - return AllClassesSearch.search(searchScope, baseClass.getProject(), parameters.getNameCondition()).forEach(new Processor<PsiClass>() { + Project project = PsiUtilCore.getProjectInReadAction(baseClass); + return AllClassesSearch.search(searchScope, project, parameters.getNameCondition()).forEach(new Processor<PsiClass>() { @Override public boolean process(final PsiClass aClass) { ProgressIndicatorProvider.checkCanceled(); @@ -250,7 +253,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas } }; stack.push(Pair.create(createHardReference(baseClass), qname)); - final GlobalSearchScope projectScope = GlobalSearchScope.allScope(baseClass.getProject()); + final GlobalSearchScope projectScope = GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(baseClass)); final JavaPsiFacade facade = JavaPsiFacade.getInstance(projectScope.getProject()); while (!stack.isEmpty()) { ProgressIndicatorProvider.checkCanceled(); diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/DirectClassInheritorsSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/DirectClassInheritorsSearch.java index da798a15ed3b..1a98d0c167d3 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/DirectClassInheritorsSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/DirectClassInheritorsSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.intellij.psi.PsiAnonymousClass; import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.FilteredQuery; import com.intellij.util.Query; import com.intellij.util.QueryExecutor; @@ -73,7 +74,7 @@ public class DirectClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass private DirectClassInheritorsSearch() {} public static Query<PsiClass> search(final PsiClass aClass) { - return search(aClass, GlobalSearchScope.allScope(aClass.getProject())); + return search(aClass, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(aClass))); } public static Query<PsiClass> search(final PsiClass aClass, SearchScope scope) { diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java index 8ad915c5ed95..f729579a5782 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java @@ -15,7 +15,9 @@ */ package com.intellij.psi.search.searches; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiFunctionalExpression; import com.intellij.psi.PsiMethod; @@ -23,6 +25,7 @@ import com.intellij.psi.PsiModifier; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PsiSearchHelper; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.EmptyQuery; import com.intellij.util.Query; import com.intellij.util.QueryExecutor; @@ -36,7 +39,7 @@ public class FunctionalExpressionSearch extends ExtensibleQueryFactory<PsiFuncti private final PsiClass myElementToSearch; private final SearchScope myScope; - public SearchParameters(PsiClass aClass, SearchScope scope) { + public SearchParameters(@NotNull PsiClass aClass, @NotNull SearchScope scope) { myElementToSearch = aClass; myScope = scope; } @@ -52,23 +55,28 @@ public class FunctionalExpressionSearch extends ExtensibleQueryFactory<PsiFuncti } } - public static Query<PsiFunctionalExpression> search(final PsiClass aClass, SearchScope scope) { + public static Query<PsiFunctionalExpression> search(@NotNull final PsiClass aClass, @NotNull SearchScope scope) { return INSTANCE.createUniqueResultsQuery(new SearchParameters(aClass, scope)); } - public static Query<PsiFunctionalExpression> search(final PsiMethod psiMethod) { - return search(psiMethod, GlobalSearchScope.allScope(psiMethod.getProject())); + public static Query<PsiFunctionalExpression> search(@NotNull final PsiMethod psiMethod) { + return search(psiMethod, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(psiMethod))); } - public static Query<PsiFunctionalExpression> search(final PsiMethod psiMethod, SearchScope scope) { - if (!psiMethod.hasModifierProperty(PsiModifier.STATIC) && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) { - return INSTANCE.createUniqueResultsQuery(new SearchParameters(psiMethod.getContainingClass(), scope)); - } + public static Query<PsiFunctionalExpression> search(@NotNull final PsiMethod psiMethod, @NotNull final SearchScope scope) { + return ApplicationManager.getApplication().runReadAction(new Computable<Query<PsiFunctionalExpression>>() { + @Override + public Query<PsiFunctionalExpression> compute() { + if (!psiMethod.hasModifierProperty(PsiModifier.STATIC) && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) { + return INSTANCE.createUniqueResultsQuery(new SearchParameters(psiMethod.getContainingClass(), scope)); + } - return EmptyQuery.getEmptyQuery(); + return EmptyQuery.getEmptyQuery(); + } + }); } - public static Query<PsiFunctionalExpression> search(final PsiClass aClass) { - return search(aClass, GlobalSearchScope.allScope(aClass.getProject())); + public static Query<PsiFunctionalExpression> search(@NotNull final PsiClass aClass) { + return search(aClass, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(aClass))); } } diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/MethodReferencesSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/MethodReferencesSearch.java index 5dd9726db029..e6b0e19e9701 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/MethodReferencesSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/MethodReferencesSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,11 @@ package com.intellij.psi.search.searches; import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.project.Project; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiReference; import com.intellij.psi.search.*; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -98,11 +100,12 @@ public static void searchOptimized(final PsiMethod method, SearchScope scope, fi final SearchRequestCollector requests = parameters.getOptimizer(); - return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(parameters.getMethod().getProject(), requests))); + Project project = PsiUtilCore.getProjectInReadAction(parameters.getMethod()); + return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(project, requests))); } public static Query<PsiReference> search(final PsiMethod method, final boolean strictSignatureSearch) { - return search(method, GlobalSearchScope.allScope(method.getProject()), strictSignatureSearch); + return search(method, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(method)), strictSignatureSearch); } public static Query<PsiReference> search(final PsiMethod method) { |