mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inspection tool window: do not collect task in change updater
This commit is contained in:
+50
-37
@@ -20,6 +20,7 @@ import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.concurrency.JobSchedulerImpl;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
|
||||
import com.intellij.openapi.progress.util.ReadTask;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -44,6 +45,8 @@ import java.util.Set;
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter {
|
||||
private final static int MAX_UPDATES_FOR_CANCELLABLE_ACTION = 100;
|
||||
|
||||
private final InspectionResultsView myView;
|
||||
private final MergingUpdateQueue myUpdater;
|
||||
private final BoundedTaskExecutor myExecutor;
|
||||
@@ -74,60 +77,70 @@ class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final Project project = view.getProject();
|
||||
synchronized (myView.getTreeStructureUpdateLock()) {
|
||||
InspectionTreeNode root = myView.getTree().getRoot();
|
||||
boolean[] needUpdateUI = {false};
|
||||
processNodesIfNeed(root, (node) -> {
|
||||
if (node instanceof CachedInspectionTreeNode) {
|
||||
//indicator.checkCanceled();
|
||||
RefEntity element = ((CachedInspectionTreeNode)node).getElement();
|
||||
if (element instanceof RefElement) {
|
||||
final SmartPsiElementPointer pointer = ((RefElement)element).getPointer();
|
||||
VirtualFile strictVirtualFile = pointer.getVirtualFile();
|
||||
if (strictVirtualFile == null || !strictVirtualFile.isValid()) {
|
||||
final PsiFile file = pointer.getContainingFile();
|
||||
if (file != null && file.isValid()) {
|
||||
strictVirtualFile = file.getVirtualFile();
|
||||
|
||||
final Runnable runnable = () -> {
|
||||
synchronized (myView.getTreeStructureUpdateLock()) {
|
||||
InspectionTreeNode root = myView.getTree().getRoot();
|
||||
boolean[] needUpdateUI = {false};
|
||||
processNodesIfNeed(root, (node) -> {
|
||||
if (node instanceof CachedInspectionTreeNode) {
|
||||
RefEntity element = ((CachedInspectionTreeNode)node).getElement();
|
||||
if (element instanceof RefElement) {
|
||||
final SmartPsiElementPointer pointer = ((RefElement)element).getPointer();
|
||||
VirtualFile strictVirtualFile = pointer.getVirtualFile();
|
||||
if (strictVirtualFile == null || !strictVirtualFile.isValid()) {
|
||||
final PsiFile file = pointer.getContainingFile();
|
||||
if (file != null && file.isValid()) {
|
||||
strictVirtualFile = file.getVirtualFile();
|
||||
}
|
||||
}
|
||||
if (strictVirtualFile == null || files.contains(strictVirtualFile)) {
|
||||
((CachedInspectionTreeNode)node).dropCache(project);
|
||||
if (!needUpdateUI[0]) {
|
||||
needUpdateUI[0] = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (strictVirtualFile == null || files.contains(strictVirtualFile)) {
|
||||
else {
|
||||
((CachedInspectionTreeNode)node).dropCache(project);
|
||||
if (!needUpdateUI[0]) {
|
||||
needUpdateUI[0] = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
((CachedInspectionTreeNode)node).dropCache(project);
|
||||
if (!needUpdateUI[0]) {
|
||||
needUpdateUI[0] = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (needUpdateUI[0]) {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myView.invalidate();
|
||||
myView.repaint();
|
||||
if (myView.isUpdating()) {
|
||||
myView.updateRightPanelLoading();
|
||||
} else {
|
||||
myView.syncRightPanel();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (needUpdateUI[0]) {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myView.invalidate();
|
||||
myView.repaint();
|
||||
if (myView.isUpdating()) {
|
||||
myView.updateRightPanelLoading();
|
||||
}
|
||||
else {
|
||||
myView.syncRightPanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (updates.length > MAX_UPDATES_FOR_CANCELLABLE_ACTION) {
|
||||
ProgressManager.getInstance().executeNonCancelableSection(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(@NotNull ProgressIndicator indicator) {
|
||||
if (!myView.isDisposed()) {
|
||||
ProgressIndicatorUtils.scheduleWithWriteActionPriority(myExecutor, this);
|
||||
for (Update update : updates) {
|
||||
myUpdater.queue(update);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user