Search in sources :

Example 1 with XDebuggerManager

use of com.intellij.xdebugger.XDebuggerManager in project intellij-plugins by JetBrains.

the class DartRunner method doExecuteDartDebug.

private RunContentDescriptor doExecuteDartDebug(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env, @Nullable final String dasExecutionContextId) throws RuntimeConfigurationError, ExecutionException {
    final DartSdk sdk = DartSdk.getDartSdk(env.getProject());
    // already checked
    assert (sdk != null);
    final RunProfile runConfiguration = env.getRunProfile();
    final VirtualFile contextFileOrDir;
    VirtualFile currentWorkingDirectory;
    final ExecutionResult executionResult;
    final String debuggingHost;
    final int observatoryPort;
    if (runConfiguration instanceof DartRunConfigurationBase) {
        contextFileOrDir = ((DartRunConfigurationBase) runConfiguration).getRunnerParameters().getDartFileOrDirectory();
        final String cwd = ((DartRunConfigurationBase) runConfiguration).getRunnerParameters().computeProcessWorkingDirectory(env.getProject());
        currentWorkingDirectory = LocalFileSystem.getInstance().findFileByPath((cwd));
        executionResult = state.execute(env.getExecutor(), this);
        if (executionResult == null) {
            return null;
        }
        debuggingHost = null;
        observatoryPort = ((DartCommandLineRunningState) state).getObservatoryPort();
    } else if (runConfiguration instanceof DartRemoteDebugConfiguration) {
        final String path = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getDartProjectPath();
        contextFileOrDir = LocalFileSystem.getInstance().findFileByPath(path);
        if (contextFileOrDir == null) {
            throw new RuntimeConfigurationError("Folder not found: " + FileUtil.toSystemDependentName(path));
        }
        currentWorkingDirectory = contextFileOrDir;
        executionResult = null;
        debuggingHost = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getHost();
        observatoryPort = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getPort();
    } else {
        LOG.error("Unexpected run configuration: " + runConfiguration.getClass().getName());
        return null;
    }
    FileDocumentManager.getInstance().saveAllDocuments();
    final XDebuggerManager debuggerManager = XDebuggerManager.getInstance(env.getProject());
    final XDebugSession debugSession = debuggerManager.startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
            final DartUrlResolver dartUrlResolver = getDartUrlResolver(env.getProject(), contextFileOrDir);
            return new DartVmServiceDebugProcess(session, StringUtil.notNullize(debuggingHost, "localhost"), observatoryPort, executionResult, dartUrlResolver, dasExecutionContextId, runConfiguration instanceof DartRemoteDebugConfiguration, getTimeout(), currentWorkingDirectory);
        }
    });
    return debugSession.getRunContentDescriptor();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugProcess(com.intellij.xdebugger.XDebugProcess) DartRunConfigurationBase(com.jetbrains.lang.dart.ide.runner.base.DartRunConfigurationBase) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) ExecutionResult(com.intellij.execution.ExecutionResult) RunProfile(com.intellij.execution.configurations.RunProfile) NotNull(org.jetbrains.annotations.NotNull) DartVmServiceDebugProcess(com.jetbrains.lang.dart.ide.runner.server.vmService.DartVmServiceDebugProcess) DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) DartRemoteDebugConfiguration(com.jetbrains.lang.dart.ide.runner.server.DartRemoteDebugConfiguration) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 2 with XDebuggerManager

use of com.intellij.xdebugger.XDebuggerManager in project flutter-intellij by flutter.

the class DebugTestRunner method runInDebugger.

protected RunContentDescriptor runInDebugger(@NotNull TestLaunchState launcher, @NotNull ExecutionEnvironment env) throws ExecutionException {
    // Start process and create console.
    final ExecutionResult executionResult = launcher.execute(env.getExecutor(), this);
    final ObservatoryConnector connector = new Connector(executionResult.getProcessHandler());
    // Set up source file mapping.
    final DartUrlResolver resolver = DartUrlResolver.getInstance(env.getProject(), launcher.getTestFileOrDir());
    final PositionMapper.Analyzer analyzer = PositionMapper.Analyzer.create(env.getProject(), launcher.getTestFileOrDir());
    final PositionMapper mapper = new PositionMapper(env.getProject(), launcher.getPubRoot().getRoot(), resolver, analyzer);
    // Create the debug session.
    final XDebuggerManager manager = XDebuggerManager.getInstance(env.getProject());
    final XDebugSession session = manager.startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
            return new TestDebugProcess(env, session, executionResult, resolver, connector, mapper);
        }
    });
    return session.getRunContentDescriptor();
}
Also used : ObservatoryConnector(com.jetbrains.lang.dart.ide.runner.ObservatoryConnector) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugProcess(com.intellij.xdebugger.XDebugProcess) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) ExecutionResult(com.intellij.execution.ExecutionResult) ObservatoryConnector(com.jetbrains.lang.dart.ide.runner.ObservatoryConnector) NotNull(org.jetbrains.annotations.NotNull) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) PositionMapper(io.flutter.run.PositionMapper)

