[name hints] settings ui cosmetics

This commit is contained in:
Yaroslav Lepenkin
2016-12-02 13:47:41 +03:00
parent 425a56febf
commit bb92553d33
5 changed files with 114 additions and 122 deletions
@@ -53,7 +53,7 @@ object JavaInlayHintsProvider {
if (params.isEmpty()) return false
if (params.size == 1) {
if (isBuilderLike(callExpression, method) || isSetterNamed(method)) return false
if (!ParameterNameHintsSettings.getInstance().isShowParamNameContainedInMethodName
if (ParameterNameHintsSettings.getInstance().isDoNotShowIfMethodNameContainsParameterName
&& isParamNameContainedInMethodName(params[0], method)) return false
}
return true
@@ -759,7 +759,7 @@ class Test {
}
fun `test do not show hint for name contained in method`() {
ParameterNameHintsSettings.getInstance().isShowParamNameContainedInMethodName = false
ParameterNameHintsSettings.getInstance().isDoNotShowIfMethodNameContainsParameterName = true
setup("""
class Test {
void main() {
@@ -776,7 +776,7 @@ class Test {
}
fun `test show if multiple params but name contained`() {
ParameterNameHintsSettings.getInstance().isShowParamNameContainedInMethodName = false
ParameterNameHintsSettings.getInstance().isDoNotShowIfMethodNameContainsParameterName = true
setup("""
class Test {
void main() {
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInsight.hints.settings.ParameterNameHintsConfigurable">
<grid id="27dc6" binding="myConfigurable" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myConfigurable" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="2069" height="400"/>
@@ -8,33 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="dda71" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="b3233" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="8ecb1" class="com.intellij.ui.EditorTextField" binding="myEditorTextField" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
<grid id="24a8f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="24a8f" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -42,91 +16,102 @@
<properties/>
<border type="none"/>
<children>
<component id="d30b0" class="com.intellij.ui.components.JBLabel">
<grid id="e5aa7" binding="myBlacklistPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&lt;html&gt;&#10;No in-line parameter name hints will be shown for methods matching any of these patterns.&lt;br&gt;&#10;Patterns are matched on fully qualified method name, parameter count and parameter names.&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;java.lang&lt;/code&gt; matches all methods from &lt;em&gt;java.lang&lt;/em&gt; package&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;java.lang.*(*, *)&lt;/code&gt; matches all methods from the &lt;em&gt;java.lang&lt;/em&gt; package with two parameters&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;(*info)&lt;/code&gt; matches all single parameter methods where the parameter name ends with &lt;em&gt;info&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;(key, value)&lt;/code&gt; matches all methods with parameters &lt;em&gt;key&lt;/em&gt; and &lt;em&gt;value&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;*.put(key, value)&lt;/code&gt; matches all &lt;em&gt;put&lt;/em&gt; methods with &lt;em&gt;key&lt;/em&gt; and &lt;em&gt;value&lt;/em&gt; parameters&#10;&lt;/ul&gt;&#10;&lt;/html&gt;"/>
</properties>
</component>
</children>
</grid>
<vspacer id="ca768">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="8ca84" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4be87" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Language:"/>
</properties>
</component>
<hspacer id="5eb47">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="6747b" class="com.intellij.openapi.ui.ComboBox" binding="myCurrentLanguageCombo" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="ea5b3" binding="myOptionsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="fe87e">
<border type="none"/>
<children>
<component id="d30b0" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&lt;html&gt;&#10;No in-line parameter name hints will be shown for methods matching any of these patterns.&lt;br&gt;&#10;Patterns are matched on fully qualified method name, parameter count and parameter names.&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;java.lang&lt;/code&gt; matches all methods from &lt;em&gt;java.lang&lt;/em&gt; package&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;java.lang.*(*, *)&lt;/code&gt; matches all methods from the &lt;em&gt;java.lang&lt;/em&gt; package with two parameters&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;(*info)&lt;/code&gt; matches all single parameter methods where the parameter name ends with &lt;em&gt;info&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;(key, value)&lt;/code&gt; matches all methods with parameters &lt;em&gt;key&lt;/em&gt; and &lt;em&gt;value&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;*.put(key, value)&lt;/code&gt; matches all &lt;em&gt;put&lt;/em&gt; methods with &lt;em&gt;key&lt;/em&gt; and &lt;em&gt;value&lt;/em&gt; parameters&#10;&lt;/ul&gt;&#10;&lt;/html&gt;"/>
</properties>
</component>
<grid id="8ca84" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="5eb47">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="6747b" class="com.intellij.openapi.ui.ComboBox" binding="myCurrentLanguageCombo" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="4be87" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Language:"/>
</properties>
</component>
</children>
</grid>
<component id="8ecb1" class="com.intellij.ui.EditorTextField" binding="myEditorTextField" custom-create="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="ea5b3" binding="myOptionsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="443be" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Show for non-literals in case of multiple params with the same type"/>
</properties>
</component>
<component id="a19f3" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Show if method contains it's single parameter name"/>
</properties>
</component>
<component id="359bc" class="com.intellij.ui.components.JBCheckBox" binding="myShowWhenMultipleParamsWithSameType" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="fb44" class="com.intellij.ui.components.JBCheckBox" binding="myShowIfParamNameContainedInMethod" custom-create="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<border type="none"/>
<children>
<hspacer id="fe87e">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="443be" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Show for non-literals in case of multiple params with the same type"/>
</properties>
</component>
<component id="a19f3" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Do not show if method name contains parameter name"/>
</properties>
</component>
<component id="359bc" class="com.intellij.ui.components.JBCheckBox" binding="myShowWhenMultipleParamsWithSameType" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="fb44" class="com.intellij.ui.components.JBCheckBox" binding="myDoNotShowIfParameterNameContainedInMethodName" custom-create="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
</children>
@@ -29,6 +29,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.util.containers.ContainerUtil;
@@ -50,8 +51,9 @@ public class ParameterNameHintsConfigurable extends DialogWrapper {
private ComboBox<Language> myCurrentLanguageCombo;
private JBCheckBox myShowWhenMultipleParamsWithSameType;
private JBCheckBox myShowIfParamNameContainedInMethod;
private JBCheckBox myDoNotShowIfParameterNameContainedInMethodName;
private JPanel myOptionsPanel;
private JPanel myBlacklistPanel;
private final Language myInitiallySelectedLanguage;
private final String myNewPreselectedItem;
@@ -70,10 +72,12 @@ public class ParameterNameHintsConfigurable extends DialogWrapper {
myNewPreselectedItem = newPreselectedPattern;
myBlackLists = ContainerUtil.newHashMap();
setTitle("Configure Parameter Name Hints Blacklist");
setTitle("Configure Parameter Name Hints");
init();
myOptionsPanel.setVisible(true);
myOptionsPanel.setBorder(IdeBorderFactory.createTitledBorder("Options"));
myBlacklistPanel.setBorder(IdeBorderFactory.createTitledBorder("Blacklist"));
}
private void updateOkEnabled() {
@@ -102,7 +106,7 @@ public class ParameterNameHintsConfigurable extends DialogWrapper {
});
ParameterNameHintsSettings settings = ParameterNameHintsSettings.getInstance();
settings.setShowParamNameContainedInMethodName(myShowIfParamNameContainedInMethod.isSelected());
settings.setDoNotShowIfMethodNameContainsParameterName(myDoNotShowIfParameterNameContainedInMethodName.isSelected());
settings.setShowForParamsWithSameType(myShowWhenMultipleParamsWithSameType.isSelected());
}
@@ -142,11 +146,11 @@ public class ParameterNameHintsConfigurable extends DialogWrapper {
}
});
myShowIfParamNameContainedInMethod = new JBCheckBox();
myDoNotShowIfParameterNameContainedInMethodName = new JBCheckBox();
myShowWhenMultipleParamsWithSameType = new JBCheckBox();
ParameterNameHintsSettings settings = ParameterNameHintsSettings.getInstance();
myShowIfParamNameContainedInMethod.setSelected(settings.isShowParamNameContainedInMethodName());
myDoNotShowIfParameterNameContainedInMethodName.setSelected(settings.isDoNotShowIfMethodNameContainsParameterName());
myShowWhenMultipleParamsWithSameType.setSelected(settings.isShowForParamsWithSameType());
initLanguageCombo(languages, selected);
@@ -15,7 +15,7 @@ private object XmlTagHelper {
val ADDED = "added"
val REMOVED = "removed"
val PATTERN = "pattern"
val SHOW_IF_PARAM_NAME_CONTAINED = "showIfParamNameContained"
val DO_NOT_SHOW_IF_PARAM_NAME_CONTAINED_IN_METHOD_NAME = "showIfParamNameContained"
val SHOW_WHEN_MULTIPLE_PARAMS_WITH_SAME_TYPE = "showWhenMultipleParamsWithSameType"
}
@@ -49,7 +49,7 @@ class ParameterNameHintsSettings : PersistentStateComponent<Element> {
private val myRemovedPatterns = hashMapOf<String, Set<String>>()
private val myAddedPatterns = hashMapOf<String, Set<String>>()
var isShowParamNameContainedInMethodName: Boolean = false
var isDoNotShowIfMethodNameContainsParameterName: Boolean = true
var isShowForParamsWithSameType: Boolean = false
fun addIgnorePattern(language: Language, pattern: String) {
@@ -81,8 +81,8 @@ class ParameterNameHintsSettings : PersistentStateComponent<Element> {
blacklists.addLanguagePatternElements(language, patterns, XmlTagHelper.ADDED)
}
root.getOrCreateChild(XmlTagHelper.SHOW_IF_PARAM_NAME_CONTAINED)
.setAttribute("value", isShowParamNameContainedInMethodName.toString())
root.getOrCreateChild(XmlTagHelper.DO_NOT_SHOW_IF_PARAM_NAME_CONTAINED_IN_METHOD_NAME)
.setAttribute("value", isDoNotShowIfMethodNameContainsParameterName.toString())
root.getOrCreateChild(XmlTagHelper.SHOW_WHEN_MULTIPLE_PARAMS_WITH_SAME_TYPE)
.setAttribute("value", isShowForParamsWithSameType.toString())
@@ -94,7 +94,7 @@ class ParameterNameHintsSettings : PersistentStateComponent<Element> {
myAddedPatterns.clear()
myRemovedPatterns.clear()
isShowParamNameContainedInMethodName = false
isDoNotShowIfMethodNameContainsParameterName = true
isShowForParamsWithSameType = false
val allBlackLists = state
@@ -107,8 +107,11 @@ class ParameterNameHintsSettings : PersistentStateComponent<Element> {
myRemovedPatterns[language] = blacklist.extractPatterns(XmlTagHelper.REMOVED)
}
isShowParamNameContainedInMethodName = state.getBooleanValue(XmlTagHelper.SHOW_IF_PARAM_NAME_CONTAINED, true)
isShowForParamsWithSameType = state.getBooleanValue(XmlTagHelper.SHOW_WHEN_MULTIPLE_PARAMS_WITH_SAME_TYPE, false)
isDoNotShowIfMethodNameContainsParameterName = state
.getBooleanValue(XmlTagHelper.DO_NOT_SHOW_IF_PARAM_NAME_CONTAINED_IN_METHOD_NAME, true)
isShowForParamsWithSameType = state
.getBooleanValue(XmlTagHelper.SHOW_WHEN_MULTIPLE_PARAMS_WITH_SAME_TYPE, false)
}
private fun Element.getBooleanValue(childName: String, defaultValue: Boolean): Boolean {