collapse signature for inferred/external annotations tooltip

GitOrigin-RevId: 65f0d6718931cb26a30f3377b0aa896edd9c2497
This commit is contained in:
Anna Kozlova
2019-06-13 03:16:23 +03:00
committed by intellij-monorepo-bot
parent 91f7445298
commit 1c496f04ac
3 changed files with 15 additions and 12 deletions
@@ -74,6 +74,8 @@ public class AnnotationDocGenerator {
boolean red = type == null && !myResolveNotPossible && !isInferred() && !isExternal();
boolean highlightNonCodeAnnotations = format == AnnotationFormat.ToolTip && (isInferred() || isExternal());
if (highlightNonCodeAnnotations) buffer.append("<b>");
if (isInferred()) buffer.append("<i>");
if (red) buffer.append("<font color=red>");
@@ -91,6 +93,7 @@ public class AnnotationDocGenerator {
generateAnnotationAttributes(buffer, generateLink);
if (isInferred()) buffer.append("</i>");
if (highlightNonCodeAnnotations) buffer.append("</b>");
}
private void generateAnnotationAttributes(StringBuilder buffer, boolean generateLink) {
@@ -1031,15 +1031,15 @@ public class JavaDocInfoGenerator {
}
private static void generateMethodSignature(StringBuilder buffer, PsiMethod method, SignaturePlace place) {
boolean useShortNames = place == SignaturePlace.ToolTip;
boolean isTooltip = place == SignaturePlace.ToolTip;
boolean generateLink = place == SignaturePlace.Javadoc;
generateAnnotations(buffer, method, place, true);
int modLength = generateModifiers(buffer, method, true);
int modLength = isTooltip ? 0 : generateModifiers(buffer, method, true);
int indent = modLength == 0 ? 0 : modLength + 1;
String typeParamsString = generateTypeParameters(method, useShortNames);
String typeParamsString = generateTypeParameters(method, isTooltip);
indent += StringUtil.unescapeXmlEntities(StringUtil.stripHtml(typeParamsString, true)).length();
if (!typeParamsString.isEmpty()) {
buffer.append(typeParamsString);
@@ -1048,7 +1048,7 @@ public class JavaDocInfoGenerator {
}
if (method.getReturnType() != null) {
indent += generateType(buffer, method.getReturnType(), method, generateLink, useShortNames);
indent += generateType(buffer, method.getReturnType(), method, generateLink, isTooltip);
buffer.append(NBSP);
indent++;
}
@@ -1063,9 +1063,9 @@ public class JavaDocInfoGenerator {
for (int i = 0; i < parameters.length; i++) {
PsiParameter parm = parameters[i];
generateAnnotations(buffer, parm, place, false);
generateType(buffer, parm.getType(), method, generateLink, useShortNames);
buffer.append(NBSP);
if (parm.getName() != null) {
generateType(buffer, parm.getType(), method, generateLink, isTooltip);
if (parm.getName() != null && !isTooltip) {
buffer.append(NBSP);
buffer.append(parm.getName());
}
if (i < parameters.length - 1) {
@@ -1081,7 +1081,7 @@ public class JavaDocInfoGenerator {
buffer.append(THROWS_KEYWORD);
buffer.append(NBSP);
for (int i = 0; i < refs.length; i++) {
generateLink(buffer, useShortNames ? refs[i].getPresentableText() : refs[i].getCanonicalText(), null, method, false);
generateLink(buffer, isTooltip ? refs[i].getPresentableText() : refs[i].getCanonicalText(), null, method, false);
if (i < refs.length - 1) {
buffer.append(',').append(NBSP);
}
@@ -96,15 +96,15 @@ public class BytecodeAnalysisIntegrationTest extends LightCodeInsightFixtureTest
public void testInferredAnnoGutter() {
checkHasGutter("org.apache.velocity.util.ExceptionUtils",
"<html><i>Inferred</i> annotations available. Full signature:<p>\n" +
"<i>@Contract('null,_,_->null')</i> \n" +
"public static Throwable <b>createWithCause</b>(Class clazz,\n String message,\n Throwable cause)</html>");
"<b><i>@Contract('null,_,_->null')</i></b> \n" +
"Throwable <b>createWithCause</b>(Class,\n String,\n Throwable)</html>");
}
public void testExternalAnnoGutter() {
checkHasGutter("java.lang.String",
"<html>External and <i>inferred</i> annotations available. Full signature:<p>\n" +
"<i>@Contract(pure = true)</i> \n" +
"public <b>String</b>(@NotNull String var1)</html>");
"<b><i>@Contract(pure = true)</i></b> \n" +
"<b>String</b>(<b>@NotNull</b> String)</html>");
}
private void checkHasGutter(String className, String expectedText) {