mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Inline Param Name Hints] do not show hints for java.lang.String methods
This commit is contained in:
+16
@@ -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) {
|
||||
|
||||
+18
@@ -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("""
|
||||
|
||||
Reference in New Issue
Block a user