diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java index 3ad759137240..da0c3855fa0f 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java @@ -16,6 +16,8 @@ package com.intellij.openapi.module; +import org.jetbrains.annotations.NotNull; + /** * @author yole */ @@ -23,7 +25,7 @@ public class ModuleServiceManager { private ModuleServiceManager() { } - public static T getService(Module module, Class serviceClass) { + public static T getService(@NotNull Module module, @NotNull Class serviceClass) { return (T)module.getPicoContainer().getComponentInstance(serviceClass.getName()); } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java b/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java index 8b0db9e4694d..3e3c1f8e5ccd 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java @@ -60,9 +60,8 @@ public class ConsoleExecuteActionHandler { languageConsole.addCurrentToHistory(range, false, myPreserveMarkup); } languageConsole.setInputText(""); - if (!StringUtil.isEmptyOrSpaces(text)) { - myConsoleHistoryModel.addToHistory(text); - } + + myConsoleHistoryModel.addToHistory(text); // Send to interpreter / server processLine(text); diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java index 1dd56eedd869..09974f4929db 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java @@ -646,6 +646,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { private class MyTreeSelectionListener implements TreeSelectionListener { private final TextAttributes myAttributes; + private RangeHighlighter myHighlighter; public MyTreeSelectionListener() { myAttributes = new TextAttributes(); @@ -656,11 +657,8 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { public void valueChanged(TreeSelectionEvent e) { if (!myEditor.getDocument().getText().equals(myLastParsedText)) return; TreePath path = myTree.getSelectionPath(); - if (path == null) { - clearSelection(); - } - else { - clearSelection(); + clearSelection(); + if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (!(node.getUserObject() instanceof ViewerNodeDescriptor)) return; ViewerNodeDescriptor descriptor = (ViewerNodeDescriptor)node.getUserObject(); @@ -684,8 +682,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { final int textLength = myEditor.getDocument().getTextLength(); if (end <= textLength) { - myEditor.getMarkupModel() - .addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE); + myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE); if (myTree.hasFocus()) { myEditor.getCaretModel().moveToOffset(start); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); @@ -716,7 +713,10 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { } private void clearSelection() { - myEditor.getMarkupModel().removeAllHighlighters(); + if (myHighlighter != null) { + myEditor.getMarkupModel().removeHighlighter(myHighlighter); + myHighlighter.dispose(); + } } } diff --git a/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java b/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java index 0e562906b9d4..385b0bb2d862 100644 --- a/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java +++ b/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java @@ -2,6 +2,7 @@ package com.intellij.execution.process; import com.intellij.ide.ui.UISettings; import com.intellij.openapi.util.ModificationTracker; +import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -21,11 +22,14 @@ public class ConsoleHistoryModel implements ModificationTracker { public void addToHistory(final String statement) { final int maxHistorySize = getMaxHistorySize(); synchronized (myHistory) { - removeFromHistory(statement); - if (myHistory.size() >= maxHistorySize) { - myHistory.removeLast(); + myHistoryCursor = -1; + if (!StringUtil.isEmptyOrSpaces(statement)) { + removeFromHistory(statement); + if (myHistory.size() >= maxHistorySize) { + myHistory.removeLast(); + } + myHistory.addFirst(statement); } - myHistory.addFirst(statement); } } @@ -36,7 +40,7 @@ public class ConsoleHistoryModel implements ModificationTracker { public void removeFromHistory(final String statement) { synchronized (myHistory) { myModificationTracker++; - myHistoryCursor = -1; + myHistory.remove(statement); } }