Example 3 with XDebuggerManager

use of com.intellij.xdebugger.XDebuggerManager in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugProcessStateCollector method getProfilesWithActiveDebugSession.

@NotNull
@VisibleForTesting
Set<RunProfile> getProfilesWithActiveDebugSession(Project project) {
    Set<RunProfile> debuggingProfiles = new HashSet<RunProfile>();
    XDebuggerManager debugManager = XDebuggerManager.getInstance(project);
    for (XDebugSession session : debugManager.getDebugSessions()) {
        if (notStoppedAndHasRunProfile(session)) {
            debuggingProfiles.add(session.getRunProfile());
        }
    }
    return debuggingProfiles;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) RunProfile(com.intellij.execution.configurations.RunProfile) HashSet(java.util.HashSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with XDebuggerManager

use of com.intellij.xdebugger.XDebuggerManager in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugProcessStateCollectorTest method createProject.

private Project createProject(int inProgressDebugSessions, int backgroundListeningDebugsSessions, int notListeningDebugSessions) {
    XDebuggerManager debuggerManager = mock(XDebuggerManager.class);
    XDebugSession[] debugSessions = new XDebugSession[inProgressDebugSessions];
    List<RunnerAndConfigurationSettings> allRunnerSettings = new ArrayList<RunnerAndConfigurationSettings>();
    for (int i = 0; i < inProgressDebugSessions; i++) {
        XDebugSession debugSession = createInProgressDebugSettings(allRunnerSettings);
        debugSessions[i] = debugSession;
    }
    when(debuggerManager.getDebugSessions()).thenReturn(debugSessions);
    applicationContainer.unregisterComponent(XDebuggerManager.class.getName());
    registerService(XDebuggerManager.class, debuggerManager);
    for (int i = 0; i < backgroundListeningDebugsSessions; i++) {
        createBackgroundListeningDebugSettings(allRunnerSettings);
    }
    for (int i = 0; i < notListeningDebugSessions; i++) {
        createNotListeningNotActiveSettings(allRunnerSettings);
    }
    RunManager runManager = mock(RunManager.class);
    when(runManager.getAllSettings()).thenReturn(allRunnerSettings);
    applicationContainer.unregisterComponent(RunManager.class.getName());
    registerService(RunManager.class, runManager);
    return project;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ArrayList(java.util.ArrayList) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager)

Example 5 with XDebuggerManager

use of com.intellij.xdebugger.XDebuggerManager in project flutter-intellij by flutter.

the class LaunchState method createDebugSession.

@NotNull
private XDebugSession createDebugSession(@NotNull final ExecutionEnvironment env, @NotNull final FlutterApp app, @NotNull final ExecutionResult executionResult) throws ExecutionException {
    final DartUrlResolver resolver = DartUrlResolver.getInstance(env.getProject(), sourceLocation);
    final PositionMapper mapper = createPositionMapper(env, app, resolver);
    final XDebuggerManager manager = XDebuggerManager.getInstance(env.getProject());
    final XDebugSession session = manager.startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
            return new FlutterDebugProcess(app, env, session, executionResult, resolver, mapper);
        }
    });
    if (app.getMode() != RunMode.DEBUG) {
        session.setBreakpointMuted(true);
    }
    return session;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugProcess(com.intellij.xdebugger.XDebugProcess) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XDebuggerManager (com.intellij.xdebugger.XDebuggerManager)9 XDebugSession (com.intellij.xdebugger.XDebugSession)6 NotNull (org.jetbrains.annotations.NotNull)5 XDebugProcess (com.intellij.xdebugger.XDebugProcess)3 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)3 DartUrlResolver (com.jetbrains.lang.dart.util.DartUrlResolver)3 Breakpoint (com.google.api.services.clouddebugger.v2.model.Breakpoint)2 CloudLineBreakpoint (com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint)2 ExecutionResult (com.intellij.execution.ExecutionResult)2 RunProfile (com.intellij.execution.configurations.RunProfile)2 XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)2 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)2 ArrayList (java.util.ArrayList)2 StatusMessage (com.google.api.services.clouddebugger.v2.model.StatusMessage)1 SetBreakpointHandler (com.google.cloud.tools.intellij.debugger.CloudDebugProcessStateController.SetBreakpointHandler)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 RunManager (com.intellij.execution.RunManager)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 MockProjectEx (com.intellij.mock.MockProjectEx)1