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();
}
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();
}
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;
}
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;
}
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;
}
Aggregations