use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class ValueHint method evaluateAndShowHint.
@Override
protected void evaluateAndShowHint() {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
final DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
if (debuggerSession == null || !debuggerSession.isPaused())
return;
try {
final ExpressionEvaluator evaluator = getExpressionEvaluator(debuggerContext);
if (evaluator == null)
return;
debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public Priority getPriority() {
return Priority.HIGH;
}
@Override
public void threadAction() {
try {
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return myCurrentExpression.getText();
}
});
final TextWithImports text = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText);
final Value value = myValueToShow != null ? myValueToShow : evaluator.evaluate(evaluationContext);
final WatchItemDescriptor descriptor = new WatchItemDescriptor(getProject(), text, value);
if (!isActiveTooltipApplicable(value) || getType() == ValueHintType.MOUSE_OVER_HINT) {
if (getType() == ValueHintType.MOUSE_OVER_HINT) {
// force using default renderer for mouse over hint in order to not to call accidentally methods while rendering
// otherwise, if the hint is invoked explicitly, show it with the right "auto" renderer
descriptor.setRenderer(DebugProcessImpl.getDefaultRenderer(value));
}
descriptor.updateRepresentation(evaluationContext, new DescriptorLabelListener() {
@Override
public void labelChanged() {
if (getCurrentRange() != null) {
if (getType() != ValueHintType.MOUSE_OVER_HINT || descriptor.isValueValid()) {
final SimpleColoredText simpleColoredText = DebuggerTreeRenderer.getDescriptorText(debuggerContext, descriptor, true);
if (isActiveTooltipApplicable(value)) {
simpleColoredText.append(" (" + DebuggerBundle.message("active.tooltip.suggestion") + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
showHint(simpleColoredText, descriptor);
}
}
}
});
} else {
createAndShowTree(expressionText, descriptor);
}
} catch (EvaluateException e) {
LOG.debug(e);
}
}
});
} catch (EvaluateException e) {
LOG.debug(e);
}
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class ThreadsDebuggerTree method build.
protected void build(DebuggerContextImpl context) {
DebuggerSession session = context.getDebuggerSession();
final RefreshThreadsTreeCommand command = new RefreshThreadsTreeCommand(session);
final DebuggerSession.State state = session != null ? session.getState() : DebuggerSession.State.DISPOSED;
if (ApplicationManager.getApplication().isUnitTestMode() || state == DebuggerSession.State.PAUSED || state == DebuggerSession.State.RUNNING) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
} else {
showMessage(session != null ? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
}
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class JavaStackFrame method customizePresentation.
@Override
public void customizePresentation(@NotNull ColoredTextContainer component) {
StackFrameDescriptorImpl selectedDescriptor = null;
DebuggerSession session = myDebugProcess.getSession();
if (session != null) {
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
XStackFrame frame = xSession.getCurrentStackFrame();
if (frame instanceof JavaStackFrame) {
selectedDescriptor = ((JavaStackFrame) frame).getDescriptor();
}
}
}
FRAME_RENDERER.customizePresentation(myDescriptor, component, selectedDescriptor);
if (myInsertCapturePoint != null) {
component.setIcon(XDebuggerUIConstants.INFORMATION_MESSAGE_ICON);
}
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class DebuggerTree method buildWhenPaused.
protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) {
DebuggerSession session = context.getDebuggerSession();
if (ApplicationManager.getApplication().isUnitTestMode() || (session != null && session.getState() == DebuggerSession.State.PAUSED)) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
} else {
showMessage(session != null ? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
if (session == null || session.isStopped()) {
// save memory by clearing references on JDI objects
getNodeFactory().clearHistory();
}
}
}
use of com.intellij.debugger.impl.DebuggerSession in project android by JetBrains.
the class InstantRunManager method refreshDebugger.
private void refreshDebugger(@NotNull String packageName) {
// First we reapply the breakpoints on the new code, otherwise the breakpoints
// remain set on the old classes and will never be hit again.
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
if (!debugger.getSessions().isEmpty()) {
List<Breakpoint> breakpoints = debugger.getBreakpointManager().getBreakpoints();
for (Breakpoint breakpoint : breakpoints) {
if (breakpoint.isEnabled()) {
breakpoint.setEnabled(false);
breakpoint.setEnabled(true);
}
}
}
}
});
// Now we refresh the call-stacks and the variable panes.
DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
for (final DebuggerSession session : debugger.getSessions()) {
Client client = session.getProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEBUG_CLIENT);
if (client != null && client.isValid() && StringUtil.equals(packageName, client.getClientData().getClientDescription())) {
session.getProcess().getManagerThread().invoke(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
DebuggerContextImpl context = session.getContextManager().getContext();
SuspendContextImpl suspendContext = context.getSuspendContext();
if (suspendContext != null) {
XExecutionStack stack = suspendContext.getActiveExecutionStack();
if (stack != null) {
((JavaExecutionStack) stack).initTopFrame();
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
session.refresh(false);
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
xSession.resume();
}
}
});
}
});
}
}
}
Aggregations