Search in sources :

Example 11 with XExpression

use of com.intellij.xdebugger.XExpression in project intellij-community by JetBrains.

the class XWatchesViewImpl method updateSessionData.

public void updateSessionData() {
    List<XExpression> watchExpressions = ContainerUtil.newArrayList();
    List<? extends WatchNode> children = myRootNode.getWatchChildren();
    for (WatchNode child : children) {
        watchExpressions.add(child.getExpression());
    }
    XDebugSession session = getSession(getTree());
    XExpression[] expressions = watchExpressions.toArray(new XExpression[watchExpressions.size()]);
    if (session != null) {
        ((XDebugSessionImpl) session).setWatchExpressions(expressions);
    } else {
        XDebugSessionData data = getData(XDebugSessionData.DATA_KEY, getTree());
        if (data != null) {
            data.setWatchExpressions(expressions);
        }
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugSessionData(com.intellij.xdebugger.impl.ui.XDebugSessionData) XExpression(com.intellij.xdebugger.XExpression) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl)

Example 12 with XExpression

use of com.intellij.xdebugger.XExpression in project intellij-community by JetBrains.

the class XWatchesViewImpl method getExpressions.

@NotNull
private XExpression[] getExpressions() {
    XDebuggerTree tree = getTree();
    XDebugSession session = getSession(tree);
    XExpression[] expressions;
    if (session != null) {
        expressions = ((XDebugSessionImpl) session).getSessionData().getWatchExpressions();
    } else {
        XDebuggerTreeNode root = tree.getRoot();
        List<? extends WatchNode> current = root instanceof WatchesRootNode ? ((WatchesRootNode) tree.getRoot()).getWatchChildren() : Collections.emptyList();
        List<XExpression> list = ContainerUtil.newArrayList();
        for (WatchNode child : current) {
            list.add(child.getExpression());
        }
        expressions = list.toArray(new XExpression[list.size()]);
    }
    return expressions;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XExpression(com.intellij.xdebugger.XExpression) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with XExpression

use of com.intellij.xdebugger.XExpression in project intellij-community by JetBrains.

the class XLightBreakpointPropertiesPanel method saveProperties.

public void saveProperties() {
    mySubPanels.forEach(XBreakpointPropertiesSubPanel::saveProperties);
    if (myConditionComboBox != null) {
        XExpression expression = myConditionComboBox.getExpression();
        XExpression condition = !XDebuggerUtilImpl.isEmptyExpression(expression) ? expression : null;
        myBreakpoint.setConditionEnabled(condition == null || myConditionEnabledCheckbox.isSelected());
        myBreakpoint.setConditionExpression(condition);
        myConditionComboBox.saveTextInHistory();
    }
    for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) {
        customPanel.saveTo(myBreakpoint);
    }
    myBreakpoint.setEnabled(myEnabledCheckbox.isSelected());
}
Also used : XBreakpointCustomPropertiesPanel(com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel) XExpression(com.intellij.xdebugger.XExpression)

Example 14 with XExpression

use of com.intellij.xdebugger.XExpression in project intellij-community by JetBrains.

the class XDebuggerEvaluateActionHandler method perform.

@Override
protected void perform(@NotNull final XDebugSession session, final DataContext dataContext) {
    final XDebuggerEditorsProvider editorsProvider = session.getDebugProcess().getEditorsProvider();
    final XStackFrame stackFrame = session.getCurrentStackFrame();
    final XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator();
    if (evaluator == null) {
        return;
    }
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    EvaluationMode mode = EvaluationMode.EXPRESSION;
    String selectedText = editor != null ? editor.getSelectionModel().getSelectedText() : null;
    if (selectedText != null) {
        selectedText = evaluator.formatTextForEvaluation(selectedText);
        mode = evaluator.getEvaluationMode(selectedText, editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), CommonDataKeys.PSI_FILE.getData(dataContext));
    }
    Promise<String> expressionTextPromise = Promise.resolve(selectedText);
    if (selectedText == null && editor != null) {
        expressionTextPromise = getExpressionText(evaluator, CommonDataKeys.PROJECT.getData(dataContext), editor);
    }
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    EvaluationMode finalMode = mode;
    XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext);
    expressionTextPromise.done(expressionText -> {
        if (expressionText == null && value != null) {
            value.calculateEvaluationExpression().done(expression -> {
                if (expression != null) {
                    AppUIUtil.invokeOnEdt(() -> showDialog(session, file, editorsProvider, stackFrame, evaluator, expression));
                }
            });
        } else {
            XExpression expression = XExpressionImpl.fromText(StringUtil.notNullize(expressionText), finalMode);
            AppUIUtil.invokeOnEdt(() -> showDialog(session, file, editorsProvider, stackFrame, evaluator, expression));
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) EvaluationMode(com.intellij.xdebugger.evaluation.EvaluationMode) XExpression(com.intellij.xdebugger.XExpression) Editor(com.intellij.openapi.editor.Editor) XDebuggerEditorsProvider(com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) XValue(com.intellij.xdebugger.frame.XValue)

Example 15 with XExpression

use of com.intellij.xdebugger.XExpression in project intellij-community by JetBrains.

the class XDebuggerHistoryManager method addRecentExpression.

public boolean addRecentExpression(@NotNull @NonNls String id, @Nullable XExpression expression) {
    if (XDebuggerUtilImpl.isEmptyExpression(expression)) {
        return false;
    }
    LinkedList<XExpression> list = myRecentExpressions.computeIfAbsent(id, k -> new LinkedList<>());
    if (list.size() == MAX_RECENT_EXPRESSIONS) {
        list.removeLast();
    }
    XExpression trimmedExpression = new XExpressionImpl(expression.getExpression().trim(), expression.getLanguage(), expression.getCustomInfo(), expression.getMode());
    list.remove(trimmedExpression);
    list.addFirst(trimmedExpression);
    return true;
}
Also used : XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XExpression(com.intellij.xdebugger.XExpression)

Aggregations

XExpression (com.intellij.xdebugger.XExpression)15 NotNull (org.jetbrains.annotations.NotNull)5 XExpressionImpl (com.intellij.xdebugger.impl.breakpoints.XExpressionImpl)3 PopupStep (com.intellij.openapi.ui.popup.PopupStep)2 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)2 ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)2 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)2 XDebugSession (com.intellij.xdebugger.XDebugSession)2 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)2 XBreakpointCustomPropertiesPanel (com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel)2 XDebugSessionImpl (com.intellij.xdebugger.impl.XDebugSessionImpl)2 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 TextWithImportsImpl (com.intellij.debugger.engine.evaluation.TextWithImportsImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 Language (com.intellij.lang.Language)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Editor (com.intellij.openapi.editor.Editor)1