Search in sources :

Example 1 with XExpression

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

the class JavaValue method calculateEvaluationExpression.

@NotNull
@Override
public Promise<XExpression> calculateEvaluationExpression() {
    if (evaluationExpression != null) {
        return Promise.resolve(evaluationExpression);
    } else {
        final AsyncPromise<XExpression> res = new AsyncPromise<>();
        myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) {

            @Override
            public Priority getPriority() {
                return Priority.HIGH;
            }

            @Override
            public void contextAction() throws Exception {
                evaluationExpression = ApplicationManager.getApplication().runReadAction(new Computable<XExpression>() {

                    @Override
                    public XExpression compute() {
                        try {
                            PsiElement psiExpression = getDescriptor().getTreeEvaluation(JavaValue.this, getDebuggerContext());
                            if (psiExpression != null) {
                                XExpression res = TextWithImportsImpl.toXExpression(new TextWithImportsImpl(psiExpression));
                                // add runtime imports if any
                                Set<String> imports = psiExpression.getUserData(DebuggerTreeNodeExpression.ADDITIONAL_IMPORTS_KEY);
                                if (imports != null && res != null) {
                                    if (res.getCustomInfo() != null) {
                                        imports.add(res.getCustomInfo());
                                    }
                                    res = new XExpressionImpl(res.getExpression(), res.getLanguage(), StringUtil.join(imports, ","), res.getMode());
                                }
                                return res;
                            }
                        } catch (EvaluateException e) {
                            LOG.info(e);
                        }
                        return null;
                    }
                });
                res.setResult(evaluationExpression);
            }
        });
        return res;
    }
}
Also used : Set(java.util.Set) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) AsyncPromise(org.jetbrains.concurrency.AsyncPromise) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) XExpression(com.intellij.xdebugger.XExpression) TextWithImportsImpl(com.intellij.debugger.engine.evaluation.TextWithImportsImpl) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with XExpression

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

the class DebuggerUtilsImpl method writeTextWithImports.

@Override
public void writeTextWithImports(Element root, String name, TextWithImports value) {
    if (value.getKind() == CodeFragmentKind.EXPRESSION) {
        JDOMExternalizerUtil.writeField(root, name, value.toExternalForm());
    } else {
        Element element = JDOMExternalizerUtil.writeOption(root, name);
        XExpression expression = TextWithImportsImpl.toXExpression(value);
        if (expression != null) {
            XmlSerializer.serializeInto(new XExpressionState(expression), element, new SkipDefaultValuesSerializationFilters());
        }
    }
}
Also used : SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element) XExpression(com.intellij.xdebugger.XExpression) XExpressionState(com.intellij.xdebugger.impl.breakpoints.XExpressionState)

Example 3 with XExpression

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

the class XBreakpointActionsPanel method saveProperties.

@Override
void saveProperties() {
    myBreakpoint.setLogMessage(myLogMessageCheckBox.isSelected());
    if (myBreakpoint instanceof XLineBreakpoint) {
        ((XLineBreakpoint) myBreakpoint).setTemporary(myTemporaryCheckBox.isSelected());
    }
    if (myLogExpressionComboBox != null) {
        XExpression expression = myLogExpressionComboBox.getExpression();
        XExpression logExpression = !XDebuggerUtilImpl.isEmptyExpression(expression) ? expression : null;
        myBreakpoint.setLogExpressionEnabled(logExpression == null || myLogExpressionCheckBox.isSelected());
        myBreakpoint.setLogExpressionObject(logExpression);
        myLogExpressionComboBox.saveTextInHistory();
    }
}
Also used : XExpression(com.intellij.xdebugger.XExpression) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 4 with XExpression

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

the class XBreakpointActionsPanel method loadProperties.

@Override
void loadProperties() {
    myLogMessageCheckBox.setSelected(myBreakpoint.isLogMessage());
    if (myBreakpoint instanceof XLineBreakpoint) {
        myTemporaryCheckBox.setSelected(((XLineBreakpoint) myBreakpoint).isTemporary());
    }
    if (myLogExpressionComboBox != null) {
        XExpression logExpression = myBreakpoint.getLogExpressionObjectInt();
        myLogExpressionComboBox.setExpression(logExpression);
        myLogExpressionCheckBox.setSelected(myBreakpoint.isLogExpressionEnabled() && logExpression != null);
    }
    onCheckboxChanged();
}
Also used : XExpression(com.intellij.xdebugger.XExpression) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 5 with XExpression

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

the class XLightBreakpointPropertiesPanel method loadProperties.

public void loadProperties() {
    mySubPanels.forEach(XBreakpointPropertiesSubPanel::loadProperties);
    if (myConditionComboBox != null) {
        XExpression condition = myBreakpoint.getConditionExpressionInt();
        myConditionComboBox.setExpression(condition);
        boolean hideCheckbox = !myShowAllOptions && condition == null;
        myConditionEnabledCheckbox.setSelected(hideCheckbox || (myBreakpoint.isConditionEnabled() && condition != null));
        myConditionEnabledPanel.removeAll();
        if (hideCheckbox) {
            JBLabel label = new JBLabel(XDebuggerBundle.message("xbreakpoints.condition.checkbox"));
            label.setBorder(JBUI.Borders.empty(0, 4));
            label.setLabelFor(myConditionComboBox.getComboBox());
            myConditionEnabledPanel.add(label);
        } else {
            myConditionEnabledPanel.add(myConditionEnabledCheckbox);
        }
        onCheckboxChanged();
    }
    for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) {
        customPanel.loadFrom(myBreakpoint);
    }
    myEnabledCheckbox.setSelected(myBreakpoint.isEnabled());
    myBreakpointNameLabel.setText(XBreakpointUtil.getShortText(myBreakpoint));
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) XBreakpointCustomPropertiesPanel(com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel) 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