Search in sources :

Example 1 with FlutterLaunchMode

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);
}
Also used : java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ObservatoryConnector(com.jetbrains.lang.dart.ide.runner.ObservatoryConnector) DartVmServiceSuspendContext(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceSuspendContext) THashSet(gnu.trove.THashSet) FlutterLaunchMode(io.flutter.run.FlutterLaunchMode) org.dartlang.vm.service.element(org.dartlang.vm.service.element) XDebuggerEditorsProvider(com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider) GetObjectConsumer(org.dartlang.vm.service.consumer.GetObjectConsumer) XDebuggerBundle(com.intellij.xdebugger.XDebuggerBundle) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) WindowListener(java.awt.event.WindowListener) ProjectUtil(com.intellij.ide.impl.ProjectUtil) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) ExecutionResult(com.intellij.execution.ExecutionResult) Logging(org.dartlang.vm.service.logging.Logging) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Logger(com.intellij.openapi.diagnostic.Logger) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugSessionListener(com.intellij.xdebugger.XDebugSessionListener) XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) DartDebuggerEditorsProvider(com.jetbrains.lang.dart.ide.runner.base.DartDebuggerEditorsProvider) Frame(java.awt.Frame) WindowManager(com.intellij.openapi.wm.WindowManager) VmService(org.dartlang.vm.service.VmService) IOException(java.io.IOException) XBreakpointHandler(com.intellij.xdebugger.breakpoints.XBreakpointHandler) FlutterBundle(io.flutter.FlutterBundle) SystemInfo(com.intellij.openapi.util.SystemInfo) WindowEvent(java.awt.event.WindowEvent) StandardCharsets(java.nio.charset.StandardCharsets) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) XSourcePosition(com.intellij.xdebugger.XSourcePosition) TimeoutUtil(com.intellij.util.TimeoutUtil) DartVmServiceStackFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame) BitUtil(com.intellij.util.BitUtil) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) FlutterLaunchMode(io.flutter.run.FlutterLaunchMode)

Example 2 with FlutterLaunchMode

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);
}
Also used : JsonObject(com.google.gson.JsonObject) Event(org.dartlang.vm.service.element.Event) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlutterInitializer(io.flutter.FlutterInitializer) THashMap(gnu.trove.THashMap) FlutterLaunchMode(io.flutter.run.FlutterLaunchMode) com.intellij.xdebugger(com.intellij.xdebugger) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) WindowListener(java.awt.event.WindowListener) Disposer(com.intellij.openapi.util.Disposer) TIntObjectHashMap(gnu.trove.TIntObjectHashMap) ExecutionResult(com.intellij.execution.ExecutionResult) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Logger(com.intellij.openapi.diagnostic.Logger) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) DartDebuggerEditorsProvider(com.jetbrains.lang.dart.ide.runner.base.DartDebuggerEditorsProvider) ObservatoryConnector(io.flutter.ObservatoryConnector) WindowManager(com.intellij.openapi.wm.WindowManager) FlutterBundle(io.flutter.FlutterBundle) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) WindowEvent(java.awt.event.WindowEvent) StandardCharsets(java.nio.charset.StandardCharsets) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) TimeoutUtil(com.intellij.util.TimeoutUtil) ApplicationManager(com.intellij.openapi.application.ApplicationManager) VMConsumer(org.dartlang.vm.service.consumer.VMConsumer) NotNull(org.jetbrains.annotations.NotNull) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) DartVmServiceEvaluator(io.flutter.vmService.frame.DartVmServiceEvaluator) java.util(java.util) DartVmServiceSuspendContext(io.flutter.vmService.frame.DartVmServiceSuspendContext) DartVmServiceStackFrame(io.flutter.vmService.frame.DartVmServiceStackFrame) CompletableFuture(java.util.concurrent.CompletableFuture) org.dartlang.vm.service.element(org.dartlang.vm.service.element) XDebuggerEditorsProvider(com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider) DartPopFrameAction(com.jetbrains.lang.dart.ide.runner.actions.DartPopFrameAction) GetObjectConsumer(org.dartlang.vm.service.consumer.GetObjectConsumer) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) ProjectUtil(com.intellij.ide.impl.ProjectUtil) Project(com.intellij.openapi.project.Project) FlutterUtils(io.flutter.FlutterUtils) Logging(org.dartlang.vm.service.logging.Logging) VmService(org.dartlang.vm.service.VmService) IOException(java.io.IOException) XBreakpointHandler(com.intellij.xdebugger.breakpoints.XBreakpointHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) java.awt(java.awt) Pair(com.intellij.openapi.util.Pair) BitUtil(com.intellij.util.BitUtil) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) javax.swing(javax.swing) FlutterLaunchMode(io.flutter.run.FlutterLaunchMode) VMConsumer(org.dartlang.vm.service.consumer.VMConsumer) Event(org.dartlang.vm.service.element.Event) WindowEvent(java.awt.event.WindowEvent)

Aggregations

ExecutionResult (com.intellij.execution.ExecutionResult)2 OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)2 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)2 ConsoleViewContentType (com.intellij.execution.ui.ConsoleViewContentType)2 ProjectUtil (com.intellij.ide.impl.ProjectUtil)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Project (com.intellij.openapi.project.Project)2 Disposer (com.intellij.openapi.util.Disposer)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 WindowManager (com.intellij.openapi.wm.WindowManager)2 BitUtil (com.intellij.util.BitUtil)2 TimeoutUtil (com.intellij.util.TimeoutUtil)2 XBreakpointHandler (com.intellij.xdebugger.breakpoints.XBreakpointHandler)2 XDebuggerEditorsProvider (com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider)2 XStackFrame (com.intellij.xdebugger.frame.XStackFrame)2 XSuspendContext (com.intellij.xdebugger.frame.XSuspendContext)2 DartDebuggerEditorsProvider (com.jetbrains.lang.dart.ide.runner.base.DartDebuggerEditorsProvider)2 DartUrlResolver (com.jetbrains.lang.dart.util.DartUrlResolver)2 FlutterBundle (io.flutter.FlutterBundle)2