mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
deprecate processed (use onProcessed) and rejected (use onError)
This commit is contained in:
@@ -40,7 +40,7 @@ abstract class NetService @JvmOverloads protected constructor(protected val proj
|
||||
return promise
|
||||
}
|
||||
|
||||
promise.rejected {
|
||||
promise.onError {
|
||||
processHandler.destroyProcess()
|
||||
LOG.errorIfNotMessage(it)
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ internal class OpenFileHttpService : RestService() {
|
||||
|
||||
val promise = openFile(apiRequest, context, request) ?: return null
|
||||
promise.onSuccess { sendStatus(HttpResponseStatus.OK, keepAlive, channel) }
|
||||
.rejected {
|
||||
.onError {
|
||||
if (it === NOT_FOUND) {
|
||||
// don't expose file status
|
||||
sendStatus(HttpResponseStatus.NOT_FOUND.orInSafeMode(HttpResponseStatus.OK), keepAlive, channel)
|
||||
|
||||
@@ -59,12 +59,12 @@ internal class BinaryRequestHandlerTest {
|
||||
channel.writeAndFlush(message).await(5, TimeUnit.SECONDS)
|
||||
|
||||
try {
|
||||
result.rejected { error -> TestCase.fail(error.message) }
|
||||
result.onError { error -> TestCase.fail(error.message) }
|
||||
|
||||
if (result.state == Promise.State.PENDING) {
|
||||
val semaphore = Semaphore()
|
||||
semaphore.down()
|
||||
result.processed { semaphore.up() }
|
||||
result.onProcessed { semaphore.up() }
|
||||
if (!semaphore.waitForUnsafe(5000)) {
|
||||
TestCase.fail("Time limit exceeded")
|
||||
return
|
||||
|
||||
@@ -41,12 +41,11 @@ import java.util.zip.ZipOutputStream
|
||||
|
||||
// for Rider purpose
|
||||
open class ExportSettingsAction : AnAction(), DumbAware {
|
||||
|
||||
protected open fun getExportableComponents() = getExportableComponentsMap(true, true)
|
||||
|
||||
protected open fun exportSettings(saveFile: Path, markedComponents: Set<ExportableItem>) {
|
||||
val exportFiles = markedComponents.mapTo(THashSet()) { it.file }
|
||||
exportSettings(exportFiles, saveFile.outputStream(), FileUtilRt.toSystemIndependentName(PathManager.getConfigPath()))
|
||||
val exportFiles = markedComponents.mapTo(THashSet()) { it.file }
|
||||
exportSettings(exportFiles, saveFile.outputStream(), FileUtilRt.toSystemIndependentName(PathManager.getConfigPath()))
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
@@ -82,7 +81,6 @@ open class ExportSettingsAction : AnAction(), DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
// not internal only to test
|
||||
fun exportSettings(exportFiles: Set<Path>, out: OutputStream, configPath: String) {
|
||||
ZipOutputStream(out).use {
|
||||
val writtenItemRelativePaths = THashSet<String>()
|
||||
@@ -243,7 +241,7 @@ private fun getComponentPresentableName(state: State, aClass: Class<*>, pluginDe
|
||||
if (pluginDescriptor.vendor == "JetBrains") {
|
||||
resourceBundleName = OptionsBundle.PATH_TO_BUNDLE
|
||||
}
|
||||
else {
|
||||
else {
|
||||
return trimDefaultName()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ public interface Promise<T> {
|
||||
* Execute passed handler on promise resolve.
|
||||
* @deprecated Use {@link #onSuccess(java.util.function.Consumer)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
default Promise<T> done(@NotNull Consumer<? super T> done) {
|
||||
return onSuccess(it -> done.consume(it));
|
||||
@@ -96,8 +97,9 @@ public interface Promise<T> {
|
||||
Promise<T> onError(@NotNull java.util.function.Consumer<Throwable> rejected);
|
||||
|
||||
/**
|
||||
* Execute passed handler on promise reject.
|
||||
* @deprecated Use {@link #onError(java.util.function.Consumer)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
default Promise<T> rejected(@NotNull Consumer<Throwable> rejected) {
|
||||
return onError(it -> rejected.consume(it));
|
||||
@@ -119,6 +121,7 @@ public interface Promise<T> {
|
||||
* Execute passed handler on promise resolve (result value will be passed),
|
||||
* or on promise reject (null as result value will be passed).
|
||||
*/
|
||||
@Deprecated
|
||||
default Promise<T> processed(@NotNull Consumer<? super T> action) {
|
||||
return onProcessed(it -> action.consume(it));
|
||||
}
|
||||
|
||||
@@ -607,7 +607,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
|
||||
if (source instanceof AsyncDiffElement) {
|
||||
((AsyncDiffElement)source).copyToAsync(myTarget, element.getTarget(), path)
|
||||
.rejected(error -> reportException(error == null ? null : error.getMessage()))
|
||||
.onError(error -> reportException(error == null ? null : error.getMessage()))
|
||||
.onSuccess(newElement -> {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
if (myDisposed) return;
|
||||
@@ -652,7 +652,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
|
||||
if (target instanceof AsyncDiffElement) {
|
||||
((AsyncDiffElement)target).copyToAsync(mySource, element.getSource(), path)
|
||||
.rejected(error -> reportException(error == null ? null : error.getMessage()))
|
||||
.onError(error -> reportException(error == null ? null : error.getMessage()))
|
||||
.onSuccess(newElement -> {
|
||||
if (myDisposed) return;
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
@@ -715,7 +715,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
LOG.assertTrue(source == null || target == null);
|
||||
if (source instanceof AsyncDiffElement || target instanceof AsyncDiffElement) {
|
||||
((AsyncDiffElement)(source != null ? source : target)).deleteAsync()
|
||||
.rejected(error -> reportException(error != null ? error.getMessage() : null))
|
||||
.onError(error -> reportException(error != null ? error.getMessage() : null))
|
||||
.onSuccess(result -> {
|
||||
if (!myDisposed && myElements.indexOf(element) != -1) {
|
||||
removeElement(element, true);
|
||||
|
||||
@@ -100,7 +100,7 @@ class ExecutionManagerKtImpl(project: Project) : ExecutionManagerImpl(project) {
|
||||
environment.contentToReuse = descriptor
|
||||
}
|
||||
}
|
||||
.rejected(::handleError)
|
||||
.onError(::handleError)
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
handleError(e)
|
||||
|
||||
+25
-25
@@ -24,18 +24,13 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.problems.WolfTheProblemSolver;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.ui.tree.AsyncTreeModel;
|
||||
import com.intellij.ui.tree.RestoreSelectionListener;
|
||||
import com.intellij.ui.tree.StructureTreeModel;
|
||||
import com.intellij.ui.tree.TreeCollector;
|
||||
import com.intellij.ui.tree.TreeVisitor;
|
||||
import com.intellij.ui.tree.ProjectFileChangeListener;
|
||||
import com.intellij.ui.tree.*;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.Collections;
|
||||
@@ -48,7 +43,6 @@ import static com.intellij.openapi.vfs.VirtualFileManager.VFS_CHANGES;
|
||||
class AsyncProjectViewSupport {
|
||||
private static final Logger LOG = Logger.getInstance(AsyncProjectViewSupport.class);
|
||||
private final TreeCollector<VirtualFile> myFileRoots = TreeCollector.createFileRootsCollector();
|
||||
private final ProjectFileChangeListener myChangeListener;
|
||||
private final StructureTreeModel myStructureTreeModel;
|
||||
private final AsyncTreeModel myAsyncTreeModel;
|
||||
|
||||
@@ -62,14 +56,13 @@ class AsyncProjectViewSupport {
|
||||
myStructureTreeModel.setComparator(comparator);
|
||||
myAsyncTreeModel = new AsyncTreeModel(myStructureTreeModel, true, parent);
|
||||
myAsyncTreeModel.setRootImmediately(myStructureTreeModel.getRootImmediately());
|
||||
myChangeListener = new ProjectFileChangeListener(project, (module, file) -> {
|
||||
setModel(tree, myAsyncTreeModel);
|
||||
MessageBusConnection connection = project.getMessageBus().connect(parent);
|
||||
connection.subscribe(VFS_CHANGES, new ProjectFileChangeListener(project, (module, file) -> {
|
||||
if (myFileRoots.add(file)) {
|
||||
myFileRoots.processLater(myStructureTreeModel.getInvoker(), roots -> roots.forEach(root -> updateByFile(root, true)));
|
||||
}
|
||||
});
|
||||
setModel(tree, myAsyncTreeModel);
|
||||
MessageBusConnection connection = project.getMessageBus().connect(parent);
|
||||
connection.subscribe(VFS_CHANGES, myChangeListener);
|
||||
}));
|
||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
@Override
|
||||
public void rootsChanged(ModuleRootEvent event) {
|
||||
@@ -158,19 +151,26 @@ class AsyncProjectViewSupport {
|
||||
LOG.debug("select object: ", object, " in file: ", file);
|
||||
TreeVisitor visitor = AbstractProjectViewPane.createVisitor(element, file);
|
||||
if (visitor != null) {
|
||||
expand(tree, promise -> myAsyncTreeModel.accept(visitor).processed(path -> {
|
||||
if (selectPath(tree, path) || element == null || file == null || Registry.is("async.project.view.support.extra.select.disabled")) {
|
||||
promise.setResult(null);
|
||||
}
|
||||
else {
|
||||
// try to search the specified file instead of element,
|
||||
// because Kotlin files cannot represent containing functions
|
||||
myAsyncTreeModel.accept(AbstractProjectViewPane.createVisitor(file)).processed(path2 -> {
|
||||
selectPath(tree, path2);
|
||||
promise.setResult(null);
|
||||
//noinspection CodeBlock2Expr
|
||||
expand(tree, promise -> {
|
||||
myAsyncTreeModel
|
||||
.accept(visitor)
|
||||
.onProcessed(path -> {
|
||||
if (selectPath(tree, path) || element == null || file == null || Registry.is("async.project.view.support.extra.select.disabled")) {
|
||||
promise.setResult(null);
|
||||
}
|
||||
else {
|
||||
// try to search the specified file instead of element,
|
||||
// because Kotlin files cannot represent containing functions
|
||||
myAsyncTreeModel
|
||||
.accept(AbstractProjectViewPane.createVisitor(file))
|
||||
.onProcessed(path2 -> {
|
||||
selectPath(tree, path2);
|
||||
promise.setResult(null);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
package com.intellij.ide.scopeView;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ProjectViewNode;
|
||||
import com.intellij.ide.projectView.ProjectViewNodeDecorator;
|
||||
import com.intellij.ide.projectView.TreeStructureProvider;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.projectView.*;
|
||||
import com.intellij.ide.projectView.impl.nodes.PsiFileNode;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
@@ -44,12 +40,7 @@ import com.intellij.psi.search.scope.ProblemsScope;
|
||||
import com.intellij.psi.search.scope.ProjectFilesScope;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.stripe.ErrorStripe;
|
||||
import com.intellij.ui.tree.AbstractTreeWalker;
|
||||
import com.intellij.ui.tree.BaseTreeModel;
|
||||
import com.intellij.ui.tree.ProjectFileNode;
|
||||
import com.intellij.ui.tree.ProjectFileTreeModel;
|
||||
import com.intellij.ui.tree.TreePathUtil;
|
||||
import com.intellij.ui.tree.TreeVisitor;
|
||||
import com.intellij.ui.tree.*;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.concurrency.Invoker;
|
||||
@@ -58,14 +49,11 @@ import com.intellij.util.ui.tree.TreeModelAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -73,9 +61,7 @@ import java.util.stream.Collectors;
|
||||
import static com.intellij.ide.projectView.impl.ProjectRootsUtil.findSourceFolder;
|
||||
import static com.intellij.openapi.roots.ui.configuration.SourceRootPresentation.getSourceRootIcon;
|
||||
import static com.intellij.openapi.util.io.FileUtil.getLocationRelativeToUserHome;
|
||||
import static com.intellij.openapi.vfs.VfsUtilCore.getRelativePath;
|
||||
import static com.intellij.openapi.vfs.VfsUtilCore.isAncestor;
|
||||
import static com.intellij.openapi.vfs.VfsUtilCore.VFS_SEPARATOR_CHAR;
|
||||
import static com.intellij.openapi.vfs.VfsUtilCore.*;
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
public final class ScopeViewTreeModel extends BaseTreeModel<AbstractTreeNode> implements InvokerSupplier {
|
||||
@@ -282,7 +268,7 @@ public final class ScopeViewTreeModel extends BaseTreeModel<AbstractTreeNode> im
|
||||
}
|
||||
};
|
||||
walker.start(root);
|
||||
walker.promise().processed(path -> consumer.consume(path == null ? null : path.getLastPathComponent()));
|
||||
walker.promise().onProcessed(path -> consumer.consume(path == null ? null : path.getLastPathComponent()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -509,7 +509,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
|
||||
else {
|
||||
AtomicBoolean complete = new AtomicBoolean(false);
|
||||
//noinspection TestOnlyProblems
|
||||
Promise<Void> promise = rebuildAndUpdate().processed(ignore -> complete.set(true));
|
||||
Promise<Void> promise = rebuildAndUpdate().onProcessed(ignore -> complete.set(true));
|
||||
while (!complete.get()) {
|
||||
//noinspection TestOnlyProblems
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
@@ -674,7 +674,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
|
||||
if (node != null) node.update();
|
||||
return TreeVisitor.Action.CONTINUE;
|
||||
};
|
||||
myAsyncTreeModel.accept(visitor).processed(ignore -> result.setResult(null));
|
||||
myAsyncTreeModel.accept(visitor).onProcessed(ignore -> result.setResult(null));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
window.addWindowFocusListener(windowFocusListener);
|
||||
Disposer.register(myPopup, () -> window.removeWindowFocusListener(windowFocusListener));
|
||||
|
||||
rebuildAndSelect(false, myInitialElement).processed(path -> UIUtil.invokeLaterIfNeeded(() -> {
|
||||
rebuildAndSelect(false, myInitialElement).onProcessed(path -> UIUtil.invokeLaterIfNeeded(() -> {
|
||||
TreeUtil.ensureSelection(myTree);
|
||||
myTreeHasBuilt.setDone();
|
||||
installUpdater();
|
||||
@@ -341,7 +341,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
if (!filter.equals(prefix)) {
|
||||
boolean isBackspace = prefix.length() < filter.length();
|
||||
filter = prefix;
|
||||
rebuild(true).processed(ignore -> UIUtil.invokeLaterIfNeeded(() -> {
|
||||
rebuild(true).onProcessed(ignore -> UIUtil.invokeLaterIfNeeded(() -> {
|
||||
if (isDisposed()) return;
|
||||
TreeUtil.promiseExpandAll(myTree);
|
||||
if (isBackspace && handleBackspace(filter)) {
|
||||
@@ -453,7 +453,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
if (node != null) node.update();
|
||||
return TreeVisitor.Action.CONTINUE;
|
||||
};
|
||||
rebuild(false).processed(ignore1 -> myAsyncTreeModel.accept(visitor).processed(ignore2 -> result.setResult(null)));
|
||||
rebuild(false).onProcessed(ignore1 -> myAsyncTreeModel.accept(visitor).onProcessed(ignore2 -> result.setResult(null)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
boolean actionState = TreeModelWrapper.shouldRevert(myAction) ? !state : state;
|
||||
myTreeActionsOwner.setActionIncluded(myAction, actionState);
|
||||
saveState(myAction, state);
|
||||
rebuild(false).processed(ignore -> {
|
||||
rebuild(false).onProcessed(ignore -> {
|
||||
if (mySpeedSearch.isPopupActive()) {
|
||||
mySpeedSearch.refreshSelection();
|
||||
}
|
||||
@@ -807,7 +807,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
saveState(action, state);
|
||||
}
|
||||
myTreeActionsOwner.setActionIncluded(action, isRevertedStructureFilter != state);
|
||||
rebuild(false).processed(ignore -> {
|
||||
rebuild(false).onProcessed(ignore -> {
|
||||
if (mySpeedSearch.isPopupActive()) {
|
||||
mySpeedSearch.refreshSelection();
|
||||
}
|
||||
@@ -843,7 +843,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
myStructureTreeModel.invalidate(
|
||||
() ->
|
||||
(selection == null ? myAsyncTreeModel.accept(o -> TreeVisitor.Action.CONTINUE) : select(selection))
|
||||
.rejected(ignore2 -> result.setError("rejected"))
|
||||
.onError(ignore2 -> result.setError("rejected"))
|
||||
.onSuccess(p -> UIUtil.invokeLaterIfNeeded(
|
||||
() -> {
|
||||
TreeUtil.expand(getTree(), myTreeModel instanceof StructureViewCompositeModel ? 3 : 2);
|
||||
|
||||
@@ -445,7 +445,7 @@ public class TreeState implements JDOMExternalizable {
|
||||
Promise<Void> expanding = UIUtil.getClientProperty(tree, EXPANDING);
|
||||
LOG.debug("EXPANDING: ", expanding);
|
||||
if (expanding == null) expanding = Promises.resolvedPromise();
|
||||
expanding.processed(value -> {
|
||||
expanding.onProcessed(value -> {
|
||||
AsyncPromise<Void> promise = new AsyncPromise<>();
|
||||
UIUtil.putClientProperty(tree, EXPANDING, promise);
|
||||
consumer.accept(promise);
|
||||
@@ -470,9 +470,9 @@ public class TreeState implements JDOMExternalizable {
|
||||
TreeModel model = tree.getModel();
|
||||
if (!(model instanceof TreeVisitor.Acceptor)) return false;
|
||||
|
||||
expand(tree, promise -> expand(tree).processed(expanded -> {
|
||||
expand(tree, promise -> expand(tree).onProcessed(expanded -> {
|
||||
if (isSelectionNeeded(expanded, tree, promise)) {
|
||||
select(tree).processed(selected -> {
|
||||
select(tree).onProcessed(selected -> {
|
||||
if (isSelectionNeeded(selected, tree, promise)) {
|
||||
for (TreePath path : selected) {
|
||||
tree.addSelectionPath(path);
|
||||
|
||||
@@ -806,7 +806,7 @@ public final class TreeUtil {
|
||||
* @param onDone a task to run after expanding nodes
|
||||
*/
|
||||
public static void expandAll(@NotNull JTree tree, @NotNull Runnable onDone) {
|
||||
promiseExpandAll(tree).processed(path -> onDone.run());
|
||||
promiseExpandAll(tree).onProcessed(path -> onDone.run());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -836,7 +836,7 @@ public final class TreeUtil {
|
||||
* @param onDone a task to run after expanding nodes
|
||||
*/
|
||||
public static void expand(@NotNull JTree tree, int depth, @NotNull Runnable onDone) {
|
||||
promiseExpand(tree, depth).processed(path -> onDone.run());
|
||||
promiseExpand(tree, depth).onProcessed(path -> onDone.run());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1104,7 +1104,7 @@ public final class TreeUtil {
|
||||
* @param consumer a path consumer called on done
|
||||
*/
|
||||
public static void expand(@NotNull JTree tree, @NotNull TreeVisitor visitor, @NotNull Consumer<TreePath> consumer) {
|
||||
promiseExpand(tree, visitor).processed(path -> consumer.accept(path));
|
||||
promiseExpand(tree, visitor).onProcessed(path -> consumer.accept(path));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1128,7 +1128,7 @@ public final class TreeUtil {
|
||||
* @param consumer a path consumer called on done
|
||||
*/
|
||||
public static void makeVisible(@NotNull JTree tree, @NotNull TreeVisitor visitor, @NotNull Consumer<TreePath> consumer) {
|
||||
promiseMakeVisible(tree, visitor).processed(path -> consumer.accept(path));
|
||||
promiseMakeVisible(tree, visitor).onProcessed(path -> consumer.accept(path));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1158,7 +1158,7 @@ public final class TreeUtil {
|
||||
* @param consumer a path consumer called on done
|
||||
*/
|
||||
public static void visit(@NotNull JTree tree, @NotNull TreeVisitor visitor, @NotNull Consumer<TreePath> consumer) {
|
||||
promiseVisit(tree, visitor).processed(path -> consumer.accept(path));
|
||||
promiseVisit(tree, visitor).onProcessed(path -> consumer.accept(path));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -256,7 +256,7 @@ public final class AsyncTreeModel extends AbstractTreeModel implements Identifia
|
||||
};
|
||||
if (allowLoading) {
|
||||
// start visiting on the background thread to ensure that root node is already invalidated
|
||||
processor.background.invokeLater(() -> onValidThread(() -> promiseRootEntry().onSuccess(walker::start).rejected(walker::setError)));
|
||||
processor.background.invokeLater(() -> onValidThread(() -> promiseRootEntry().onSuccess(walker::start).onError(walker::setError)));
|
||||
}
|
||||
else {
|
||||
onValidThread(() -> walker.start(tree.root));
|
||||
|
||||
@@ -137,7 +137,7 @@ public abstract class AsyncValueLoader<T> {
|
||||
|
||||
effectivePromise.onSuccess(doneHandler);
|
||||
if (isCancelOnReject()) {
|
||||
effectivePromise.rejected(throwable -> ref.compareAndSet(effectivePromise, null));
|
||||
effectivePromise.onError(throwable -> ref.compareAndSet(effectivePromise, null));
|
||||
}
|
||||
|
||||
if (effectivePromise != promise) {
|
||||
|
||||
@@ -478,12 +478,12 @@ public final class AsyncTreeModelTest {
|
||||
|
||||
private void resolve(@NotNull TreePath path, @NotNull Consumer<TreePath> consumer) {
|
||||
AsyncTreeModel model = (AsyncTreeModel)tree.getModel();
|
||||
model.resolve(path).rejected(promise::setError).onSuccess(consumer);
|
||||
model.resolve(path).onError(promise::setError).onSuccess(consumer);
|
||||
}
|
||||
|
||||
private void visit(@NotNull TreeVisitor visitor, boolean allowLoading, @NotNull Consumer<TreePath> consumer) {
|
||||
AsyncTreeModel model = (AsyncTreeModel)tree.getModel();
|
||||
model.accept(visitor, allowLoading).rejected(promise::setError).onSuccess(consumer);
|
||||
model.accept(visitor, allowLoading).onError(promise::setError).onSuccess(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ private fun promise(state: AsyncPromiseTest2.State, `when`: When): AsyncPromise<
|
||||
}
|
||||
AsyncPromiseTest2.State.ERROR -> {
|
||||
log("notify promise about error to preserve a cause")
|
||||
promise.rejected { /* add empty error handler to ensure that promise will not call LOG.error */ }
|
||||
promise.onError { /* add empty error handler to ensure that promise will not call LOG.error */ }
|
||||
promise.setError(CheckedException())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.util.ActionCallback
|
||||
import com.intellij.util.Consumer
|
||||
import com.intellij.util.Function
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.ThreeState
|
||||
import com.intellij.util.concurrency.AppExecutorUtil
|
||||
import org.jetbrains.concurrency.InternalPromiseUtil.MessageError
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
val Promise<*>.isRejected: Boolean
|
||||
get() = state == Promise.State.REJECTED
|
||||
@@ -62,7 +62,7 @@ abstract class ValueNodeAsyncFunction<PARAM, RESULT>(private val node: Obsolesce
|
||||
override fun isObsolete() = node.isObsolete
|
||||
}
|
||||
|
||||
abstract class ObsolescentConsumer<T>(private val obsolescent: Obsolescent) : Obsolescent, java.util.function.Consumer<T> {
|
||||
abstract class ObsolescentConsumer<T>(private val obsolescent: Obsolescent) : Obsolescent, Consumer<T> {
|
||||
override fun isObsolete() = obsolescent.isObsolete
|
||||
}
|
||||
|
||||
@@ -213,12 +213,12 @@ fun <T: Any?> all(promises: Collection<Promise<*>>, totalResult: T, ignoreErrors
|
||||
|
||||
for (promise in promises) {
|
||||
promise.onSuccess(done)
|
||||
promise.rejected(rejected)
|
||||
promise.onError(rejected)
|
||||
}
|
||||
return totalPromise
|
||||
}
|
||||
|
||||
private class CountDownConsumer<T : Any?>(@Volatile private var countDown: Int, private val promise: AsyncPromise<T>, private val totalResult: T) : java.util.function.Consumer<Any?> {
|
||||
private class CountDownConsumer<T : Any?>(@Volatile private var countDown: Int, private val promise: AsyncPromise<T>, private val totalResult: T) : Consumer<Any?> {
|
||||
override fun accept(t: Any?) {
|
||||
if (--countDown == 0) {
|
||||
promise.setResult(totalResult)
|
||||
@@ -235,8 +235,8 @@ fun <T> any(promises: Collection<Promise<T>>, totalError: String): Promise<T> {
|
||||
}
|
||||
|
||||
val totalPromise = AsyncPromise<T>()
|
||||
val done = java.util.function.Consumer<T> { result -> totalPromise.setResult(result) }
|
||||
val rejected = object : java.util.function.Consumer<Throwable> {
|
||||
val done = Consumer<T> { result -> totalPromise.setResult(result) }
|
||||
val rejected = object : Consumer<Throwable> {
|
||||
@Volatile private var toConsume = promises.size
|
||||
|
||||
override fun accept(throwable: Throwable) {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package org.jetbrains.debugger
|
||||
|
||||
import com.intellij.concurrency.ConcurrentCollectionFactory
|
||||
@@ -70,7 +56,7 @@ abstract class BreakpointManagerBase<T : BreakpointBase<*>> : BreakpointManager
|
||||
|
||||
breakpoints.add(breakpoint)
|
||||
val promise = doSetBreakpoint(target, url, breakpoint)
|
||||
.rejected { dispatcher.multicaster.errorOccurred(breakpoint, it.message ?: it.toString()) }
|
||||
.onError { dispatcher.multicaster.errorOccurred(breakpoint, it.message ?: it.toString()) }
|
||||
return BreakpointManager.BreakpointCreated(breakpoint, promise)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package org.jetbrains.debugger
|
||||
|
||||
import com.intellij.util.io.addChannelListener
|
||||
@@ -59,7 +45,7 @@ open class StandaloneVmHelper(private val vm: Vm, private val messageProcessor:
|
||||
}
|
||||
else {
|
||||
messageProcessor.send(disconnectRequest)
|
||||
.rejected {
|
||||
.onError {
|
||||
if (it.message != CONNECTION_CLOSED_MESSAGE) {
|
||||
LOG.errorIfNotMessage(it)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ internal class FunctionScopesValueGroup(private val functionValue: FunctionValue
|
||||
createAndAddScopeList(node, Arrays.asList(*scopes), variableContext, null)
|
||||
}
|
||||
}
|
||||
.rejected {
|
||||
.onError {
|
||||
LOG.errorIfNotMessage(it)
|
||||
node.setErrorMessage(it.message!!)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package org.jetbrains.debugger
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
@@ -56,7 +42,7 @@ abstract class LineBreakpointManager(internal val debugProcess: DebugProcessImpl
|
||||
if (!vmBreakpoint.enabled) {
|
||||
vmBreakpoint.enabled = true
|
||||
breakpointManager.flush(vmBreakpoint)
|
||||
.rejected { debugProcess.session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, it.message) }
|
||||
.onError { debugProcess.session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, it.message) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ class ProcessHandlerWrapper(private val debugProcess: XDebugProcess, private val
|
||||
}
|
||||
|
||||
debugProcess.stopAsync()
|
||||
.done { stopProcess(destroy) }
|
||||
.rejected {
|
||||
.onSuccess() { stopProcess(destroy) }
|
||||
.onError {
|
||||
try {
|
||||
LOG.error(it)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ abstract class RemoteVmConnection : VmConnection<Vm>() {
|
||||
.onSuccess {
|
||||
connectionSucceeded(it, address)
|
||||
}
|
||||
.rejected {
|
||||
.onError {
|
||||
if (it !is ConnectException) {
|
||||
LOG.errorIfNotMessage(it)
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ class VariableView(override val variableName: String, private val variable: Vari
|
||||
value = null
|
||||
callback.valueModified()
|
||||
}
|
||||
.rejected { callback.errorOccurred(it.message!!) }
|
||||
.onError { callback.errorOccurred(it.message!!) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user