IDEA-261340 allow slow operations a caller of AbstractTreeNode#canRepresent

GitOrigin-RevId: 73907b577973027065855b2e823d9be18ed48a42
This commit is contained in:
Daniil Ovchinnikov
2021-06-04 16:44:05 +00:00
committed by intellij-monorepo-bot
parent a3d1cbbdac
commit 9a38edeead
2 changed files with 5 additions and 4 deletions
@@ -12,7 +12,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.ElementPresentationUtil;
import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -172,7 +171,8 @@ public class ClassTreeNode extends BasePsiMemberNode<PsiClass> {
@Override
public boolean canRepresent(final Object element) {
return SlowOperations.allowSlowOperations(() -> canRepresentInner(element));
if (!isValid()) return false;
return super.canRepresent(element) || canRepresent(getValue(), element);
}
private boolean canRepresentInner(final Object element) {
@@ -1,8 +1,9 @@
// Copyright 2000-2018 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.ui.tree;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.SlowOperations;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -94,7 +95,7 @@ public abstract class AbstractTreeNodeVisitor<T> implements TreeVisitor {
* @return {@code true} if the specified node represents the given element
*/
protected boolean matches(@NotNull AbstractTreeNode node, @NotNull T element) {
return node.canRepresent(element);
return SlowOperations.allowSlowOperations(() -> node.canRepresent(element));
}
/**