|
24 | 24 | import com.intellij.xdebugger.impl.XDebugSessionImpl; |
25 | 25 | import com.jetbrains.lang.dart.DartFileType; |
26 | 26 | import io.flutter.bazel.WorkspaceCache; |
27 | | -import io.flutter.run.daemon.FlutterApp; |
28 | 27 | import io.flutter.sdk.FlutterSdk; |
29 | 28 | import io.flutter.sdk.FlutterSdkVersion; |
30 | 29 | import io.flutter.utils.OpenApiUtils; |
|
33 | 32 | import io.flutter.vmService.frame.DartVmServiceStackFrame; |
34 | 33 | import io.flutter.vmService.frame.DartVmServiceValue; |
35 | 34 | import org.dartlang.vm.service.VmService; |
36 | | -import org.dartlang.vm.service.consumer.*; |
37 | | -import org.dartlang.vm.service.element.*; |
| 35 | +import org.dartlang.vm.service.consumer.AddBreakpointWithScriptUriConsumer; |
| 36 | +import org.dartlang.vm.service.consumer.EvaluateConsumer; |
| 37 | +import org.dartlang.vm.service.consumer.EvaluateInFrameConsumer; |
| 38 | +import org.dartlang.vm.service.consumer.GetIsolateConsumer; |
| 39 | +import org.dartlang.vm.service.consumer.GetObjectConsumer; |
| 40 | +import org.dartlang.vm.service.consumer.GetStackConsumer; |
| 41 | +import org.dartlang.vm.service.consumer.InvokeConsumer; |
| 42 | +import org.dartlang.vm.service.consumer.PauseConsumer; |
| 43 | +import org.dartlang.vm.service.consumer.RemoveBreakpointConsumer; |
| 44 | +import org.dartlang.vm.service.consumer.SetExceptionPauseModeConsumer; |
| 45 | +import org.dartlang.vm.service.consumer.SetIsolatePauseModeConsumer; |
| 46 | +import org.dartlang.vm.service.consumer.SuccessConsumer; |
| 47 | +import org.dartlang.vm.service.consumer.UriListConsumer; |
| 48 | +import org.dartlang.vm.service.consumer.VMConsumer; |
| 49 | +import org.dartlang.vm.service.consumer.VersionConsumer; |
| 50 | +import org.dartlang.vm.service.element.Breakpoint; |
| 51 | +import org.dartlang.vm.service.element.ElementList; |
| 52 | +import org.dartlang.vm.service.element.ErrorRef; |
| 53 | +import org.dartlang.vm.service.element.Event; |
| 54 | +import org.dartlang.vm.service.element.EventKind; |
| 55 | +import org.dartlang.vm.service.element.ExceptionPauseMode; |
| 56 | +import org.dartlang.vm.service.element.Frame; |
| 57 | +import org.dartlang.vm.service.element.FrameKind; |
| 58 | +import org.dartlang.vm.service.element.InstanceRef; |
| 59 | +import org.dartlang.vm.service.element.Isolate; |
| 60 | +import org.dartlang.vm.service.element.IsolateRef; |
| 61 | +import org.dartlang.vm.service.element.LibraryRef; |
| 62 | +import org.dartlang.vm.service.element.Obj; |
| 63 | +import org.dartlang.vm.service.element.RPCError; |
| 64 | +import org.dartlang.vm.service.element.Script; |
| 65 | +import org.dartlang.vm.service.element.ScriptRef; |
| 66 | +import org.dartlang.vm.service.element.Sentinel; |
38 | 67 | import org.dartlang.vm.service.element.Stack; |
| 68 | +import org.dartlang.vm.service.element.StepOption; |
| 69 | +import org.dartlang.vm.service.element.Success; |
| 70 | +import org.dartlang.vm.service.element.UnresolvedSourceLocation; |
| 71 | +import org.dartlang.vm.service.element.UriList; |
| 72 | +import org.dartlang.vm.service.element.VM; |
39 | 73 | import org.jetbrains.annotations.NotNull; |
40 | 74 | import org.jetbrains.annotations.Nullable; |
41 | 75 |
|
42 | | -import java.util.*; |
| 76 | +import java.util.ArrayList; |
| 77 | +import java.util.Collection; |
| 78 | +import java.util.Collections; |
| 79 | +import java.util.HashMap; |
| 80 | +import java.util.HashSet; |
| 81 | +import java.util.List; |
| 82 | +import java.util.Map; |
| 83 | +import java.util.Objects; |
| 84 | +import java.util.Set; |
43 | 85 | import java.util.concurrent.CompletableFuture; |
44 | 86 | import java.util.concurrent.atomic.AtomicInteger; |
45 | 87 | import java.util.regex.Matcher; |
@@ -93,15 +135,6 @@ private void addRequest(@NotNull Runnable runnable) { |
93 | 135 | } |
94 | 136 | } |
95 | 137 |
|
96 | | - @NotNull |
97 | | - public List<IsolateRef> getExistingIsolates() { |
98 | | - List<IsolateRef> isolateRefs = new ArrayList<>(); |
99 | | - for (IsolatesInfo.IsolateInfo isolateInfo : myIsolatesInfo.getIsolateInfos()) { |
100 | | - isolateRefs.add(isolateInfo.getIsolateRef()); |
101 | | - } |
102 | | - return isolateRefs; |
103 | | - } |
104 | | - |
105 | 138 | @Nullable |
106 | 139 | public StepOption getLatestStep() { |
107 | 140 | return myLatestStep; |
@@ -145,7 +178,7 @@ public void received(final Isolate isolate) { |
145 | 178 |
|
146 | 179 | // This is the entry point for attaching a debugger to a running app. |
147 | 180 | if (eventKind == EventKind.Resume) { |
148 | | - attachIsolate(isolateRef, isolate); |
| 181 | + attachIsolate(isolateRef); |
149 | 182 | return; |
150 | 183 | } |
151 | 184 | // if event is not PauseStart it means that PauseStart event will follow later and will be handled by listener |
@@ -290,13 +323,16 @@ public void received(Success response) { |
290 | 323 | } |
291 | 324 | } |
292 | 325 |
|
293 | | - public void attachIsolate(@NotNull IsolateRef isolateRef, @NotNull Isolate isolate) { |
| 326 | + public void attachIsolate(@NotNull IsolateRef isolateRef) { |
294 | 327 | boolean newIsolate = myIsolatesInfo.addIsolate(isolateRef); |
295 | 328 | // Just to make sure that the main isolate is not handled twice, both from handleDebuggerConnected() and DartVmServiceListener.received(PauseStart) |
296 | 329 | if (newIsolate) { |
297 | | - XDebugSessionImpl session = (XDebugSessionImpl)myDebugProcess.getSession(); |
| 330 | + var session = myDebugProcess.getSession(); |
298 | 331 | OpenApiUtils.safeRunReadAction(() -> { |
299 | | - session.reset(); |
| 332 | + // Only the impl class supports reset so we need to cast. |
| 333 | + // Note that `XDebugSessionImpl` is marked internal, so this may not be safe long-run. |
| 334 | + // See: https://github.com/flutter/flutter-intellij/issues/7718 |
| 335 | + ((XDebugSessionImpl)session).reset(); |
300 | 336 | session.initBreakpoints(); |
301 | 337 | }); |
302 | 338 | setIsolatePauseMode(isolateRef.getId(), myDebugProcess.getBreakOnExceptionMode(), isolateRef); |
@@ -328,20 +364,6 @@ public void received(final Isolate isolate) { |
328 | 364 | } |
329 | 365 | } |
330 | 366 |
|
331 | | - private void setInitialBreakpointsAndCheckExtensions(@NotNull IsolateRef isolateRef, @NotNull Isolate isolate) { |
332 | | - doSetBreakpointsForIsolate(myBreakpointHandler.getXBreakpoints(), isolateRef.getId(), () -> { |
333 | | - myIsolatesInfo.setBreakpointsSet(isolateRef); |
334 | | - }); |
335 | | - FlutterApp app = FlutterApp.fromEnv(myDebugProcess.getExecutionEnvironment()); |
336 | | - // TODO(messick) Consider replacing this test with an assert; could interfere with setExceptionPauseMode(). |
337 | | - if (app != null) { |
338 | | - VMServiceManager service = app.getVMServiceManager(); |
339 | | - if (service != null) { |
340 | | - service.addRegisteredExtensionRPCs(isolate); |
341 | | - } |
342 | | - } |
343 | | - } |
344 | | - |
345 | 367 | private void doSetInitialBreakpointsAndResume(@NotNull IsolateRef isolateRef) { |
346 | 368 | doSetBreakpointsForIsolate(myBreakpointHandler.getXBreakpoints(), isolateRef.getId(), () -> { |
347 | 369 | myIsolatesInfo.setBreakpointsSet(isolateRef); |
@@ -471,8 +493,7 @@ private boolean isVmServiceMappingSupported(org.dartlang.vm.service.element.Vers |
471 | 493 | if (WorkspaceCache.getInstance(myDebugProcess.getSession().getProject()).isBazel()) { |
472 | 494 | return true; |
473 | 495 | } |
474 | | - |
475 | | - FlutterSdk sdk = FlutterSdk.getFlutterSdk(myDebugProcess.getSession().getProject()); |
| 496 | + |
476 | 497 | return VmServiceVersion.hasMapping(version); |
477 | 498 | } |
478 | 499 |
|
|
0 commit comments