mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
when searching for methods on EDT, don't wait for smart mode (EA-67196 - assert: DumbServiceImpl.waitForSmartMode)
This commit is contained in:
+9
-8
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -60,12 +59,13 @@ public class ConstructorReferencesSearchHelper {
|
||||
final boolean[] isEnum = new boolean[1];
|
||||
final boolean[] isUnder18 = new boolean[1];
|
||||
|
||||
DumbService.getInstance(project).runReadActionInSmartMode(new Runnable() {
|
||||
MethodUsagesSearcher.resolveInReadAction(project, new Computable<Void>() {
|
||||
@Override
|
||||
public void run() {
|
||||
public Void compute() {
|
||||
constructorCanBeCalledImplicitly[0] = constructor.getParameterList().getParametersCount() == 0;
|
||||
isEnum[0] = containingClass.isEnum();
|
||||
isUnder18[0] = PsiUtil.getLanguageLevel(containingClass).isAtLeast(LanguageLevel.JDK_1_8);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -106,10 +106,11 @@ public class ConstructorReferencesSearchHelper {
|
||||
}
|
||||
|
||||
// search usages like "this(..)"
|
||||
if (!DumbService.getInstance(project).runReadActionInSmartMode(new Computable<Boolean>() {
|
||||
if (!MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return processSuperOrThis(containingClass, constructor, constructorCanBeCalledImplicitly[0], searchScope, project, isStrictSignatureSearch,
|
||||
return processSuperOrThis(containingClass, constructor, constructorCanBeCalledImplicitly[0], searchScope, project,
|
||||
isStrictSignatureSearch,
|
||||
PsiKeyword.THIS, processor);
|
||||
}
|
||||
})) {
|
||||
@@ -136,7 +137,7 @@ public class ConstructorReferencesSearchHelper {
|
||||
@NotNull final PsiMethod constructor,
|
||||
@NotNull final Project project,
|
||||
@NotNull final PsiClass aClass) {
|
||||
return DumbService.getInstance(project).runReadActionInSmartMode(new Computable<Boolean>() {
|
||||
return MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
for (PsiField field : aClass.getFields()) {
|
||||
@@ -163,7 +164,7 @@ public class ConstructorReferencesSearchHelper {
|
||||
public boolean process(PsiReference reference) {
|
||||
final PsiElement element = reference.getElement();
|
||||
if (element != null) {
|
||||
return DumbService.getInstance(project).runReadActionInSmartMode(new Computable<Boolean>() {
|
||||
return MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
final PsiElement parent = element.getParent();
|
||||
@@ -237,7 +238,7 @@ public class ConstructorReferencesSearchHelper {
|
||||
@NotNull final Project project,
|
||||
@NotNull final PsiClass containingClass) {
|
||||
if (containingClass instanceof PsiAnonymousClass) return true;
|
||||
boolean same = DumbService.getInstance(project).runReadActionInSmartMode(new Computable<Boolean>() {
|
||||
boolean same = MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return myManager.areElementsEquivalent(constructor.getContainingClass(), containingClass.getSuperClass());
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.QueryExecutorBase;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
@@ -43,7 +45,7 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
|
||||
final boolean[] needStrictSignatureSearch = new boolean[1];
|
||||
final boolean strictSignatureSearch = p.isStrictSignatureSearch();
|
||||
|
||||
final PsiClass aClass = DumbService.getInstance(p.getProject()).runReadActionInSmartMode(new Computable<PsiClass>() {
|
||||
final PsiClass aClass = resolveInReadAction(p.getProject(), new Computable<PsiClass>() {
|
||||
public PsiClass compute() {
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null) return null;
|
||||
@@ -65,7 +67,7 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
|
||||
|
||||
final SearchRequestCollector collector = p.getOptimizer();
|
||||
|
||||
final SearchScope searchScope = DumbService.getInstance(p.getProject()).runReadActionInSmartMode(new Computable<SearchScope>() {
|
||||
final SearchScope searchScope = resolveInReadAction(p.getProject(), new Computable<SearchScope>() {
|
||||
@Override
|
||||
public SearchScope compute() {
|
||||
return p.getEffectiveSearchScope();
|
||||
@@ -91,8 +93,9 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
|
||||
return;
|
||||
}
|
||||
|
||||
DumbService.getInstance(p.getProject()).runReadActionInSmartMode(new Runnable() {
|
||||
public void run() {
|
||||
resolveInReadAction(p.getProject(), new Computable<Void>() {
|
||||
@Override
|
||||
public Void compute() {
|
||||
final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(methodName[0], false);
|
||||
SearchScope accessScope = methods[0].getUseScope();
|
||||
for (int i = 1; i < methods.length; i++) {
|
||||
@@ -107,10 +110,15 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
|
||||
getTextOccurrenceProcessor(methods, aClass, strictSignatureSearch));
|
||||
|
||||
SimpleAccessorReferenceSearcher.addPropertyAccessUsages(method, restrictedByAccessScope, collector);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static <T> T resolveInReadAction(@NotNull Project p, Computable<T> computable) {
|
||||
return ApplicationManager.getApplication().isReadAccessAllowed() ? computable.compute() : DumbService.getInstance(p).runReadActionInSmartMode(computable);
|
||||
}
|
||||
|
||||
protected MethodTextOccurrenceProcessor getTextOccurrenceProcessor(PsiMethod[] methods, PsiClass aClass, boolean strictSignatureSearch) {
|
||||
return new MethodTextOccurrenceProcessor(aClass, strictSignatureSearch, methods);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user