use of com.intellij.debugger.ui.impl.watch.WatchItemDescriptor in project intellij-community by JetBrains.
the class EditSourceAction method getSourcePosition.
private static SourcePosition getSourcePosition(DebuggerTreeNodeImpl selectedNode, DebuggerContextImpl debuggerContext) {
final DebuggerContextImpl context = debuggerContext;
if (selectedNode == null || context == null) {
return null;
}
final Project project = selectedNode.getProject();
final DebuggerSession debuggerSession = context.getDebuggerSession();
if (debuggerSession == null) {
return null;
}
NodeDescriptorImpl nodeDescriptor = selectedNode.getDescriptor();
if (nodeDescriptor instanceof WatchItemDescriptor) {
Modifier modifier = ((WatchItemDescriptor) nodeDescriptor).getModifier();
if (modifier == null) {
return null;
}
nodeDescriptor = (NodeDescriptorImpl) modifier.getInspectItem(project);
}
final NodeDescriptorImpl nodeDescriptor1 = nodeDescriptor;
return ApplicationManager.getApplication().runReadAction(new Computable<SourcePosition>() {
public SourcePosition compute() {
return SourcePositionProvider.getSourcePosition(nodeDescriptor1, project, context);
}
});
}
use of com.intellij.debugger.ui.impl.watch.WatchItemDescriptor 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);
}
}
Aggregations