From e0d2ec980efa64c911eaca9118009411f13ac754 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 23 Sep 2014 19:53:10 +0400 Subject: [PATCH] IDEA-130195 Code fragments in debugger can no longer evaluate Grails domain methods --- .../impl/evaluate/CodeFragmentInputComponent.java | 3 +++ .../xdebugger/impl/ui/XDebuggerEditorBase.java | 12 +++--------- .../xdebugger/impl/ui/XDebuggerMultilineEditor.java | 11 +++++++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java index be44e2c01d2b..63349076ddb4 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java @@ -52,6 +52,9 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent { 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); + } } @NotNull diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java index 61a499ccf4dd..cadd45350ca5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java @@ -98,9 +98,10 @@ public abstract class XDebuggerEditorBase { private ListPopup createLanguagePopup() { DefaultActionGroup actions = new DefaultActionGroup(); for (final Language language : getEditorsProvider().getSupportedLanguages(myProject, mySourcePosition)) { + //noinspection ConstantConditions actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) { @Override - public void actionPerformed(AnActionEvent e) { + public void actionPerformed(@NotNull AnActionEvent e) { XExpression currentExpression = getExpression(); setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo())); IdeFocusManager.getInstance(getProject()).requestFocus(getComponent(), true); @@ -127,7 +128,7 @@ public abstract class XDebuggerEditorBase { public void setSourcePosition(@Nullable XSourcePosition sourcePosition) { if (mySourcePosition != sourcePosition) { mySourcePosition = sourcePosition; - setExpression(getExpression(), false); + setExpression(getExpression()); } } @@ -144,16 +145,9 @@ public abstract class XDebuggerEditorBase { protected abstract void doSetText(XExpression text); public void setExpression(@Nullable XExpression text) { - setExpression(text, true); - } - - private void setExpression(@Nullable XExpression text, boolean saveInHistory) { if (text == null) { text = getMode() == EvaluationMode.EXPRESSION ? XExpressionImpl.EMPTY_EXPRESSION : XExpressionImpl.EMPTY_CODE_FRAGMENT; } - if (saveInHistory) { - saveTextInHistory(text); - } Language language = text.getLanguage(); if (language == null) { if (mySourcePosition != null) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java index 3f06418ac8ac..b2222ce556c5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java @@ -15,8 +15,10 @@ */ package com.intellij.xdebugger.impl.ui; +import com.intellij.lang.Language; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.ui.EditorTextField; import com.intellij.xdebugger.XExpression; @@ -34,6 +36,7 @@ import javax.swing.*; * @author nik */ public class XDebuggerMultilineEditor extends XDebuggerEditorBase { + private final JComponent myComponent; private final EditorTextField myEditorTextField; private XExpression myExpression; @@ -57,16 +60,20 @@ public class XDebuggerMultilineEditor extends XDebuggerEditorBase { } }; myEditorTextField.setFontInheritedFromLAF(false); + myComponent = addChooseFactoryLabel(myEditorTextField, true); } @Override public JComponent getComponent() { - return myEditorTextField; + return myComponent; } @Override protected void doSetText(XExpression text) { - myEditorTextField.setText(text.getExpression()); + myExpression = text; + Language language = text.getLanguage(); + FileType fileType = language != null ? language.getAssociatedFileType() : getEditorsProvider().getFileType(); + myEditorTextField.setNewDocumentAndFileType(fileType, createDocument(text)); } @Override