mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
incompatible types tooltips: use short type names at varargs position (IDEA-224305)
GitOrigin-RevId: cd5dc23e741098d6158dc9ebec666a1a600e1700
This commit is contained in:
committed by
intellij-monorepo-bot
parent
400018c548
commit
5b3ef443c9
+3
-1
@@ -1032,7 +1032,9 @@ public class HighlightMethodUtil {
|
||||
PsiParameter parameter = i < parameters.length ? parameters[i] : null;
|
||||
PsiExpression expression = i < expressions.length ? expressions[i] : null;
|
||||
if (assignmentCompatible(i, parameters, expressions, substitutor)) continue;
|
||||
boolean showShortType = HighlightUtil.showShortType(parameter != null ? substitutor.substitute(parameter.getType()) : null,
|
||||
boolean varargs = info != null && info.getApplicabilityLevel() == MethodCandidateInfo.ApplicabilityLevel.VARARGS;
|
||||
PsiType parameterType = PsiTypesUtil.getParameterType(parameters, i, varargs);
|
||||
boolean showShortType = HighlightUtil.showShortType(substitutor.substitute(parameterType),
|
||||
expression != null ? expression.getType() : null);
|
||||
s.append("<tr>");
|
||||
if (parameter != null) {
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class MyTest {
|
||||
|
||||
private void paramTypeMismatch() {
|
||||
String.join(",", <error descr="'join(java.lang.CharSequence, java.lang.CharSequence...)' in 'java.lang.String' cannot be applied to '(java.lang.String, java.lang.String, int, java.lang.String)'">"start"</error>, <error descr="'join(java.lang.CharSequence, java.lang.CharSequence...)' in 'java.lang.String' cannot be applied to '(java.lang.String, java.lang.String, int, java.lang.String)'">1</error>, <error descr="'join(java.lang.CharSequence, java.lang.CharSequence...)' in 'java.lang.String' cannot be applied to '(java.lang.String, java.lang.String, int, java.lang.String)'">"end"</error>);
|
||||
}
|
||||
}
|
||||
+29
@@ -21,6 +21,8 @@ import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
import com.intellij.codeInspection.unusedImport.UnusedImportInspection;
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsUtil;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -1064,6 +1066,33 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
.forEach(info -> Assert.assertEquals(expected, info.getToolTip()));
|
||||
}
|
||||
|
||||
public void testTooltipShortTypeNames() {
|
||||
doTest();
|
||||
String toolTipForeground = ColorUtil.toHtmlColor(UIUtil.getToolTipForeground());
|
||||
String greyed = ColorUtil.toHtmlColor(UIUtil.getContextHelpForeground());
|
||||
String red = ColorUtil.toHtmlColor(DialogWrapper.ERROR_FOREGROUND_COLOR);
|
||||
String paramBgColor = ColorUtil.toHtmlColor(EditorColorsUtil.getGlobalOrDefaultColorScheme()
|
||||
.getAttributes(DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT)
|
||||
.getBackgroundColor());
|
||||
String expected = "<html><body><table>" +
|
||||
"<tr>" +
|
||||
"<td/>" +
|
||||
"<td style='color: " + greyed + "; padding-left: 16px; padding-right: 24px;'>Required type</td>" +
|
||||
"<td style='color: " + greyed + "; padding-right: 28px;'>Provided</td></tr>" +
|
||||
"<tr>" +
|
||||
"<td><table><tr><td style='color: " + greyed + "; font-size:12pt; padding:1px 4px 1px 4px;background-color: " + paramBgColor + ";'>charSequences:</td></tr></table></td>" +
|
||||
"<td style='padding-left: 16px; padding-right: 24px;'><font color='" + toolTipForeground + "'>CharSequence...</font></td>" +
|
||||
"<td style='padding-right: 28px;'><font color='" + red + "'>String</font></td></tr>" +
|
||||
"<tr><td/><td style='padding-left: 16px; padding-right: 24px;'/><td style='padding-right: 28px;'><font color='" + red + "'>int</font></td></tr>" +
|
||||
"<tr><td/><td style='padding-left: 16px; padding-right: 24px;'/><td style='padding-right: 28px;'><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 testBridgeMethodOverriding() { doTest(); }
|
||||
public void testNestedWildcardsWithImplicitBounds() { doTest(); }
|
||||
public void testCallOnRawWithExplicitTypeArguments() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user