Skip to content

[CQ] limit internal XDebugSessionImpl dependence; remove dead code #8206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public void received(Isolate isolate) {
else if (eventKind == EventKind.Resume) {
// Currently true if we got here via 'flutter attach'
OpenApiUtils.safeInvokeLater(() -> {
myVmServiceWrapper.attachIsolate(isolateRef, isolate);
myVmServiceWrapper.attachIsolate(isolateRef);
});
}
}
Expand Down
36 changes: 7 additions & 29 deletions flutter-idea/src/io/flutter/vmService/VmServiceWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.jetbrains.lang.dart.DartFileType;
import io.flutter.bazel.WorkspaceCache;
import io.flutter.run.daemon.FlutterApp;
import io.flutter.sdk.FlutterSdk;
import io.flutter.sdk.FlutterSdkVersion;
import io.flutter.utils.OpenApiUtils;
Expand Down Expand Up @@ -93,15 +92,6 @@ private void addRequest(@NotNull Runnable runnable) {
}
}

@NotNull
public List<IsolateRef> getExistingIsolates() {
List<IsolateRef> isolateRefs = new ArrayList<>();
for (IsolatesInfo.IsolateInfo isolateInfo : myIsolatesInfo.getIsolateInfos()) {
isolateRefs.add(isolateInfo.getIsolateRef());
}
return isolateRefs;
}

@Nullable
public StepOption getLatestStep() {
return myLatestStep;
Expand Down Expand Up @@ -145,7 +135,7 @@ public void received(final Isolate isolate) {

// This is the entry point for attaching a debugger to a running app.
if (eventKind == EventKind.Resume) {
attachIsolate(isolateRef, isolate);
attachIsolate(isolateRef);
return;
}
// if event is not PauseStart it means that PauseStart event will follow later and will be handled by listener
Expand Down Expand Up @@ -291,13 +281,16 @@ public void received(Success response) {
}
}

public void attachIsolate(@NotNull IsolateRef isolateRef, @NotNull Isolate isolate) {
public void attachIsolate(@NotNull IsolateRef isolateRef) {
boolean newIsolate = myIsolatesInfo.addIsolate(isolateRef);
// Just to make sure that the main isolate is not handled twice, both from handleDebuggerConnected() and DartVmServiceListener.received(PauseStart)
if (newIsolate) {
XDebugSessionImpl session = (XDebugSessionImpl)myDebugProcess.getSession();
var session = myDebugProcess.getSession();
OpenApiUtils.safeRunReadAction(() -> {
session.reset();
// Only the impl class supports reset so we need to cast.
// Note that `XDebugSessionImpl` is marked internal, so this may not be safe long-run.
// See: https://github.com/flutter/flutter-intellij/issues/7718
((XDebugSessionImpl)session).reset();
session.initBreakpoints();
});
setIsolatePauseMode(isolateRef.getId(), myDebugProcess.getBreakOnExceptionMode(), isolateRef);
Expand Down Expand Up @@ -329,20 +322,6 @@ public void received(final Isolate isolate) {
}
}

private void setInitialBreakpointsAndCheckExtensions(@NotNull IsolateRef isolateRef, @NotNull Isolate isolate) {
doSetBreakpointsForIsolate(myBreakpointHandler.getXBreakpoints(), isolateRef.getId(), () -> {
myIsolatesInfo.setBreakpointsSet(isolateRef);
});
FlutterApp app = FlutterApp.fromEnv(myDebugProcess.getExecutionEnvironment());
// TODO(messick) Consider replacing this test with an assert; could interfere with setExceptionPauseMode().
if (app != null) {
VMServiceManager service = app.getVMServiceManager();
if (service != null) {
service.addRegisteredExtensionRPCs(isolate, true);
}
}
}

private void doSetInitialBreakpointsAndResume(@NotNull IsolateRef isolateRef) {
doSetBreakpointsForIsolate(myBreakpointHandler.getXBreakpoints(), isolateRef.getId(), () -> {
myIsolatesInfo.setBreakpointsSet(isolateRef);
Expand Down Expand Up @@ -474,7 +453,6 @@ private boolean isVmServiceMappingSupported(org.dartlang.vm.service.element.Vers
return true;
}

FlutterSdk sdk = FlutterSdk.getFlutterSdk(myDebugProcess.getSession().getProject());
return VmServiceVersion.hasMapping(version);
}

Expand Down