Search in sources :

Example 1 with XExpressionImpl

use of com.intellij.xdebugger.impl.breakpoints.XExpressionImpl in project intellij-community by JetBrains.

the class Breakpoint method readExternal.

public void readExternal(Element parentNode) throws InvalidDataException {
    FilteredRequestorImpl requestor = new FilteredRequestorImpl(myProject);
    requestor.readTo(parentNode, this);
    try {
        setEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "ENABLED")));
    } catch (Exception ignored) {
    }
    try {
        setLogEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_ENABLED")));
    } catch (Exception ignored) {
    }
    try {
        String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
        if (logMessage != null && !logMessage.isEmpty()) {
            XExpressionImpl expression = XExpressionImpl.fromText(logMessage);
            XDebuggerHistoryManager.getInstance(myProject).addRecentExpression(XBreakpointActionsPanel.LOG_EXPRESSION_HISTORY_ID, expression);
            myXBreakpoint.setLogExpressionObject(expression);
            ((XBreakpointBase) myXBreakpoint).setLogExpressionEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_EXPRESSION_ENABLED")));
        }
    } catch (Exception ignored) {
    }
    try {
        setRemoveAfterHit(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "REMOVE_AFTER_HIT")));
    } catch (Exception ignored) {
    }
}
Also used : XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XBreakpointBase(com.intellij.xdebugger.impl.breakpoints.XBreakpointBase) UnsupportedExpressionException(com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 2 with XExpressionImpl

use of com.intellij.xdebugger.impl.breakpoints.XExpressionImpl 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 3 with XExpressionImpl

use of com.intellij.xdebugger.impl.breakpoints.XExpressionImpl in project intellij-community by JetBrains.

the class XDebuggerEvaluateActionHandler method showDialog.

private static void showDialog(@NotNull XDebugSession session, VirtualFile file, XDebuggerEditorsProvider editorsProvider, XStackFrame stackFrame, XDebuggerEvaluator evaluator, @NotNull 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();
}
Also used : Language(com.intellij.lang.Language) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XDebuggerEvaluationDialog(com.intellij.xdebugger.impl.evaluate.XDebuggerEvaluationDialog)

Example 4 with XExpressionImpl

use of com.intellij.xdebugger.impl.breakpoints.XExpressionImpl in project intellij-community by JetBrains.

the class XDebuggerEvaluationDialog method switchToMode.

private void switchToMode(EvaluationMode mode, XExpression text) {
    if (myMode == mode)
        return;
    myMode = mode;
    if (mode == EvaluationMode.EXPRESSION) {
        text = new XExpressionImpl(StringUtil.convertLineSeparators(text.getExpression(), " "), text.getLanguage(), text.getCustomInfo());
    }
    myInputComponent = createInputComponent(mode, text);
    myMainPanel.removeAll();
    myInputComponent.addComponent(myMainPanel, myResultPanel);
    setTitle(myInputComponent.getTitle());
    mySwitchModeAction.putValue(Action.NAME, getSwitchButtonText(mode));
    getInputEditor().requestFocusInEditor();
}
Also used : XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl)

Example 5 with XExpressionImpl

use of com.intellij.xdebugger.impl.breakpoints.XExpressionImpl in project intellij-community by JetBrains.

the class XDebuggerEditorBase method createLanguagePopup.

private ListPopup createLanguagePopup() {
    DefaultActionGroup actions = new DefaultActionGroup();
    for (Language language : getSupportedLanguages()) {
        //noinspection ConstantConditions
        actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                XExpression currentExpression = getExpression();
                setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
                requestFocusInEditor();
            }
        });
    }
    DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
    return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Language(com.intellij.lang.Language) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XExpression(com.intellij.xdebugger.XExpression) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

XExpressionImpl (com.intellij.xdebugger.impl.breakpoints.XExpressionImpl)7 Language (com.intellij.lang.Language)3 XExpression (com.intellij.xdebugger.XExpression)3 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 TextWithImportsImpl (com.intellij.debugger.engine.evaluation.TextWithImportsImpl)1 UnsupportedExpressionException (com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)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 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 PsiElement (com.intellij.psi.PsiElement)1 LayeredIcon (com.intellij.ui.LayeredIcon)1 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XBreakpointBase (com.intellij.xdebugger.impl.breakpoints.XBreakpointBase)1 XDebuggerEvaluationDialog (com.intellij.xdebugger.impl.evaluate.XDebuggerEvaluationDialog)1 Set (java.util.Set)1 NotNull (org.jetbrains.annotations.NotNull)1 AsyncPromise (org.jetbrains.concurrency.AsyncPromise)1