use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class SortValuesToggleAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
XDebugSession session = XDebugSession.DATA_KEY.getData(e.getDataContext());
e.getPresentation().setEnabledAndVisible(session != null && !session.getDebugProcess().isValuesCustomSorted());
}
use of com.intellij.xdebugger.XDebugSession in project android by JetBrains.
the class InstantRunPositionManager method getPsiFileByLocation.
/**
* Returns the PSI file corresponding to the given JDI location.
* This method is overridden so that we may provide an API specific version of the sources for platform (android.jar) classes.
*
* TODO: This method is implemented as part of InstantRunPositionManager, although it has nothing to do with instant run.
* The issue is that the position manager extension API is a little odd: the position manager that was added last is the one that gets
* used, and luckily for us, the instant run position manager is being added last. Ideally, we should move just the code that identifies
* the Psi File given a location to a separate extension mechanism. See b.android.com/208140
*/
@Nullable
@Override
protected PsiFile getPsiFileByLocation(Project project, Location location) {
PsiFile file = super.getPsiFileByLocation(project, location);
if (file == null) {
return null;
}
if (!DebuggerSettings.getInstance().SHOW_ALTERNATIVE_SOURCE) {
return file;
}
// we only care about providing an alternate source for files inside the platform.
if (!AndroidFacet.isInAndroidSdk(file)) {
return file;
}
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session == null) {
return file;
}
String relPath = getRelPathFromSourceRoot(project, file);
if (relPath == null) {
return file;
}
AndroidVersion version = session.getDebugProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEVICE_API_LEVEL);
if (version == null) {
return file;
}
PsiFile source = getSourceForApiLevel(project, version, relPath);
return source == null ? file : source;
}
use of com.intellij.xdebugger.XDebugSession in project android by JetBrains.
the class AndroidJavaDebugger method hasExistingDebugSession.
private static boolean hasExistingDebugSession(@NotNull Project project, @NotNull final String debugPort, @NotNull final String runConfigName) {
Collection<RunContentDescriptor> descriptors = null;
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
Project targetProject = null;
// Scan through open project to find if this port has been opened in any session.
for (Project openProject : openProjects) {
targetProject = openProject;
// First check the titles of the run configurations.
descriptors = ExecutionHelper.findRunningConsoleByTitle(targetProject, new NotNullFunction<String, Boolean>() {
@NotNull
@Override
public Boolean fun(String title) {
return runConfigName.equals(title);
}
});
// If it can't find a matching title, check the debugger sessions.
if (descriptors.isEmpty()) {
DebuggerSession debuggerSession = findJdwpDebuggerSession(targetProject, debugPort);
if (debuggerSession != null) {
XDebugSession session = debuggerSession.getXDebugSession();
if (session != null) {
descriptors = Collections.singletonList(session.getRunContentDescriptor());
} else {
// Detach existing session.
debuggerSession.getProcess().stop(false);
}
}
}
if (!descriptors.isEmpty()) {
break;
}
}
if (descriptors != null && !descriptors.isEmpty()) {
return activateDebugSessionWindow(project, descriptors.iterator().next());
}
return false;
}
use of com.intellij.xdebugger.XDebugSession 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.XDebugSession in project intellij-plugins by JetBrains.
the class DartPopFrameAction method getStackFrame.
@Nullable
private static DartVmServiceStackFrame getStackFrame(@NotNull final AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return null;
XDebugSession session = e.getData(XDebugSession.DATA_KEY);
if (session == null) {
session = XDebuggerManager.getInstance(project).getCurrentSession();
}
if (session != null) {
XStackFrame frame = session.getCurrentStackFrame();
if (frame instanceof DartVmServiceStackFrame) {
return ((DartVmServiceStackFrame) frame);
}
}
return null;
}
Aggregations