mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] less highlighting range (IDEA-292997)
GitOrigin-RevId: 3fb8256094eff2e93758e2ea285e51c179b4569c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f2d737b880
commit
1122b7ac15
+11
-11
@@ -499,11 +499,17 @@ public final class HighlightMethodUtil {
|
||||
PsiExpression[] expressions = list.getExpressions();
|
||||
PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
|
||||
mismatchedExpressions = mismatchedArgs(expressions, substitutor, parameters, candidateInfo.isVarargs());
|
||||
if (mismatchedExpressions.size() == 1) {
|
||||
if (mismatchedExpressions.size() == 1 && parameters.length > 0) {
|
||||
toolTip = createOneArgMismatchTooltip(candidateInfo, mismatchedExpressions, expressions, parameters);
|
||||
}
|
||||
if (toolTip == null) {
|
||||
toolTip = mismatchedExpressions.isEmpty() ? description : createMismatchedArgumentsHtmlTooltip(candidateInfo, list);
|
||||
if ((parameters.length == 0 || !parameters[parameters.length - 1].isVarArgs()) &&
|
||||
parameters.length != expressions.length) {
|
||||
toolTip = createMismatchedArgumentCountTooltip(parameters, expressions);
|
||||
}
|
||||
else {
|
||||
toolTip = mismatchedExpressions.isEmpty() ? description : createMismatchedArgumentsHtmlTooltip(candidateInfo, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -542,11 +548,8 @@ public final class HighlightMethodUtil {
|
||||
PsiExpression[] expressions,
|
||||
PsiParameter[] parameters) {
|
||||
PsiExpression wrongArg = mismatchedExpressions.get(0);
|
||||
PsiType argType = wrongArg.getType();
|
||||
PsiType argType = wrongArg != null ? wrongArg.getType() : null;
|
||||
if (argType != null) {
|
||||
if ((parameters.length == 0 || !parameters[parameters.length - 1].isVarArgs()) && parameters.length != expressions.length) {
|
||||
return createMismatchedArgumentCountTooltip(parameters, expressions);
|
||||
}
|
||||
int idx = ArrayUtil.find(expressions, wrongArg);
|
||||
PsiType paramType = candidateInfo.getSubstitutor().substitute(PsiTypesUtil.getParameterType(parameters, idx, candidateInfo.isVarargs()));
|
||||
String errorMessage = candidateInfo.getInferenceErrorMessage();
|
||||
@@ -718,13 +721,10 @@ public final class HighlightMethodUtil {
|
||||
PsiSubstitutor substitutor,
|
||||
PsiParameter @NotNull [] parameters,
|
||||
boolean varargs) {
|
||||
if ((parameters.length == 0 || !parameters[parameters.length - 1].isVarArgs()) && parameters.length > expressions.length) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<PsiExpression> result = new ArrayList<>();
|
||||
for (int i = 0; i < Math.max(parameters.length, expressions.length); i++) {
|
||||
if (parameters.length == 0 || !assignmentCompatible(i, parameters, expressions, substitutor, varargs)) {
|
||||
if (parameters.length == 0 ||
|
||||
!assignmentCompatible(i, parameters, expressions, substitutor, varargs)) {
|
||||
result.add(i < expressions.length ? expressions[i] : null);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class MyTest {
|
||||
MyTest(int a, int b, int c) {
|
||||
}
|
||||
|
||||
{
|
||||
new MyTest(1, <error descr="'MyTest(int, int, int)' in 'MyTest' cannot be applied to '(int, java.lang.String)'">""</error>);
|
||||
}
|
||||
}
|
||||
+20
@@ -1054,6 +1054,26 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
.forEach(info -> Assert.assertEquals(expected, info.getToolTip()));
|
||||
}
|
||||
|
||||
public void testTooltipNotEnoughArguments() {
|
||||
doTest();
|
||||
String toolTipForeground = ColorUtil.toHtmlColor(UIUtil.getToolTipForeground());
|
||||
String greyed = ColorUtil.toHtmlColor(UIUtil.getContextHelpForeground());
|
||||
String red = ColorUtil.toHtmlColor(UIUtil.getErrorForeground());
|
||||
String expected = "<html><body><table>" +
|
||||
"<tr>" +
|
||||
"<td style='padding: 0px 16px 8px 4px;color: " + greyed + "'>Required type:</td>" +
|
||||
"<td style='padding: 0px 4px 8px 0px;'><font color=\"" + toolTipForeground + "\">int</font></td></tr>" +
|
||||
"<tr><td style='padding: 0px 16px 0px 4px;color: " + greyed + "'>Provided:</td>" +
|
||||
"<td style='padding: 0px 4px 0px 0px;'><font color=\"" + red + "\">String</font></td></tr>" +
|
||||
"</table>" +
|
||||
"</body></html>";
|
||||
|
||||
doHighlighting()
|
||||
.stream()
|
||||
.filter(info -> info.type == HighlightInfoType.ERROR)
|
||||
.forEach(info -> Assert.assertEquals(expected, info.getToolTip()));
|
||||
}
|
||||
|
||||
public void testVarargsTooltip() {
|
||||
doTest();
|
||||
String toolTipForeground = ColorUtil.toHtmlColor(UIUtil.getToolTipForeground());
|
||||
|
||||
Reference in New Issue
Block a user