From 12db31ac2d4dfa6268ad10dafad777fcaeca6cc3 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Tue, 26 Sep 2017 16:38:01 +0300 Subject: [PATCH] don't show overload switch prompt for lookup hint --- .../codeInsight/hint/ParameterInfoComponent.java | 12 ++++++------ .../codeInsight/hint/ParameterInfoController.java | 2 +- .../codeInsight/hint/ShowParameterInfoHandler.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java index 6ad194d1723a..f92521c47742 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java @@ -91,10 +91,11 @@ public class ParameterInfoComponent extends JPanel { } ParameterInfoComponent(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler) { - this(objects, editor, handler, false); + this(objects, editor, handler, false, false); } - ParameterInfoComponent(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler, boolean requestFocus) { + ParameterInfoComponent(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler, + boolean requestFocus, boolean allowSwitchLabel) { super(new BorderLayout()); myRequestFocus = requestFocus; @@ -131,7 +132,8 @@ public class ParameterInfoComponent extends JPanel { String upShortcut = KeymapUtil.getFirstKeyboardShortcutText(IdeActions.ACTION_METHOD_OVERLOAD_SWITCH_UP); String downShortcut = KeymapUtil.getFirstKeyboardShortcutText(IdeActions.ACTION_METHOD_OVERLOAD_SWITCH_DOWN); - if (upShortcut.isEmpty() && downShortcut.isEmpty()) { + if (!allowSwitchLabel || myObjects.length <= 1 || !myHandler.supportsOverloadSwitching() || + upShortcut.isEmpty() && downShortcut.isEmpty()) { myShortcutLabel = null; } else { @@ -277,9 +279,7 @@ public class ParameterInfoComponent extends JPanel { } } - if (myShortcutLabel != null) { - myShortcutLabel.setVisible(!singleParameterInfo && myObjects.length > 1 && myHandler.supportsOverloadSwitching()); - } + if (myShortcutLabel != null) myShortcutLabel.setVisible(!singleParameterInfo); invalidate(); validate(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java index d087c7b47d14..1215a7cbe312 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java @@ -149,7 +149,7 @@ public class ParameterInfoController implements Disposable { myHandler = handler; myProvider = new MyBestLocationPointProvider(editor); myLbraceMarker = editor.getDocument().createRangeMarker(lbraceOffset, lbraceOffset); - myComponent = new ParameterInfoComponent(descriptors, editor, handler, requestFocus); + myComponent = new ParameterInfoComponent(descriptors, editor, handler, requestFocus, true); myHint = new LightweightHint(myComponent); myKeepOnHintHidden = !showHint; mySingleParameterInfo = !showHint; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoHandler.java index 0795955bb07b..7495feb5381a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoHandler.java @@ -143,7 +143,7 @@ public class ShowParameterInfoHandler implements CodeInsightActionHandler { final Project project, ParameterInfoHandler handler, boolean requestFocus) { - ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor, handler, requestFocus); + ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor, handler, requestFocus, false); component.update(false); final LightweightHint hint = new LightweightHint(component);