[Parameter Hints] builder methods only ones with single param

This commit is contained in:
Yaroslav Lepenkin
2016-11-24 14:25:18 +03:00
parent dc0a725919
commit f846c43145
2 changed files with 24 additions and 1 deletions
@@ -57,15 +57,17 @@ public class JavaParameterHintManager {
}
private static boolean isBuilder(PsiCallExpression expression, PsiMethod method) {
if (expression instanceof PsiNewExpression) {
if (expression instanceof PsiNewExpression || !hasSingleParameter(method)) {
return false;
}
PsiType returnType = TypeConversionUtil.erasure(method.getReturnType());
final PsiClass aClass = method.getContainingClass();
final String calledMethodFqn = aClass != null ? aClass.getQualifiedName() : null;
if (calledMethodFqn != null && returnType != null) {
return returnType.equalsToText(calledMethodFqn);
}
return false;
}
@@ -582,6 +582,27 @@ class Test {
onLineStartingWith("builder.bwait").assertNoInlays()
}
fun `test builder method only method with one param`() {
setup("""
class Builder {
Builder qwit(boolean value, String sValue) {}
Builder trew(boolean value) {}
}
class Test {
public void test() {
Builder builder = new Builder();
builder
.trew(false)
.qwit(true, "value");
}
}
""")
onLineStartingWith(".trew").assertNoInlays()
onLineStartingWith(".qw").assertInlays("value->true", "sValue->\"value\"")
}
fun `test do not show single parameter hint if it is string literal`() {
setup("""
public class Test {