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