more checkCanceled

This commit is contained in:
Alexey Kudravtsev
2015-09-21 16:32:28 +03:00
parent 3d908a24f4
commit cfc0226642
5 changed files with 21 additions and 10 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.impl;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
@@ -84,11 +85,14 @@ public class FindSuperElementsHelper {
ClassInheritorsSearch.search(containingClass, containingClass.getUseScope(), true, true, false).forEach(new Processor<PsiClass>() {
@Override
public boolean process(PsiClass inheritor) {
ProgressManager.checkCanceled();
for (PsiClassType interfaceType : inheritor.getImplementsListTypes()) {
ProgressManager.checkCanceled();
PsiClassType.ClassResolveResult resolved = interfaceType.resolveGenerics();
PsiClass anInterface = resolved.getElement();
if (anInterface == null || !checkedInterfaces.add(PsiAnchor.create(anInterface))) continue;
for (PsiMethod superMethod : anInterface.findMethodsByName(method.getName(), true)) {
ProgressManager.checkCanceled();
PsiClass superInterface = superMethod.getContainingClass();
if (superInterface == null) {
continue;
@@ -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;
@@ -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);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 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.
@@ -17,6 +17,7 @@ package com.intellij.util;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.IndexNotReadyException;
import org.jetbrains.annotations.NotNull;
@@ -40,6 +41,7 @@ public final class ExecutorsQuery<Result, Parameter> extends AbstractQuery<Resul
protected boolean processResults(@NotNull final Processor<Result> consumer) {
for (QueryExecutor<Result, Parameter> executor : myExecutors) {
try {
ProgressManager.checkCanceled();
if (!executor.execute(myParameters, consumer)) {
return false;
}