com.intellij.xdebugger.evaluation.XDebuggerEvaluator Java Examples
The following examples show how to use
com.intellij.xdebugger.evaluation.XDebuggerEvaluator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XVariablesViewBase.java From consulo with Apache License 2.0 | 6 votes |
@Override public void selectionChanged(final SelectionEvent e) { if (!XDebuggerSettingsManager.getInstance().getDataViewSettings().isValueTooltipAutoShowOnSelection() || myEditor.getCaretModel().getCaretCount() > 1) { return; } final String text = myEditor.getDocument().getText(e.getNewRange()); if (!StringUtil.isEmpty(text) && !(text.contains("exec(") || text.contains("++") || text.contains("--") || text.contains("="))) { final XDebugSession session = getSession(getTree()); if (session == null) return; XDebuggerEvaluator evaluator = myStackFrame.getEvaluator(); if (evaluator == null) return; TextRange range = e.getNewRange(); ExpressionInfo info = new ExpressionInfo(range); int offset = range.getStartOffset(); LogicalPosition pos = myEditor.offsetToLogicalPosition(offset); Point point = myEditor.logicalPositionToXY(pos); new XValueHint(myProject, myEditor, point, ValueHintType.MOUSE_OVER_HINT, info, evaluator, session).invokeHint(); } }
Example #2
Source File: XValueHint.java From consulo with Apache License 2.0 | 6 votes |
public XValueHint(@Nonnull Project project, @Nonnull Editor editor, @Nonnull Point point, @Nonnull ValueHintType type, @Nonnull ExpressionInfo expressionInfo, @Nonnull XDebuggerEvaluator evaluator, @Nonnull XDebugSession session) { super(project, editor, point, type, expressionInfo.getTextRange()); myEvaluator = evaluator; myDebugSession = session; myExpression = XDebuggerEvaluateActionHandler.getExpressionText(expressionInfo, editor.getDocument()); myValueName = XDebuggerEvaluateActionHandler.getDisplayText(expressionInfo, editor.getDocument()); myExpressionInfo = expressionInfo; VirtualFile file; ConsoleView consoleView = ConsoleViewImpl.CONSOLE_VIEW_IN_EDITOR_VIEW.get(editor); if (consoleView instanceof LanguageConsoleView) { LanguageConsoleView console = ((LanguageConsoleView)consoleView); file = console.getHistoryViewer() == editor ? console.getVirtualFile() : null; } else { file = FileDocumentManager.getInstance().getFile(editor.getDocument()); } myExpressionPosition = file != null ? XDebuggerUtil.getInstance().createPositionByOffset(file, expressionInfo.getTextRange().getStartOffset()) : null; }
Example #3
Source File: XAddToWatchesFromEditorActionHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nullable protected static String getTextToEvaluate(DataContext dataContext, XDebugSession session) { final Editor editor = dataContext.getData(CommonDataKeys.EDITOR); if (editor == null) { return null; } String text = editor.getSelectionModel().getSelectedText(); if (text == null) { XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator(); if (evaluator != null) { text = XDebuggerEvaluateActionHandler.getExpressionText(evaluator, editor.getProject(), editor); } } return StringUtil.nullize(text, true); }
Example #4
Source File: VmServiceWrapper.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void evaluateInFrame(@NotNull final String isolateId, @NotNull final Frame vmFrame, @NotNull final String expression, @NotNull final XDebuggerEvaluator.XEvaluationCallback callback) { addRequest(() -> myVmService.evaluateInFrame(isolateId, vmFrame.getIndex(), expression, new EvaluateInFrameConsumer() { @Override public void received(InstanceRef instanceRef) { callback.evaluated(new DartVmServiceValue(myDebugProcess, isolateId, "result", instanceRef, null, null, false)); } @Override public void received(Sentinel sentinel) { callback.errorOccurred(sentinel.getValueAsString()); } @Override public void received(ErrorRef errorRef) { callback.errorOccurred(DartVmServiceEvaluator.getPresentableError(errorRef.getMessage())); } @Override public void onError(RPCError error) { callback.errorOccurred(error.getMessage()); } })); }
Example #5
Source File: VmServiceWrapper.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void evaluateInTargetContext(@NotNull final String isolateId, @NotNull final String targetId, @NotNull final String expression, @NotNull final XDebuggerEvaluator.XEvaluationCallback callback) { evaluateInTargetContext(isolateId, targetId, expression, new EvaluateConsumer() { @Override public void received(InstanceRef instanceRef) { callback.evaluated(new DartVmServiceValue(myDebugProcess, isolateId, "result", instanceRef, null, null, false)); } @Override public void received(Sentinel sentinel) { callback.errorOccurred(sentinel.getValueAsString()); } @Override public void received(ErrorRef errorRef) { callback.errorOccurred(DartVmServiceEvaluator.getPresentableError(errorRef.getMessage())); } @Override public void onError(RPCError error) { callback.errorOccurred(error.getMessage()); } }); }
Example #6
Source File: XQuickEvaluateHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static ExpressionInfo getExpressionInfo(final XDebuggerEvaluator evaluator, final Project project, final ValueHintType type, final Editor editor, final int offset) { SelectionModel selectionModel = editor.getSelectionModel(); int selectionStart = selectionModel.getSelectionStart(); int selectionEnd = selectionModel.getSelectionEnd(); if ((type == ValueHintType.MOUSE_CLICK_HINT || type == ValueHintType.MOUSE_ALT_OVER_HINT) && selectionModel.hasSelection() && selectionStart <= offset && offset <= selectionEnd) { return new ExpressionInfo(new TextRange(selectionStart, selectionEnd)); } return evaluator.getExpressionInfoAtOffset(project, editor.getDocument(), offset, type == ValueHintType.MOUSE_CLICK_HINT || type == ValueHintType.MOUSE_ALT_OVER_HINT); }
Example #7
Source File: VmServiceWrapper.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void evaluateInFrame(@NotNull final String isolateId, @NotNull final Frame vmFrame, @NotNull final String expression, @NotNull final XDebuggerEvaluator.XEvaluationCallback callback) { addRequest(() -> myVmService.evaluateInFrame(isolateId, vmFrame.getIndex(), expression, new EvaluateInFrameConsumer() { @Override public void received(InstanceRef instanceRef) { callback.evaluated(new DartVmServiceValue(myDebugProcess, isolateId, "result", instanceRef, null, null, false)); } @Override public void received(Sentinel sentinel) { callback.errorOccurred(sentinel.getValueAsString()); } @Override public void received(ErrorRef errorRef) { callback.errorOccurred(DartVmServiceEvaluator.getPresentableError(errorRef.getMessage())); } @Override public void onError(RPCError error) { callback.errorOccurred(error.getMessage()); } })); }
Example #8
Source File: VmServiceWrapper.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void evaluateInTargetContext(@NotNull final String isolateId, @NotNull final String targetId, @NotNull final String expression, @NotNull final XDebuggerEvaluator.XEvaluationCallback callback) { evaluateInTargetContext(isolateId, targetId, expression, new EvaluateConsumer() { @Override public void received(InstanceRef instanceRef) { callback.evaluated(new DartVmServiceValue(myDebugProcess, isolateId, "result", instanceRef, null, null, false)); } @Override public void received(Sentinel sentinel) { callback.errorOccurred(sentinel.getValueAsString()); } @Override public void received(ErrorRef errorRef) { callback.errorOccurred(DartVmServiceEvaluator.getPresentableError(errorRef.getMessage())); } @Override public void onError(RPCError error) { callback.errorOccurred(error.getMessage()); } }); }
Example #9
Source File: XDebuggerEvaluateActionHandler.java From consulo with Apache License 2.0 | 6 votes |
private static void showDialog(@Nonnull XDebugSession session, VirtualFile file, XDebuggerEditorsProvider editorsProvider, XStackFrame stackFrame, XDebuggerEvaluator evaluator, @Nonnull XExpression expression) { if (expression.getLanguage() == null) { Language language = null; if (stackFrame != null) { XSourcePosition position = stackFrame.getSourcePosition(); if (position != null) { language = LanguageUtil.getFileLanguage(position.getFile()); } } if (language == null && file != null) { language = LanguageUtil.getFileTypeLanguage(file.getFileType()); } expression = new XExpressionImpl(expression.getExpression(), language, expression.getCustomInfo(), expression.getMode()); } new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show(); }
Example #10
Source File: XDebuggerUtilImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static XDebuggerEvaluator getEvaluator(final XSuspendContext suspendContext) { XExecutionStack executionStack = suspendContext.getActiveExecutionStack(); if (executionStack != null) { XStackFrame stackFrame = executionStack.getTopFrame(); if (stackFrame != null) { return stackFrame.getEvaluator(); } } return null; }
Example #11
Source File: XDebuggerEvaluationDialog.java From consulo with Apache License 2.0 | 5 votes |
public void startEvaluation(@Nonnull XDebuggerEvaluator.XEvaluationCallback evaluationCallback) { final XDebuggerEditorBase inputEditor = getInputEditor(); inputEditor.saveTextInHistory(); XExpression expression = inputEditor.getExpression(); XDebuggerEvaluator evaluator = mySession.getDebugProcess().getEvaluator(); if (evaluator == null) { evaluationCallback.errorOccurred(XDebuggerBundle.message("xdebugger.evaluate.stack.frame.has.not.evaluator")); } else { evaluator.evaluate(expression, evaluationCallback, null); } }
Example #12
Source File: XQuickEvaluateHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public AbstractValueHint createValueHint(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull final Point point, final ValueHintType type) { final XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession(); if (session == null) { return null; } final XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator(); if (evaluator == null) { return null; } return PsiDocumentManager.getInstance(project).commitAndRunReadAction(new Computable<XValueHint>() { @Override public XValueHint compute() { int offset = AbstractValueHint.calculateOffset(editor, point); ExpressionInfo expressionInfo = getExpressionInfo(evaluator, project, type, editor, offset); if (expressionInfo == null) { return null; } int textLength = editor.getDocument().getTextLength(); 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); return null; } return new XValueHint(project, editor, point, type, expressionInfo, evaluator, session); } }); }
Example #13
Source File: HaxeDebugRunner.java From intellij-haxe with Apache License 2.0 | 5 votes |
public XDebuggerEvaluator getEvaluator() { return new XDebuggerEvaluator() { public void evaluate (@NotNull String expression, @NotNull XEvaluationCallback callback, XSourcePosition expressionPosition) { callback.evaluated(new Value(expression)); } }; }
Example #14
Source File: UnityScriptDebuggerProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override public void evaluate(@Nonnull DotNetStackFrameProxy stackFrameMirror, @Nonnull DotNetDebugContext context, @Nonnull String s, @Nullable PsiElement element, @Nonnull XDebuggerEvaluator.XEvaluationCallback callback, @Nullable XSourcePosition sourcePosition) { callback.errorOccurred("UnityScript evaluation is not supported"); }
Example #15
Source File: DartVmServiceListener.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private String evaluateExpression(final @NotNull String isolateId, final @Nullable Frame vmTopFrame, final @Nullable XExpression xExpression) { final String evalText = xExpression == null ? null : xExpression.getExpression(); if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null; final Ref<String> evalResult = new Ref<>(); final Semaphore semaphore = new Semaphore(); semaphore.down(); myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() { @Override public void evaluated(@NotNull final XValue result) { if (result instanceof DartVmServiceValue) { evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef())); } semaphore.up(); } @Override public void errorOccurred(@NotNull final String errorMessage) { evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage); semaphore.up(); } }); semaphore.waitFor(1000); return evalResult.get(); }
Example #16
Source File: DartVmServiceDebugProcess.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable public XDebuggerEvaluator getEvaluator() { final XStackFrame frame = getSession().getCurrentStackFrame(); if (frame != null) { return frame.getEvaluator(); } return new DartVmServiceEvaluator(this); }
Example #17
Source File: DartVmServiceListener.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private String evaluateExpression(final @NotNull String isolateId, final @Nullable Frame vmTopFrame, final @Nullable XExpression xExpression) { final String evalText = xExpression == null ? null : xExpression.getExpression(); if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null; final Ref<String> evalResult = new Ref<>(); final Semaphore semaphore = new Semaphore(); semaphore.down(); myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() { @Override public void evaluated(@NotNull final XValue result) { if (result instanceof DartVmServiceValue) { evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef())); } semaphore.up(); } @Override public void errorOccurred(@NotNull final String errorMessage) { evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage); semaphore.up(); } }); semaphore.waitFor(1000); return evalResult.get(); }
Example #18
Source File: DartVmServiceDebugProcess.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable public XDebuggerEvaluator getEvaluator() { final XStackFrame frame = getSession().getCurrentStackFrame(); if (frame != null) { return frame.getEvaluator(); } return new DartVmServiceEvaluator(this); }
Example #19
Source File: XDebuggerEvaluateActionHandler.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static String getExpressionText(@Nullable XDebuggerEvaluator evaluator, @Nullable Project project, @Nonnull Editor editor) { if (project == null || evaluator == null) { return null; } Document document = editor.getDocument(); return getExpressionText(evaluator.getExpressionInfoAtOffset(project, document, editor.getCaretModel().getOffset(), true), document); }
Example #20
Source File: WatchesRootNode.java From consulo with Apache License 2.0 | 5 votes |
/** * @deprecated Use {@link #addWatchExpression(XStackFrame, XExpression, int, boolean)} */ @Deprecated public void addWatchExpression(@Nullable XDebuggerEvaluator evaluator, @Nonnull XExpression expression, int index, boolean navigateToWatchNode) { addWatchExpression((XStackFrame)null, expression, index, navigateToWatchNode); }
Example #21
Source File: WatchNodeImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void computePresentation(@Nonnull XValueNode node, @Nonnull XValuePlace place) { if (myStackFrame != null) { if (myTree.isShowing() || ApplicationManager.getApplication().isUnitTestMode()) { XDebuggerEvaluator evaluator = myStackFrame.getEvaluator(); if (evaluator != null) { evaluator.evaluate(myExpression, new MyEvaluationCallback(node, place), myStackFrame.getSourcePosition()); } } } else { node.setPresentation(AllIcons.Debugger.Watch, EMPTY_PRESENTATION, false); } }
Example #22
Source File: MuleStackFrame.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
@Nullable @Override public XDebuggerEvaluator getEvaluator() { return new MuleScriptEvaluator(session); }
Example #23
Source File: XDebuggerTestUtil.java From consulo with Apache License 2.0 | 4 votes |
public static Pair<XValue, String> evaluate(XDebugSession session, String expression, long timeout) throws InterruptedException { XDebuggerEvaluator evaluator = session.getCurrentStackFrame().getEvaluator(); XTestEvaluationCallback callback = new XTestEvaluationCallback(); evaluator.evaluate(expression, callback, session.getCurrentPosition()); return callback.waitFor(timeout); }
Example #24
Source File: XStackFrame.java From consulo with Apache License 2.0 | 4 votes |
/** * Implement to support evaluation in debugger (conditional breakpoints, logging message on breakpoint, "Evaluate" action, watches) * @return evaluator instance */ @Nullable public XDebuggerEvaluator getEvaluator() { return null; }
Example #25
Source File: XDebugProcess.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public XDebuggerEvaluator getEvaluator() { XStackFrame frame = getSession().getCurrentStackFrame(); return frame == null ? null : frame.getEvaluator(); }
Example #26
Source File: XQueryStackFrame.java From intellij-xquery with Apache License 2.0 | 4 votes |
@Nullable @Override public XDebuggerEvaluator getEvaluator() { return new XQueryEvaluator(dbgpIde, stackDepth); }
Example #27
Source File: SkylarkStackFrame.java From intellij with Apache License 2.0 | 4 votes |
@Override public XDebuggerEvaluator getEvaluator() { return new DebuggerEvaluator(debugProcess); }
Example #28
Source File: DartVmServiceStackFrame.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Nullable @Override public XDebuggerEvaluator getEvaluator() { return new DartVmServiceEvaluatorInFrame(myDebugProcess, myIsolateId, myVmFrame); }
Example #29
Source File: DartVmServiceStackFrame.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Nullable @Override public XDebuggerEvaluator getEvaluator() { return new DartVmServiceEvaluatorInFrame(myDebugProcess, myIsolateId, myVmFrame); }
Example #30
Source File: WeaveDebugProcess.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
@Nullable @Override public XDebuggerEvaluator getEvaluator() { return new WeaveScriptEvaluator(weaveDebuggerClient); }