mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
quick documentation: fix formatting stripping html tags (IDEA-118673)
This commit is contained in:
@@ -71,7 +71,9 @@ public class JavaDocInfoGenerator {
|
||||
@NonNls private static final String INHERITDOC_TAG = "inheritDoc";
|
||||
@NonNls private static final String DOCROOT_TAG = "docRoot";
|
||||
@NonNls private static final String VALUE_TAG = "value";
|
||||
|
||||
private static final String LT = "<";
|
||||
private static final String GT = ">";
|
||||
|
||||
private final Project myProject;
|
||||
private final PsiElement myElement;
|
||||
|
||||
@@ -732,7 +734,7 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
|
||||
final String typeParamsString = generateTypeParameters(method);
|
||||
indent += typeParamsString.length();
|
||||
indent += StringUtil.unescapeXml(StringUtil.stripHtml(typeParamsString, true)).length();
|
||||
if (!typeParamsString.isEmpty()) {
|
||||
buffer.append(typeParamsString);
|
||||
buffer.append(" ");
|
||||
@@ -1083,8 +1085,8 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
|
||||
private static void appendPlainText(@NonNls String text, final StringBuilder buffer) {
|
||||
text = text.replaceAll("<", "<");
|
||||
text = text.replaceAll(">", ">");
|
||||
text = text.replaceAll("<", LT);
|
||||
text = text.replaceAll(">", GT);
|
||||
|
||||
buffer.append(text);
|
||||
}
|
||||
@@ -1540,12 +1542,12 @@ public class JavaDocInfoGenerator {
|
||||
buffer.append("<font color=red>");
|
||||
buffer.append(label);
|
||||
buffer.append("</font>");
|
||||
return label.length();
|
||||
return StringUtil.stripHtml(label, true).length();
|
||||
}
|
||||
|
||||
|
||||
generateLink(buffer, target, label, plainLink);
|
||||
return label.length();
|
||||
return StringUtil.stripHtml(label, true).length();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1605,9 +1607,10 @@ public class JavaDocInfoGenerator {
|
||||
PsiSubstitutor psiSubst = result.getSubstitutor();
|
||||
|
||||
if (psiClass == null) {
|
||||
String text = "<font color=red>" + StringUtil.escapeXml(type.getCanonicalText()) + "</font>";
|
||||
String canonicalText = type.getCanonicalText();
|
||||
String text = "<font color=red>" + StringUtil.escapeXml(canonicalText) + "</font>";
|
||||
buffer.append(text);
|
||||
return text.length();
|
||||
return canonicalText.length();
|
||||
}
|
||||
|
||||
String qName = psiClass.getQualifiedName();
|
||||
@@ -1632,7 +1635,8 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
PsiTypeParameter[] params = psiClass.getTypeParameters();
|
||||
|
||||
subst.append("<");
|
||||
subst.append(LT);
|
||||
length += 1;
|
||||
boolean goodSubst = true;
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
PsiType t = psiSubst.substitute(params[i]);
|
||||
@@ -1649,7 +1653,8 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
subst.append(">");
|
||||
subst.append(GT);
|
||||
length += 1;
|
||||
if (goodSubst) {
|
||||
String text = subst.toString();
|
||||
|
||||
@@ -1662,9 +1667,10 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
if (type instanceof PsiDisjunctionType || type instanceof PsiIntersectionType) {
|
||||
if (!generateLink) {
|
||||
final String text = StringUtil.escapeXml(type.getCanonicalText());
|
||||
String canonicalText = type.getCanonicalText();
|
||||
final String text = StringUtil.escapeXml(canonicalText);
|
||||
buffer.append(text);
|
||||
return text.length();
|
||||
return canonicalText.length();
|
||||
}
|
||||
else {
|
||||
final String separator = type instanceof PsiDisjunctionType ? " | " : " & ";
|
||||
@@ -1697,7 +1703,7 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append("<");
|
||||
buffer.append(LT);
|
||||
|
||||
for (int i = 0; i < parms.length; i++) {
|
||||
PsiTypeParameter p = parms[i];
|
||||
@@ -1723,7 +1729,7 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(">");
|
||||
buffer.append(GT);
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://Producer"><code>Producer</code></a></b></small><PRE><E extends <a href="psi_element://java.lang.Exception"><code>Exception</code></a>> void <b>drainTo</b>(<a href="psi_element://Consumer"><code>Consumer</code></a><? super T, E> consumer,
|
||||
<a href="psi_element://java.lang.Object"><code>Object</code></a> someParameter)
|
||||
throws <a href="psi_element://E"><code>E</code></a></PRE><DD><DL><DT><b>Throws:</b><DD><a href="psi_element://E"><code>E</code></a></DD></DL></DD></body></html>
|
||||
@@ -0,0 +1,12 @@
|
||||
interface Producer<T> {
|
||||
|
||||
<E extends Exception> void drainTo( Consumer<? super T, E> consumer, Object someParameter ) throws E;
|
||||
|
||||
}
|
||||
|
||||
interface Consumer<T, E extends Exception> {
|
||||
|
||||
void consume( T message ) throws E;
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
public void testMethodFormatting() throws Exception {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
public void testInitializerWithNew() throws Exception {
|
||||
doTestField();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user