|
5 | 5 | */
|
6 | 6 | package io.flutter.inspector;
|
7 | 7 |
|
| 8 | +import com.google.api.client.json.Json; |
8 | 9 | import com.google.common.base.Joiner;
|
9 | 10 | import com.google.gson.JsonArray;
|
10 | 11 | import com.google.gson.JsonElement;
|
|
29 | 30 | import com.intellij.xdebugger.XSourcePosition;
|
30 | 31 | import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
|
31 | 32 | import com.intellij.xdebugger.impl.XSourcePositionImpl;
|
| 33 | +import com.jetbrains.lang.dart.ide.toolingDaemon.DartToolingDaemonService; |
32 | 34 | import com.jetbrains.lang.dart.psi.DartCallExpression;
|
33 | 35 | import com.jetbrains.lang.dart.psi.DartExpression;
|
34 | 36 | import com.jetbrains.lang.dart.psi.DartReferenceExpression;
|
35 | 37 | import io.flutter.bazel.Workspace;
|
36 | 38 | import io.flutter.bazel.WorkspaceCache;
|
| 39 | +import io.flutter.dart.DtdUtils; |
37 | 40 | import io.flutter.pub.PubRoot;
|
38 | 41 | import io.flutter.run.FlutterDebugProcess;
|
39 | 42 | import io.flutter.run.daemon.FlutterApp;
|
| 43 | +import io.flutter.sdk.FlutterSdk; |
40 | 44 | import io.flutter.utils.JsonUtils;
|
41 | 45 | import io.flutter.utils.StreamSubscription;
|
42 | 46 | import io.flutter.utils.VmServiceListenerAdapter;
|
|
61 | 65 | import java.util.List;
|
62 | 66 | import java.util.*;
|
63 | 67 | import java.util.concurrent.CompletableFuture;
|
| 68 | +import java.util.concurrent.Executors; |
64 | 69 | import java.util.concurrent.locks.ReentrantReadWriteLock;
|
65 | 70 | import java.util.function.BiConsumer;
|
66 | 71 | import java.util.function.Supplier;
|
@@ -251,7 +256,29 @@ private InspectorService(@NotNull FlutterApp app,
|
251 | 256 |
|
252 | 257 | clients = new HashSet<>();
|
253 | 258 |
|
254 |
| - vmService.addVmServiceListener(new VmServiceListenerAdapter() { |
| 259 | + // This code hasn't been tested yet, as it requires the Dart plugin to be updated to this PR: https://github.com/JetBrains/intellij-plugins/pull/920. |
| 260 | + final FlutterSdk sdk = FlutterSdk.getFlutterSdk(app.getProject()); |
| 261 | + if (sdk != null && sdk.getVersion().canUseDtd()) { |
| 262 | + Thread t1 = new Thread(() -> { |
| 263 | + CompletableFuture<DartToolingDaemonService> future = new DtdUtils().readyDtdService(app.getProject()); |
| 264 | + future.thenApply((dtdService) -> { |
| 265 | + JsonObject capabilities = new JsonObject(); |
| 266 | + JsonArray capabilitiesList = new JsonArray(); |
| 267 | + capabilitiesList.add("file"); |
| 268 | + capabilities.add("supportedSchemes", capabilitiesList); |
| 269 | + |
| 270 | + dtdService.registerServiceMethod("Editor", "navigateToCode", capabilities, new DartToolingDaemonRequestHandler() { |
| 271 | + public DartToolingDaemonResponse handleRequest(JsonObject request) { |
| 272 | + // Extract request params |
| 273 | + // Then replicate ToolEvent actions below |
| 274 | + } |
| 275 | + }); |
| 276 | + }); |
| 277 | + }); |
| 278 | + t1.start(); |
| 279 | + } |
| 280 | + |
| 281 | + vmService.addVmServiceListener(new VmServiceListenerAdapter() { |
255 | 282 | @Override
|
256 | 283 | public void received(String streamId, Event event) {
|
257 | 284 | onVmServiceReceived(streamId, event);
|
|
0 commit comments