mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more checkCanceled
This commit is contained in:
+4
-3
@@ -21,6 +21,7 @@ import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -81,7 +82,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase<PsiClass, Cla
|
||||
AllClassesSearch.search(searchScope, project, parameters.getNameCondition()).forEach(new Processor<PsiClass>() {
|
||||
@Override
|
||||
public boolean process(final PsiClass aClass) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
ProgressManager.checkCanceled();
|
||||
return isJavaLangObject(aClass) || consumer.process(aClass);
|
||||
}
|
||||
});
|
||||
@@ -95,7 +96,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase<PsiClass, Cla
|
||||
final Processor<PsiClass> processor = new ReadActionProcessor<PsiClass>() {
|
||||
@Override
|
||||
public boolean processInReadAction(PsiClass candidate) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
if (parameters.isCheckInheritance() || parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass)) {
|
||||
if (!candidate.isInheritor(currentBase.get(), false)) {
|
||||
@@ -130,7 +131,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase<PsiClass, Cla
|
||||
final GlobalSearchScope projectScope = GlobalSearchScope.allScope(project);
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
final PsiAnchor anchor = stack.pop();
|
||||
if (!processed.add(anchor)) continue;
|
||||
|
||||
+8
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,7 +16,7 @@
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
@@ -74,6 +74,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
return AllClassesSearch.search(useScope, project).forEach(new Processor<PsiClass>() {
|
||||
@Override
|
||||
public boolean process(final PsiClass psiClass) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (psiClass.isInterface()) {
|
||||
return consumer.process(psiClass);
|
||||
}
|
||||
@@ -113,7 +114,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
Map<String, List<PsiClass>> classes = new HashMap<String, List<PsiClass>>();
|
||||
|
||||
for (final PsiReferenceList referenceList : candidates) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
ProgressManager.checkCanceled();
|
||||
final PsiClass candidate = (PsiClass)ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
|
||||
@Override
|
||||
public PsiElement compute() {
|
||||
@@ -139,6 +140,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
if (!classes.isEmpty()) {
|
||||
final VirtualFile jarFile = getJarFile(aClass);
|
||||
for (List<PsiClass> sameNamedClasses : classes.values()) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (!processSameNamedClasses(consumer, sameNamedClasses, jarFile)) return false;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +157,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
});
|
||||
|
||||
for (PsiAnonymousClass candidate : anonymousCandidates) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
ProgressManager.checkCanceled();
|
||||
if (!checkInheritance(p, aClass, candidate, project)) continue;
|
||||
|
||||
if (!consumer.process(candidate)) return false;
|
||||
@@ -176,6 +178,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
}
|
||||
});
|
||||
for (final PsiField field : fields) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (field instanceof PsiEnumConstant) {
|
||||
PsiEnumConstantInitializer initializingClass =
|
||||
ApplicationManager.getApplication().runReadAction(new Computable<PsiEnumConstantInitializer>() {
|
||||
@@ -210,6 +213,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
|
||||
if (jarFile != null && sameNamedClasses.size() > 1) {
|
||||
for (PsiClass sameNamedClass : sameNamedClasses) {
|
||||
ProgressManager.checkCanceled();
|
||||
boolean fromSameJar = Comparing.equal(getJarFile(sameNamedClass), jarFile);
|
||||
if (fromSameJar) {
|
||||
sameJarClassFound = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -119,7 +119,7 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
|
||||
});
|
||||
}
|
||||
|
||||
static <T> T resolveInReadAction(@NotNull Project p, Computable<T> computable) {
|
||||
static <T> T resolveInReadAction(@NotNull Project p, @NotNull Computable<T> computable) {
|
||||
return ApplicationManager.getApplication().isReadAccessAllowed() ? computable.compute() : DumbService.getInstance(p).runReadActionInSmartMode(computable);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user