interruptibility when doing "analyze from here" has to perform huge find usages and the user starts typing, to fix IDEA-191450 Idea hangs trying to investigate data flow from a project parameter of PsiBuilderImpl

This commit is contained in:
Alexey Kudravtsev
2018-05-16 17:15:22 +03:00
parent 0388974dac
commit 46f6b33e98
@@ -17,8 +17,8 @@ package com.intellij.slicer;
import com.intellij.ide.projectView.PresentationData;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.AbstractTreeUi;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -101,23 +101,20 @@ public class SliceNode extends AbstractTreeNode<SliceUsage> implements Duplicate
}
private List<SliceNode> doGetChildren() {
return AbstractTreeUi.calculateYieldingToWriteAction(() -> {
final List<SliceNode> children = new ArrayList<>();
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
Processor<SliceUsage> processor = sliceUsage -> {
progress.checkCanceled();
SliceNode node = new SliceNode(myProject, sliceUsage, targetEqualUsages);
synchronized (children) {
node.index = children.size();
children.add(node);
}
return true;
};
final List<SliceNode> children = new ArrayList<>();
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
Processor<SliceUsage> processor = sliceUsage -> {
progress.checkCanceled();
SliceNode node = new SliceNode(myProject, sliceUsage, targetEqualUsages);
synchronized (children) {
node.index = children.size();
children.add(node);
}
return true;
};
getValue().processChildren(processor);
return children;
});
ApplicationManagerEx.getApplicationEx().executeByImpatientReader(() -> getValue().processChildren(processor));
return children;
}
SliceNode getNext(List parentChildren) {