use of io.flutter.run.FlutterLaunchMode in project flutter-intellij by flutter.
the class DartVmServiceDebugProcessZ method onConnectSucceeded.
private void onConnectSucceeded(VmService vmService, VmOpenSourceLocationListener vmOpenSourceLocationListener) {
final DartVmServiceListener vmServiceListener = new DartVmServiceListener(this, (DartVmServiceBreakpointHandler) myBreakpointHandlers[0]);
final DartVmServiceBreakpointHandler breakpointHandler = (DartVmServiceBreakpointHandler) myBreakpointHandlers[0];
myVmOpenSourceLocationListener = vmOpenSourceLocationListener;
myVmServiceWrapper = new VmServiceWrapper(this, vmService, vmServiceListener, myIsolatesInfo, breakpointHandler);
final ScriptProvider provider = (isolateId, scriptId) -> myVmServiceWrapper.getScriptSync(isolateId, scriptId);
mapper.onConnect(provider, myConnector.getRemoteBaseUrl());
// We disable the remote debug flag so that handleDebuggerConnected() does not echo the stdout and
// stderr streams (this would duplicate what we get over daemon logging).
remoteDebug = false;
final FlutterLaunchMode launchMode = FlutterLaunchMode.getMode(executionEnvironment);
if (launchMode.supportsDebugConnection()) {
myVmServiceWrapper.handleDebuggerConnected();
}
// We re-enable the remote debug flag so that the service wrapper will call our guessRemoteProjectRoot()
// method with the list of loaded libraries for the isolate.
remoteDebug = true;
vmService.addVmServiceListener(vmServiceListener);
myVmOpenSourceLocationListener.addListener(this::onOpenSourceLocationRequest);
myVmConnected = true;
getSession().rebuildViews();
onVmConnected(vmService);
}
use of io.flutter.run.FlutterLaunchMode in project flutter-intellij by flutter.
the class DartVmServiceDebugProcess method onConnectSucceeded.
private void onConnectSucceeded(VmService vmService) {
final DartVmServiceListener vmServiceListener = new DartVmServiceListener(this, (DartVmServiceBreakpointHandler) myBreakpointHandlers[0]);
final DartVmServiceBreakpointHandler breakpointHandler = (DartVmServiceBreakpointHandler) myBreakpointHandlers[0];
myVmServiceWrapper = new VmServiceWrapper(this, vmService, vmServiceListener, myIsolatesInfo, breakpointHandler);
final ScriptProvider provider = (isolateId, scriptId) -> myVmServiceWrapper.getScriptSync(isolateId, scriptId);
mapper.onConnect(provider, myConnector.getRemoteBaseUrl());
final FlutterLaunchMode launchMode = FlutterLaunchMode.fromEnv(executionEnvironment);
if (launchMode.supportsDebugConnection()) {
myVmServiceWrapper.handleDebuggerConnected();
// TODO(jacobr): the following code is a workaround for issues
// auto-resuming isolates paused at their creation while running in
// debug mode.
// The ideal fix would by to fix VMServiceWrapper so that it checks
// for already running isolates like we do here or to refactor where we
// create our VmServiceWrapper so we can listen for isolate creation soon
// enough that we never miss an isolate creation message.
vmService.getVM(new VMConsumer() {
@Override
public void received(VM vm) {
final ElementList<IsolateRef> isolates = vm.getIsolates();
// to handleDebuggerConnected was made and so
for (IsolateRef isolateRef : isolates) {
vmService.getIsolate(isolateRef.getId(), new VmServiceConsumers.GetIsolateConsumerWrapper() {
public void received(Isolate isolate) {
final Event event = isolate.getPauseEvent();
final EventKind eventKind = event.getKind();
if (eventKind == EventKind.PauseStart) {
ApplicationManager.getApplication().invokeLater(() -> {
// We are assuming it is safe to call handleIsolate multiple times.
myVmServiceWrapper.handleIsolate(isolateRef, true);
});
} else if (eventKind == EventKind.Resume) {
// Currently true if we got here via 'flutter attach'
ApplicationManager.getApplication().invokeLater(() -> {
myVmServiceWrapper.attachIsolate(isolateRef, isolate);
});
}
}
});
}
}
@Override
public void onError(RPCError error) {
FlutterUtils.warn(LOG, error.toString());
}
});
}
vmService.addVmServiceListener(vmServiceListener);
myVmConnected = true;
getSession().rebuildViews();
onVmConnected(vmService);
}
Aggregations