mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-183950 start visiting after processing background tasks to ensure that invalidation requests
This commit is contained in:
+11
-17
@@ -248,24 +248,18 @@ class AsyncProjectViewSupport {
|
||||
}
|
||||
|
||||
void accept(List<TreeVisitor> visitors, Consumer<List<TreePath>> consumer) {
|
||||
int size = visitors == null ? 0 : visitors.size();
|
||||
if (visitors != null && !visitors.isEmpty()) {
|
||||
// start visiting on the background thread to ensure that root node is already invalidated
|
||||
myStructureTreeModel.getInvoker().invokeLater(() -> {
|
||||
if (1 == visitors.size()) {
|
||||
myAsyncTreeModel.accept(visitors.get(0)).done(path -> {
|
||||
if (path != null) consumer.consume(singletonList(path));
|
||||
});
|
||||
}
|
||||
else if (size > 1) {
|
||||
myStructureTreeModel.getInvoker().invokeLater(() -> {
|
||||
List<Promise<TreePath>> promises = visitors.stream().map(visitor -> myAsyncTreeModel.accept(visitor)).collect(toList());
|
||||
collectResults(promises, true).done(list -> {
|
||||
if (list != null && !list.isEmpty()) consumer.consume(list);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
if (1 == visitors.size()) {
|
||||
myAsyncTreeModel.accept(visitors.get(0)).done(path -> {
|
||||
if (path != null) consumer.consume(singletonList(path));
|
||||
});
|
||||
}
|
||||
else {
|
||||
List<Promise<TreePath>> promises = visitors.stream().map(visitor -> myAsyncTreeModel.accept(visitor)).collect(toList());
|
||||
collectResults(promises, true).done(list -> {
|
||||
if (list != null && !list.isEmpty()) consumer.consume(list);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -744,8 +744,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
|
||||
if (o instanceof AbstractTreeNode) ((AbstractTreeNode)o).update();
|
||||
return TreeVisitor.Action.CONTINUE;
|
||||
};
|
||||
myStructureTreeModel.getInvoker().invokeLater(() ->
|
||||
myAsyncTreeModel.accept(visitor).processed(ignore -> result.setResult(null)));
|
||||
myAsyncTreeModel.accept(visitor).processed(ignore -> result.setResult(null));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -493,8 +493,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
}
|
||||
}
|
||||
};
|
||||
myStructureTreeModel.getInvoker().invokeLaterIfNeeded(
|
||||
() -> myAsyncTreeModel.accept(visitor).thenAsync(fallback).processed(result));
|
||||
myAsyncTreeModel.accept(visitor).thenAsync(fallback).processed(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -510,8 +509,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
if (o instanceof AbstractTreeNode) ((AbstractTreeNode)o).update();
|
||||
return TreeVisitor.Action.CONTINUE;
|
||||
};
|
||||
rebuild(false).processed(ignore1 -> myStructureTreeModel.getInvoker().invokeLater(
|
||||
() -> myAsyncTreeModel.accept(visitor).processed(ignore2 -> result.setResult(null))));
|
||||
rebuild(false).processed(ignore1 -> myAsyncTreeModel.accept(visitor).processed(ignore2 -> result.setResult(null)));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,14 +260,13 @@ public final class AsyncTreeModel extends AbstractTreeModel implements Identifia
|
||||
return null;
|
||||
}
|
||||
};
|
||||
onValidThread(() -> {
|
||||
if (allowLoading) {
|
||||
promiseRootEntry().done(walker::start).rejected(walker::setError);
|
||||
}
|
||||
else {
|
||||
walker.start(tree.root);
|
||||
}
|
||||
});
|
||||
if (allowLoading) {
|
||||
// start visiting on the background thread to ensure that root node is already invalidated
|
||||
processor.background.invokeLater(() -> onValidThread(() -> promiseRootEntry().done(walker::start).rejected(walker::setError)));
|
||||
}
|
||||
else {
|
||||
onValidThread(() -> walker.start(tree.root));
|
||||
}
|
||||
return walker.promise();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user