summaryrefslogtreecommitdiff
path: root/platform/script-debugger/backend/src/org/jetbrains/rpc/CommandSender.java
blob: 8df0824db5ae48aa61939040bcb3f72a7cb4ebfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.jetbrains.rpc;

import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.util.Function;
import com.intellij.util.PairConsumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jsonProtocol.Request;
import org.jetbrains.jsonProtocol.RequestWithResponse;

public interface CommandSender<ERROR_DETAILS> {
  ActionCallback send(Request message);

  <RESULT, TRANSFORMED_RESULT> AsyncResult<TRANSFORMED_RESULT> send(@NotNull RequestWithResponse message, @NotNull Function<RESULT, TRANSFORMED_RESULT> transform);

  <RESULT, TRANSFORMED_RESULT> AsyncResult<TRANSFORMED_RESULT> send(@NotNull RequestWithResponse message,
                                                                    @NotNull Function<RESULT, TRANSFORMED_RESULT> transform,
                                                                    @Nullable ErrorConsumer<AsyncResult<TRANSFORMED_RESULT>, ERROR_DETAILS> errorConsumer);

  <RESULT, TRANSFORMED_RESULT> void send(@NotNull AsyncResult<TRANSFORMED_RESULT> result,
                                         @NotNull RequestWithResponse message,
                                         @NotNull Function<RESULT, TRANSFORMED_RESULT> transform);

  <RESULT, MAIN_RESULT> AsyncResult<MAIN_RESULT> send(@NotNull AsyncResult<MAIN_RESULT> result,
                                                      @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);
}