mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[Parameter Name Hints] show hints for single param methods if method returns something and has boolean parameter
This commit is contained in:
+7
-1
@@ -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;
|
||||
}
|
||||
|
||||
+16
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user