diff options
Diffstat (limited to 'platform/script-debugger/backend/src/org/jetbrains/rpc')
4 files changed, 20 insertions, 14 deletions
diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandCallbackWithResponseBase.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandCallbackWithResponseBase.java index a0889cfc6ce6..aad3023ad340 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandCallbackWithResponseBase.java +++ b/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandCallbackWithResponseBase.java @@ -20,8 +20,8 @@ abstract class CommandCallbackWithResponseBase<SUCCESS_RESPONSE, C extends Actio onSuccess(resultReader.<RESULT>readResult(methodName, response)); } catch (Throwable e) { - callback.reject(e.getMessage()); MessageManager.LOG.error(e); + callback.reject(e.getMessage()); } } diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java index b014cbefacf8..8df0824db5ae 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java +++ b/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java @@ -26,6 +26,11 @@ public interface CommandSender<ERROR_DETAILS> { @NotNull RequestWithResponse message, @NotNull PairConsumer<RESULT, AsyncResult<MAIN_RESULT>> consumer); + <RESULT, MAIN_RESULT> AsyncResult<MAIN_RESULT> send(@NotNull AsyncResult<MAIN_RESULT> result, + @NotNull RequestWithResponse message, + @NotNull PairConsumer<RESULT, AsyncResult<MAIN_RESULT>> consumer, + @Nullable ErrorConsumer<AsyncResult<MAIN_RESULT>, ERROR_DETAILS> errorConsumer); + <RESULT, MAIN_RESULT> AsyncResult<MAIN_RESULT> send(@NotNull RequestWithResponse message, @NotNull PairConsumer<RESULT, AsyncResult<MAIN_RESULT>> consumer); }
\ No newline at end of file diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageHandler.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageHandler.java index fb6cabb9a577..1b87843c7168 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageHandler.java +++ b/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageHandler.java @@ -2,7 +2,6 @@ package org.jetbrains.rpc; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.AsyncResult; -import com.intellij.util.BooleanFunction; import com.intellij.util.Function; import com.intellij.util.PairConsumer; import org.jetbrains.annotations.NotNull; @@ -17,10 +16,7 @@ public abstract class MessageHandler<INCOMING, INCOMING_WITH_SEQ, SUCCESS_RESPON private final AtomicInteger currentSequence = new AtomicInteger(); protected final MessageManager<Request, INCOMING, INCOMING_WITH_SEQ, SUCCESS_RESPONSE, ERROR_DETAILS> messageManager; - private final BooleanFunction<Request> out; - - protected MessageHandler(@NotNull BooleanFunction<Request> out) { - this.out = out; + protected MessageHandler() { messageManager = new MessageManager<Request, INCOMING, INCOMING_WITH_SEQ, SUCCESS_RESPONSE, ERROR_DETAILS>(this); } @@ -33,11 +29,6 @@ public abstract class MessageHandler<INCOMING, INCOMING_WITH_SEQ, SUCCESS_RESPON } @Override - public boolean write(@NotNull Request message) { - return out.fun(message); - } - - @Override public final int getUpdatedSequence(Request message) { int id = currentSequence.incrementAndGet(); message.finalize(id); @@ -83,7 +74,16 @@ public abstract class MessageHandler<INCOMING, INCOMING_WITH_SEQ, SUCCESS_RESPON public final <RESULT, TRANSFORMED_RESULT> AsyncResult<TRANSFORMED_RESULT> send(@NotNull AsyncResult<TRANSFORMED_RESULT> result, @NotNull RequestWithResponse message, @NotNull PairConsumer<RESULT, AsyncResult<TRANSFORMED_RESULT>> consumer) { - messageManager.send(message, new NestedCommandCallbackWithResponse<SUCCESS_RESPONSE, RESULT, TRANSFORMED_RESULT, ERROR_DETAILS>(result, message.getMethodName(), consumer)); + messageManager.send(message, new NestedCommandCallbackWithResponse<SUCCESS_RESPONSE, RESULT, TRANSFORMED_RESULT, ERROR_DETAILS>(result, message.getMethodName(), consumer, null)); + return result; + } + + @Override + public final <RESULT, TRANSFORMED_RESULT> AsyncResult<TRANSFORMED_RESULT> send(@NotNull AsyncResult<TRANSFORMED_RESULT> result, + @NotNull RequestWithResponse message, + @NotNull PairConsumer<RESULT, AsyncResult<TRANSFORMED_RESULT>> consumer, + @Nullable ErrorConsumer<AsyncResult<TRANSFORMED_RESULT>, ERROR_DETAILS> errorConsumer) { + messageManager.send(message, new NestedCommandCallbackWithResponse<SUCCESS_RESPONSE, RESULT, TRANSFORMED_RESULT, ERROR_DETAILS>(result, message.getMethodName(), consumer, errorConsumer)); return result; } }
\ No newline at end of file diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/NestedCommandCallbackWithResponse.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/NestedCommandCallbackWithResponse.java index ee5640ce91d9..d089bda2b0e5 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/rpc/NestedCommandCallbackWithResponse.java +++ b/platform/script-debugger/backend/src/org/jetbrains/rpc/NestedCommandCallbackWithResponse.java @@ -2,13 +2,14 @@ package org.jetbrains.rpc; import com.intellij.openapi.util.AsyncResult; import com.intellij.util.PairConsumer; +import org.jetbrains.annotations.Nullable; final class NestedCommandCallbackWithResponse<SUCCESS_RESPONSE, RESULT, MAIN_RESULT, ERROR_DETAILS> extends CommandCallbackWithResponseBase<SUCCESS_RESPONSE, AsyncResult<MAIN_RESULT>, RESULT, ERROR_DETAILS> { private final PairConsumer<RESULT, AsyncResult<MAIN_RESULT>> consumer; - public NestedCommandCallbackWithResponse(AsyncResult<MAIN_RESULT> result, String methodName, PairConsumer<RESULT, AsyncResult<MAIN_RESULT>> consumer) { - super(result, methodName, null); + public NestedCommandCallbackWithResponse(AsyncResult<MAIN_RESULT> result, String methodName, PairConsumer<RESULT, AsyncResult<MAIN_RESULT>> consumer, @Nullable ErrorConsumer<AsyncResult<MAIN_RESULT>, ERROR_DETAILS> errorConsumer) { + super(result, methodName, errorConsumer); this.consumer = consumer; } |