[Inline Param Name Hints] do not show hints for java.lang.String methods

This commit is contained in:
Yaroslav Lepenkin
2016-09-29 22:00:24 +03:00
parent bd7dad86c1
commit e0a89da302
2 changed files with 34 additions and 0 deletions
@@ -46,6 +46,8 @@ public class ParameterNameHintsManager {
"charAt", "startsWith", "indexOf"
);
private static final List<String> COMMON_CLASSES = ContainerUtil.newArrayList(JAVA_LANG_STRING);
@NotNull
private final List<InlayInfo> myDescriptors;
@@ -59,6 +61,11 @@ public class ParameterNameHintsManager {
&& hasUnclearExpressions(callArguments))
{
PsiMethod method = (PsiMethod)resolveResult.getElement();
if (isInBlackList(method)) {
myDescriptors = descriptors;
return;
}
PsiParameter[] parameters = method.getParameterList().getParameters();
descriptors = buildDescriptorsForLiteralArguments(callArguments, parameters, resolveResult);
}
@@ -66,6 +73,15 @@ public class ParameterNameHintsManager {
myDescriptors = descriptors;
}
private static boolean isInBlackList(PsiMethod method) {
PsiClass aClass = method.getContainingClass();
if (aClass != null) {
String fqn = aClass.getQualifiedName();
return COMMON_CLASSES.stream().anyMatch((e) -> e.equals(fqn));
}
return false;
}
private static boolean isMethodToShowParams(JavaResolveResult resolveResult) {
PsiElement element = resolveResult.getElement();
if (element instanceof PsiMethod) {
@@ -461,6 +461,24 @@ public class VarArgTest {
onLineStartingWith("check(")
.assertInlays("beginIndex->10", "endIndex->1000")
}
fun `test ignore String methods`() {
setup("""
class Test {
public void main() {
"qq".replace("a", "a");
"ww".replace('a', 'b');
String.format("line", "eee", "www");
}
}
""")
onLineStartingWith("\"q").assertNoInlays()
onLineStartingWith("\"w").assertNoInlays()
onLineStartingWith("String").assertNoInlays()
}
fun `test inline common name pair if more that 2 args xxx`() {
setup("""