[java-analysis-api] Check for PCE before running visitor

The `PsiElementVisitor#visitElement` checks if the progress is cancelled, and all methods of the class are delegating its calls to it by default. The `AbstractBaseJavaLocalInspectionTool.buildVisitor` method defines a visitor that doesn't check if the progress is canceled which can cause freezes.

This patch adds calls to super methods of the visitor to implicitly check for PCE.

GitOrigin-RevId: ca718c4660f8f80adc5f9775dc6e1930a98b283f
This commit is contained in:
Nikita Eshkeev
2021-10-01 02:15:36 +03:00
committed by intellij-monorepo-bot
parent 445f6ed410
commit 357a0a4493

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection;
import com.intellij.psi.*;
@@ -49,21 +49,25 @@ public abstract class AbstractBaseJavaLocalInspectionTool extends LocalInspectio
return new JavaElementVisitor() {
@Override
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
addDescriptors(checkMethod(method, holder.getManager(), isOnTheFly));
}
@Override
public void visitClass(PsiClass aClass) {
super.visitClass(aClass);
addDescriptors(checkClass(aClass, holder.getManager(), isOnTheFly));
}
@Override
public void visitField(PsiField field) {
super.visitField(field);
addDescriptors(checkField(field, holder.getManager(), isOnTheFly));
}
@Override
public void visitFile(@NotNull PsiFile file) {
super.visitFile(file);
addDescriptors(checkFile(file, holder.getManager(), isOnTheFly));
}