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) {
}
}
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;
}
}
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();
}
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();
}
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);
}
Aggregations