com.intellij.xdebugger.XExpression Java Examples
The following examples show how to use
com.intellij.xdebugger.XExpression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WatchesRootNode.java From consulo with Apache License 2.0 | 6 votes |
public WatchesRootNode(@Nonnull XDebuggerTree tree, @Nonnull XWatchesView watchesView, @Nonnull XExpression[] expressions, @Nullable XStackFrame stackFrame, boolean watchesInVariables) { super(tree, null, new XValueContainer() { @Override public void computeChildren(@Nonnull XCompositeNode node) { if (stackFrame != null && watchesInVariables) { stackFrame.computeChildren(node); } else { node.addChildren(XValueChildrenList.EMPTY, true); } } }); setLeaf(false); myWatchesView = watchesView; myChildren = ContainerUtil.newArrayList(); for (XExpression watchExpression : expressions) { myChildren.add(new WatchNodeImpl(myTree, this, watchExpression, stackFrame)); } }
Example #2
Source File: XDebuggerHistoryManager.java From consulo with Apache License 2.0 | 6 votes |
public boolean addRecentExpression(@Nonnull @NonNls String id, @Nullable XExpression expression) { if (expression == null || StringUtil.isEmptyOrSpaces(expression.getExpression())) { return false; } LinkedList<XExpression> list = myRecentExpressions.get(id); if (list == null) { list = new LinkedList<XExpression>(); myRecentExpressions.put(id, list); } if (list.size() == MAX_RECENT_EXPRESSIONS) { list.removeLast(); } XExpression trimmedExpression = new XExpressionImpl(expression.getExpression().trim(), expression.getLanguage(), expression.getCustomInfo()); list.remove(trimmedExpression); list.addFirst(trimmedExpression); return true; }
Example #3
Source File: XDebuggerEditorBase.java From consulo with Apache License 2.0 | 6 votes |
private ListPopup createLanguagePopup() { DefaultActionGroup actions = new DefaultActionGroup(); for (Language language : getSupportedLanguages()) { //noinspection ConstantConditions actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) { @RequiredUIAccess @Override public void actionPerformed(@Nonnull 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); }
Example #4
Source File: XWatchesViewImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull 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; }
Example #5
Source File: CodeFragmentInputComponent.java From consulo with Apache License 2.0 | 6 votes |
public CodeFragmentInputComponent(final @Nonnull Project project, @Nonnull XDebuggerEditorsProvider editorsProvider, final @Nullable XSourcePosition sourcePosition, @Nullable XExpression statements, String splitterProportionKey, Disposable parentDisposable) { super(XDebuggerBundle.message("dialog.title.evaluate.code.fragment")); myMultilineEditor = new XDebuggerExpressionEditor(project, editorsProvider, "evaluateCodeFragment", sourcePosition, statements != null ? statements : XExpressionImpl.EMPTY_CODE_FRAGMENT, true, true, false); myMainPanel = new JPanel(new BorderLayout()); JPanel editorPanel = new JPanel(new BorderLayout()); editorPanel.add(myMultilineEditor.getComponent(), BorderLayout.CENTER); DefaultActionGroup group = new DefaultActionGroup(); group.add(new HistoryNavigationAction(false, IdeActions.ACTION_PREVIOUS_OCCURENCE, parentDisposable)); group.add(new HistoryNavigationAction(true, IdeActions.ACTION_NEXT_OCCURENCE, parentDisposable)); editorPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false).getComponent(), BorderLayout.EAST); //myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.label.text.code.fragment")), BorderLayout.NORTH); myMainPanel.add(editorPanel, BorderLayout.CENTER); if (statements != null) { myMultilineEditor.setExpression(statements); } mySplitterProportionKey = splitterProportionKey; }
Example #6
Source File: XCopyWatchAction.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void perform(@Nonnull AnActionEvent e, @Nonnull XDebuggerTree tree, @Nonnull final XWatchesView watchesView) { final XDebuggerTreeNode root = tree.getRoot(); for (final XValueNodeImpl node : getSelectedNodes(tree, XValueNodeImpl.class)) { node.getValueContainer().calculateEvaluationExpression().doWhenDone(new Consumer<XExpression>() { @Override public void accept(XExpression expr) { final XExpression watchExpression = expr != null ? expr : XExpressionImpl.fromText(node.getName()); if (watchExpression != null) { DebuggerUIUtil.invokeLater(new Runnable() { @Override public void run() { watchesView.addWatchExpression(watchExpression, node instanceof WatchNode ? root.getIndex(node) + 1 : -1, true); } }); } } }); } }
Example #7
Source File: ExpressionInputComponent.java From consulo with Apache License 2.0 | 6 votes |
private void showHistory() { List<XExpression> expressions = myExpressionEditor.getRecentExpressions(); if (!expressions.isEmpty()) { ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) { @Override public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) { myExpressionEditor.setExpression(selectedValue); myExpressionEditor.requestFocusInEditor(); return FINAL_CHOICE; } }) { @Override protected ListCellRenderer getListElementRenderer() { return new ColoredListCellRenderer<XExpression>() { @Override protected void customizeCellRenderer(@Nonnull JList list, XExpression value, int index, boolean selected, boolean hasFocus) { append(value.getExpression()); } }; } }; popup.getList().setFont(EditorUtil.getEditorFont()); popup.showUnderneathOf(myExpressionEditor.getEditorComponent()); } }
Example #8
Source File: XWatchesViewImpl.java From consulo with Apache License 2.0 | 6 votes |
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); } } }
Example #9
Source File: WatchesRootNode.java From consulo with Apache License 2.0 | 6 votes |
public void addWatchExpression(@Nullable XStackFrame stackFrame, @Nonnull XExpression expression, int index, boolean navigateToWatchNode) { WatchNodeImpl message = new WatchNodeImpl(myTree, this, expression, stackFrame); if (index == -1) { myChildren.add(message); index = myChildren.size() - 1; } else { myChildren.add(index, message); } fireNodeInserted(index); TreeUtil.selectNode(myTree, message); if (navigateToWatchNode) { myTree.scrollPathToVisible(message.getPath()); } }
Example #10
Source File: XBreakpointActionsPanel.java From consulo with Apache License 2.0 | 6 votes |
@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(); } }
Example #11
Source File: XDebuggerEvaluateActionHandler.java From consulo with Apache License 2.0 | 6 votes |
private static void showDialog(@Nonnull XDebugSession session, VirtualFile file, XDebuggerEditorsProvider editorsProvider, XStackFrame stackFrame, XDebuggerEvaluator evaluator, @Nonnull 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(); }
Example #12
Source File: XLightBreakpointPropertiesPanel.java From consulo with Apache License 2.0 | 6 votes |
public void saveProperties() { for (XBreakpointPropertiesSubPanel panel : mySubPanels) { panel.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()); }
Example #13
Source File: XDebuggerEditorBase.java From consulo with Apache License 2.0 | 5 votes |
protected Document createDocument(final XExpression text) { XDebuggerEditorsProvider provider = getEditorsProvider(); if (myContext != null && provider instanceof XDebuggerEditorsProviderBase) { return ((XDebuggerEditorsProviderBase)provider).createDocument(getProject(), text, myContext, myMode); } else { return provider.createDocument(getProject(), text, mySourcePosition, myMode); } }
Example #14
Source File: XDebuggerExpressionComboBox.java From consulo with Apache License 2.0 | 5 votes |
@Override public XExpression getItem() { Object document = myDelegate.getItem(); if (document instanceof Document) { // sometimes null on Mac return getEditorsProvider().createExpression(getProject(), (Document)document, myExpression.getLanguage(), myExpression.getMode()); } return null; }
Example #15
Source File: XDebuggerEditorBase.java From consulo with Apache License 2.0 | 5 votes |
private void saveTextInHistory(final XExpression text) { if (myHistoryId != null) { boolean update = XDebuggerHistoryManager.getInstance(myProject).addRecentExpression(myHistoryId, text); myHistoryIndex = -1; //meaning not from the history list if (update) { onHistoryChanged(); } } }
Example #16
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@NotNull public static Breakpoint toMuleBreakpoint(Project project, @NotNull XSourcePosition sourcePosition, XExpression conditionExpression, @Nullable Map<String, String> modulesToAppsMap) { VirtualFile file = sourcePosition.getFile(); Module module = ModuleUtilCore.findModuleForFile(file, project); String deployableName = module.getName(); if (modulesToAppsMap != null && !StringUtils.isEmpty(modulesToAppsMap.get(deployableName))) deployableName = modulesToAppsMap.get(deployableName); final String conditionScript = conditionExpression != null ? asMelScript(conditionExpression.getExpression()) : null; final XmlTag tag = getXmlTagAt(module.getProject(), sourcePosition); if (tag != null) { //TODO - Module name is an app name - but can I get it from Maven? Or override it by using the additional param? return new Breakpoint(getMulePath(tag), conditionScript, deployableName); } else { final int line = sourcePosition.getLine(); final Document document = FileDocumentManager.getInstance().getDocument(sourcePosition.getFile()); final PsiElement xmlElement = WeavePsiUtils.getFirstWeaveElement(module.getProject(), document, line); if (xmlElement != null) { PsiLanguageInjectionHost parent = PsiTreeUtil.getParentOfType(xmlElement, PsiLanguageInjectionHost.class); if (parent != null) { final XmlTag weavePart = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class); final XmlTag weaveTag = PsiTreeUtil.getParentOfType(weavePart, XmlTag.class); int lineNumber = line + 1 - XSourcePositionImpl.createByElement(xmlElement).getLine(); final String mulePath = getMulePath(weaveTag); //TODO - Module name is an app name - but can I get it from Maven? Or override it by using the additional param? return new Breakpoint(mulePath, getPrefix(weavePart) + "/" + (lineNumber + 1), conditionScript, deployableName); } } } return new Breakpoint("", conditionScript, deployableName); }
Example #17
Source File: XDebuggerEditorBase.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected FileType getFileType(@Nonnull XExpression expression) { FileType fileType = LanguageUtil.getLanguageFileType(expression.getLanguage()); if (fileType != null) { return fileType; } return getEditorsProvider().getFileType(); }
Example #18
Source File: XBreakpointBase.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setLogExpressionObject(@Nullable XExpression expression) { if (!Comparing.equal(myLogExpression, expression)) { myLogExpression = expression; fireBreakpointChanged(); } }
Example #19
Source File: XBreakpointBase.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setConditionExpression(@Nullable XExpression condition) { if (!Comparing.equal(condition, myCondition)) { myCondition = condition; fireBreakpointChanged(); } }
Example #20
Source File: XBreakpointActionsPanel.java From consulo with Apache License 2.0 | 5 votes |
@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(); }
Example #21
Source File: XLightBreakpointPropertiesPanel.java From consulo with Apache License 2.0 | 5 votes |
public void loadProperties() { for (XBreakpointPropertiesSubPanel panel : mySubPanels) { panel.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)); }
Example #22
Source File: BreakpointState.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static Condition create(boolean disabled, XExpression expression) { if (XDebuggerUtilImpl.isEmptyExpression(expression)) { return null; } return new Condition(disabled, expression); }
Example #23
Source File: XDebuggerEditorBase.java From consulo with Apache License 2.0 | 5 votes |
public void goForward() { final List<XExpression> expressions = getRecentExpressions(); if (myHistoryIndex > 0) { myHistoryIndex--; setExpression(expressions.get(myHistoryIndex)); } }
Example #24
Source File: XDebuggerEditorBase.java From consulo with Apache License 2.0 | 5 votes |
public void setExpression(@Nullable XExpression text) { if (text == null) { text = getMode() == EvaluationMode.EXPRESSION ? XExpressionImpl.EMPTY_EXPRESSION : XExpressionImpl.EMPTY_CODE_FRAGMENT; } Language language = text.getLanguage(); if (language == null) { if (myContext != null) { language = myContext.getLanguage(); } if (language == null && mySourcePosition != null) { language = LanguageUtil.getFileLanguage(mySourcePosition.getFile()); } if (language == null) { language = LanguageUtil.getFileTypeLanguage(getEditorsProvider().getFileType()); } text = new XExpressionImpl(text.getExpression(), language, text.getCustomInfo(), text.getMode()); } Collection<Language> languages = getSupportedLanguages(); boolean many = languages.size() > 1; if (language != null) { myChooseFactory.setVisible(many); } myChooseFactory.setVisible(myChooseFactory.isVisible() || many); //myChooseFactory.setEnabled(many && languages.contains(language)); if (language != null && language.getAssociatedFileType() != null) { Image fileTypeIcon = ImageEffects.layered(language.getAssociatedFileType().getIcon(), AllIcons.General.Dropdown); myChooseFactory.setIcon(TargetAWT.to(fileTypeIcon)); myChooseFactory.setDisabledIcon(TargetAWT.to(ImageEffects.grayed(fileTypeIcon))); } doSetText(text); }
Example #25
Source File: XDebuggerExpressionComboBox.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setItem(Object anObject) { if (anObject == null) { anObject = XExpressionImpl.EMPTY_EXPRESSION; } XExpression expression = (XExpression)anObject; myDelegate.getEditorComponent().setNewDocumentAndFileType(getFileType(expression), createDocument(expression)); }
Example #26
Source File: WatchesRootNode.java From consulo with Apache License 2.0 | 5 votes |
/** * @deprecated Use {@link #addWatchExpression(XStackFrame, XExpression, int, boolean)} */ @Deprecated public void addWatchExpression(@Nullable XDebuggerEvaluator evaluator, @Nonnull XExpression expression, int index, boolean navigateToWatchNode) { addWatchExpression((XStackFrame)null, expression, index, navigateToWatchNode); }
Example #27
Source File: XDebuggerExpressionComboBox.java From consulo with Apache License 2.0 | 5 votes |
private void fillComboBox() { myComboBox.removeAllItems(); for (XExpression expression : getRecentExpressions()) { myComboBox.addItem(expression); } if (myComboBox.getItemCount() > 0) { myComboBox.setSelectedIndex(0); } }
Example #28
Source File: XDebuggerExpressionEditor.java From consulo with Apache License 2.0 | 5 votes |
public XDebuggerExpressionEditor(Project project, @Nonnull XDebuggerEditorsProvider debuggerEditorsProvider, @Nullable @NonNls String historyId, @Nullable XSourcePosition sourcePosition, @Nonnull XExpression text, final boolean multiline, boolean editorFont, boolean showEditor) { super(project, debuggerEditorsProvider, multiline ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION, historyId, sourcePosition); myExpression = XExpressionImpl.changeMode(text, getMode()); myEditorTextField = new EditorTextField(createDocument(myExpression), project, debuggerEditorsProvider.getFileType(), false, !multiline) { @Override protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); editor.setVerticalScrollbarVisible(multiline); editor.getColorsScheme().setEditorFontName(getFont().getFontName()); editor.getColorsScheme().setEditorFontSize(getFont().getSize()); return editor; } @Override public Object getData(@Nonnull Key dataId) { if (LangDataKeys.CONTEXT_LANGUAGES == dataId) { return new Language[]{myExpression.getLanguage()}; } else if (CommonDataKeys.PSI_FILE == dataId) { return PsiDocumentManager.getInstance(getProject()).getPsiFile(getDocument()); } return super.getData(dataId); } }; if (editorFont) { myEditorTextField.setFontInheritedFromLAF(false); myEditorTextField.setFont(EditorUtil.getEditorFont()); } myComponent = decorate(myEditorTextField, multiline, showEditor); }
Example #29
Source File: DebuggerUIUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * Checks if value has evaluation expression ready, or calculation is pending */ public static boolean hasEvaluationExpression(@Nonnull XValue value) { AsyncResult<XExpression> promise = value.calculateEvaluationExpression(); if (promise.isDone()) { return promise.getResult() != null; } return true; }
Example #30
Source File: WatchNodeImpl.java From consulo with Apache License 2.0 | 5 votes |
public WatchNodeImpl(@Nonnull XDebuggerTree tree, @Nonnull WatchesRootNode parent, @Nonnull XExpression expression, @Nullable XStackFrame stackFrame) { super(tree, parent, expression.getExpression(), new XWatchValue(expression, tree, stackFrame)); myExpression = expression; }