use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class JumpToAllocationSourceAction method getStack.
@Nullable
private List<StackFrameItem> getStack(AnActionEvent e) {
final Project project = e.getProject();
final XValueNodeImpl selectedNode = getSelectedNode(e.getDataContext());
final ObjectReference ref = selectedNode != null ? getObjectReference(selectedNode) : null;
if (project == null || ref == null) {
return null;
}
final XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session != null) {
final MemoryViewDebugProcessData data = DebuggerManager.getInstance(project).getDebugProcess(session.getDebugProcess().getProcessHandler()).getUserData(MemoryViewDebugProcessData.KEY);
return data != null ? data.getTrackedStacks().getStack(ref) : null;
}
return null;
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class GenericDebuggerRunner method attachVirtualMachine.
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state, @NotNull ExecutionEnvironment env, RemoteConnection connection, long pollTimeout) throws ExecutionException {
DebugEnvironment environment = new DefaultDebugEnvironment(env, state, connection, pollTimeout);
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
if (debuggerSession == null) {
return null;
}
final DebugProcessImpl debugProcess = debuggerSession.getProcess();
return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
XDebugSessionImpl sessionImpl = (XDebugSessionImpl) session;
ExecutionResult executionResult = debugProcess.getExecutionResult();
sessionImpl.addExtraActions(executionResult.getActions());
if (executionResult instanceof DefaultExecutionResult) {
sessionImpl.addRestartActions(((DefaultExecutionResult) executionResult).getRestartActions());
}
return JavaDebugProcess.create(session, debuggerSession);
}
}).getRunContentDescriptor();
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class DebuggerTreeRenderer method getValueIcon.
public static Icon getValueIcon(ValueDescriptorImpl valueDescriptor) {
Icon nodeIcon;
if (valueDescriptor instanceof FieldDescriptorImpl) {
FieldDescriptorImpl fieldDescriptor = (FieldDescriptorImpl) valueDescriptor;
nodeIcon = PlatformIcons.FIELD_ICON;
if (fieldDescriptor.getField().isFinal()) {
nodeIcon = new LayeredIcon(nodeIcon, AllIcons.Nodes.FinalMark);
}
if (fieldDescriptor.isStatic()) {
nodeIcon = new LayeredIcon(nodeIcon, AllIcons.Nodes.StaticMark);
}
} else if (valueDescriptor instanceof ThrownExceptionValueDescriptorImpl) {
nodeIcon = AllIcons.Nodes.ExceptionClass;
} else if (valueDescriptor instanceof MethodReturnValueDescriptorImpl) {
nodeIcon = AllIcons.Debugger.WatchLastReturnValue;
} else if (isParameter(valueDescriptor)) {
nodeIcon = PlatformIcons.PARAMETER_ICON;
} else if (valueDescriptor.isEnumConstant()) {
nodeIcon = PlatformIcons.ENUM_ICON;
} else if (valueDescriptor.isArray()) {
nodeIcon = AllIcons.Debugger.Db_array;
} else if (valueDescriptor.isPrimitive()) {
nodeIcon = AllIcons.Debugger.Db_primitive;
} else if (valueDescriptor instanceof WatchItemDescriptor) {
nodeIcon = AllIcons.Debugger.Watch;
} else {
nodeIcon = AllIcons.Debugger.Value;
}
if (valueDescriptor instanceof UserExpressionDescriptorImpl) {
EnumerationChildrenRenderer enumerationChildrenRenderer = EnumerationChildrenRenderer.getCurrent(((UserExpressionDescriptorImpl) valueDescriptor).getParentDescriptor());
if (enumerationChildrenRenderer != null && enumerationChildrenRenderer.isAppendDefaultChildren()) {
nodeIcon = AllIcons.Debugger.Watch;
}
}
// if watches in variables enabled, always use watch icon
if (valueDescriptor instanceof WatchItemDescriptor && nodeIcon != AllIcons.Debugger.Watch) {
XDebugSession session = XDebuggerManager.getInstance(valueDescriptor.getProject()).getCurrentSession();
if (session != null) {
XDebugSessionTab tab = ((XDebugSessionImpl) session).getSessionTab();
if (tab != null && tab.isWatchesInVariables()) {
nodeIcon = AllIcons.Debugger.Watch;
}
}
}
final Icon valueIcon = valueDescriptor.getValueIcon();
if (nodeIcon != null && valueIcon != null) {
nodeIcon = new RowIcon(nodeIcon, valueIcon);
}
return nodeIcon;
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class XQuickEvaluateHandler method createValueHintAsync.
@NotNull
@Override
public Promise<AbstractValueHint> createValueHintAsync(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final ValueHintType type) {
final XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session == null) {
return Promise.resolve(null);
}
final XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator();
if (evaluator == null) {
return Promise.resolve(null);
}
int offset = AbstractValueHint.calculateOffset(editor, point);
return getExpressionInfo(evaluator, project, type, editor, offset).thenAsync(expressionInfo -> {
AsyncPromise<AbstractValueHint> resultPromise = new AsyncPromise<>();
UIUtil.invokeLaterIfNeeded(() -> {
int textLength = editor.getDocument().getTextLength();
if (expressionInfo == null) {
resultPromise.setResult(null);
return;
}
TextRange range = expressionInfo.getTextRange();
if (range.getStartOffset() > range.getEndOffset() || range.getStartOffset() < 0 || range.getEndOffset() > textLength) {
LOG.error("invalid range: " + range + ", text length = " + textLength + ", evaluator: " + evaluator);
resultPromise.setResult(null);
return;
}
resultPromise.setResult(new XValueHint(project, editor, point, type, expressionInfo, evaluator, session));
});
return resultPromise;
});
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class XDebuggerToggleActionHandler method setSelected.
@Override
public void setSelected(@NotNull final Project project, final AnActionEvent event, final boolean state) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
setSelected(session, event, state);
}
Aggregations