[java] don't include fully qualified name in unresolved call messages (IDEA-282207)

GitOrigin-RevId: 3f22a64e3ab3173157368140af5d072e3cad2654
This commit is contained in:
Anna Kozlova
2022-01-26 21:14:47 +01:00
committed by intellij-monorepo-bot
parent 44e8537630
commit 4a300c672b
5 changed files with 13 additions and 13 deletions

View File

@@ -490,7 +490,7 @@ public final class HighlightMethodUtil {
String methodName = HighlightMessageUtil.getSymbolName(resolvedMethod, substitutor);
PsiClass parent = resolvedMethod.getContainingClass();
String containerName = parent == null ? "" : HighlightMessageUtil.getSymbolName(parent, substitutor);
String argTypes = buildArgTypesList(list);
String argTypes = buildArgTypesList(list, false);
String description = JavaErrorBundle.message("wrong.method.arguments", methodName, containerName, argTypes);
String toolTip = null;
List<PsiExpression> mismatchedExpressions;
@@ -784,7 +784,7 @@ public final class HighlightMethodUtil {
description = qualifier != null ? JavaErrorBundle
.message("ambiguous.method.call.no.match", referenceToMethod.getReferenceName(), qualifier)
: JavaErrorBundle
.message("cannot.resolve.method", referenceToMethod.getReferenceName() + buildArgTypesList(list));
.message("cannot.resolve.method", referenceToMethod.getReferenceName() + buildArgTypesList(list, true));
highlightInfoType = HighlightInfoType.WRONG_REF;
}
else {
@@ -857,7 +857,7 @@ public final class HighlightMethodUtil {
if (element != null && !resolveResult.isStaticsScopeCorrect()) {
return null;
}
String methodName = referenceToMethod.getReferenceName() + buildArgTypesList(list);
String methodName = referenceToMethod.getReferenceName() + buildArgTypesList(list, true);
description = JavaErrorBundle.message("cannot.resolve.method", methodName);
if (candidates.length == 0) {
return null;
@@ -1708,7 +1708,7 @@ public final class HighlightMethodUtil {
if (constructors.length == 0) {
if (!list.isEmpty()) {
String constructorName = aClass.getName();
String argTypes = buildArgTypesList(list);
String argTypes = buildArgTypesList(list, false);
String description = JavaErrorBundle.message("wrong.constructor.arguments", constructorName + "()", argTypes);
String tooltip = createMismatchedArgumentsHtmlTooltip(list, null, PsiParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).description(description).escapedToolTip(tooltip).navigationShift(+1).create();
@@ -1768,7 +1768,7 @@ public final class HighlightMethodUtil {
if (constructor == null) {
String name = aClass.getName();
name += buildArgTypesList(list);
name += buildArgTypesList(list, true);
String description = JavaErrorBundle.message("cannot.resolve.constructor", name);
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(elementToHighlight).descriptionAndTooltip(description).create();
@@ -1889,14 +1889,14 @@ public final class HighlightMethodUtil {
}
@NotNull
private static String buildArgTypesList(@NotNull PsiExpressionList list) {
private static String buildArgTypesList(@NotNull PsiExpressionList list, boolean shortNames) {
StringBuilder builder = new StringBuilder();
builder.append("(");
PsiExpression[] args = list.getExpressions();
for (int i = 0; i < args.length; i++) {
if (i > 0) builder.append(", ");
PsiType argType = args[i].getType();
builder.append(argType != null ? JavaHighlightUtil.formatType(argType) : "?");
builder.append(argType != null ? (shortNames ? argType.getPresentableText() : JavaHighlightUtil.formatType(argType)) : "?");
}
builder.append(")");
return builder.toString();

View File

@@ -5,7 +5,7 @@ public abstract class Test<T> {
Test<? super T> sBind,
Test<? extends T> eBind) {
sBind.toProvider(provider);
eBind.toProvider<error descr="Cannot resolve method 'toProvider(a.Provider<T>)'">(provider)</error><EOLError descr="';' expected"></EOLError>
eBind.toProvider<error descr="Cannot resolve method 'toProvider(Provider<T>)'">(provider)</error><EOLError descr="';' expected"></EOLError>
}
abstract void toProvider(Provider<? extends T> var1);

View File

@@ -4,14 +4,14 @@ class Test {
}
static void foo(final A<?> bar) {
bar._<error descr="Cannot resolve method '_(java.lang.String)'">("")</error>;
bar._<error descr="Cannot resolve method '_(String)'">("")</error>;
}
static void foo1(final A<? extends String> bar) {
bar._<error descr="Cannot resolve method '_(java.lang.String)'">("")</error>;
bar._<error descr="Cannot resolve method '_(String)'">("")</error>;
}
static void foo2(final A<? extends Integer> bar) {
bar._<error descr="Cannot resolve method '_(java.lang.String)'">("")</error>;
bar._<error descr="Cannot resolve method '_(String)'">("")</error>;
}

View File

@@ -8,7 +8,7 @@ class Test<T> {
m("");
Test.<String>m("");
new Test<>("");
new Test<String><error descr="Cannot resolve constructor 'Test(java.lang.String)'">("")</error>;
new Test<String><error descr="Cannot resolve constructor 'Test(String)'">("")</error>;
}
}

View File

@@ -1,7 +1,7 @@
class MyTest {
void m(String[] refInfos){
refInfos = <error descr="Cannot resolve method 'unresolved' in 'MyTest'">unresolved</error>(refInfos, refInfo -> {
refInfo = refInfo.<error descr="Cannot resolve method 'replaceAll(java.lang.String, java.lang.String)'">replaceAll</error>("a", "b");
refInfo = refInfo.<error descr="Cannot resolve method 'replaceAll(String, String)'">replaceAll</error>("a", "b");
refInfo = n<error descr="'n(java.lang.String)' in 'MyTest' cannot be applied to '(<lambda parameter>)'">(refInfo)</error>;
return refInfo;
});