show shortcuts for overloads switching in parameter info popup

This commit is contained in:
Dmitry Batrak
2017-09-19 15:56:19 +03:00
parent 9d598fa28a
commit ea7a991311
4 changed files with 22 additions and 1 deletions
@@ -693,4 +693,9 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
updateMethodPresentation((PsiMethod)p, null, context);
}
}
@Override
public boolean supportsOverloadSwitching() {
return CodeInsightSettings.getInstance().SHOW_PARAMETER_NAME_HINTS_ON_COMPLETION;
}
}
@@ -46,5 +46,6 @@ public interface ParameterInfoHandler <ParameterOwner, ParameterType> {
@Nullable String getParameterCloseChars();
boolean tracksParameterIndex();
default boolean supportsOverloadSwitching() { return false; }
default void dispose() {}
}
@@ -17,14 +17,17 @@
package com.intellij.codeInsight.hint;
import com.google.common.collect.ImmutableMap;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.lang.parameterInfo.ParameterInfoHandler;
import com.intellij.lang.parameterInfo.ParameterInfoUIContextEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.ui.*;
import com.intellij.util.Function;
import com.intellij.util.ui.JBEmptyBorder;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.accessibility.AccessibleContextUtil;
import com.intellij.xml.util.XmlStringUtil;
@@ -48,6 +51,7 @@ public class ParameterInfoComponent extends JPanel {
@NotNull private final ParameterInfoHandler myHandler;
private final OneElementComponent[] myPanels;
private final JLabel myShortcutLabel;
private final Font NORMAL_FONT;
private final Font BOLD_FONT;
@@ -123,6 +127,13 @@ public class ParameterInfoComponent extends JPanel {
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(pane, BorderLayout.CENTER);
myShortcutLabel = new JLabel(CodeInsightBundle.message("parameter.info.switch.overload.shortcuts"));
myShortcutLabel.setForeground(new JBColor(0x787878, 0x787878));
Font labelFont = UIUtil.getLabelFont();
myShortcutLabel.setFont(labelFont.deriveFont(labelFont.getSize2D() - (SystemInfo.isWindows ? 1 : 2)));
myShortcutLabel.setBorder(new JBEmptyBorder(3, 0, 0, 0));
add(myShortcutLabel, BorderLayout.SOUTH);
myCurrentParameterIndex = -1;
}
@@ -255,6 +266,8 @@ public class ParameterInfoComponent extends JPanel {
}
}
myShortcutLabel.setVisible(!singleParameterInfo && myObjects.length > 1 && myHandler.supportsOverloadSwitching());
invalidate();
validate();
repaint();
@@ -557,4 +557,6 @@ block.comment.intersects.existing.comment=Selected region intersects existing co
block.comment.wrapping.suffix=Selected region contains block comment suffix
block.comment.nested.comment=Selected region contained block {0, choice, 1#comment|2#comments},\nsurrounding ranges were commented.
intention.unroll.loop.family=Unroll loop
intention.unroll.loop.family=Unroll loop
parameter.info.switch.overload.shortcuts=Switch with \u2191 or \u2193