[Parameter Name Hints] show hints for single param methods if method returns something and has boolean parameter

This commit is contained in:
Yaroslav Lepenkin
2016-10-03 18:25:01 +03:00
parent 8942ece514
commit e62abe8283
2 changed files with 23 additions and 1 deletions
@@ -72,13 +72,19 @@ public class ParameterNameHintsManager {
PsiMethod method = (PsiMethod)element;
if (isSetter(method)) return false;
if (hasSingleParameter(method)) {
return PsiType.VOID.equals(method.getReturnType());
PsiParameter parameter = method.getParameterList().getParameters()[0];
return PsiType.VOID.equals(method.getReturnType()) || isBoolean(parameter);
}
return !isCommonMethod(method);
}
return false;
}
private static boolean isBoolean(PsiParameter parameter) {
PsiType type = parameter.getType();
return PsiType.BOOLEAN.equals(type) || PsiType.BOOLEAN.equals(PsiPrimitiveType.getUnboxedType(type));
}
private static boolean hasSingleParameter(PsiMethod method) {
return method.getParameterList().getParametersCount() == 1;
}
@@ -589,6 +589,22 @@ class Test {
onLineStartingWith("drawRect").assertInlays("w->10", "h->12")
}
fun `test show for method with boolean param and return value`() {
setup("""
class Test {
void test() {
String name = getTestName(true);
System.out.println("");
}
String getTestName(boolean lowerCase) {}
}
""")
onLineStartingWith("String name").assertInlays("lowerCase->true")
}
private fun getInlays(): List<Inlay> {
val editor = myFixture.editor
return editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength)