escape initializer text for quick javadoc (IDEA-114911)

This commit is contained in:
anna
2013-10-21 18:34:57 +02:00
parent d86e31fff5
commit 835549ca5f
4 changed files with 11 additions and 5 deletions
@@ -605,9 +605,7 @@ public class JavaDocInfoGenerator {
boolean trunc = index < text.length();
if (trunc) {
text = text.substring(0, index);
text = StringUtil.replace(text, "<", "&lt;");
text = StringUtil.replace(text, ">", "&gt;");
buffer.append(text);
buffer.append(StringUtil.escapeXml(text));
buffer.append("...");
}
else {
@@ -1876,12 +1874,12 @@ public class JavaDocInfoGenerator {
@Override
public void visitLiteralExpression(PsiLiteralExpression expression) {
myBuffer.append(expression.getText());
myBuffer.append(StringUtil.escapeXml(expression.getText()));
}
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
myBuffer.append(expression.getText());
myBuffer.append(StringUtil.escapeXml(expression.getText()));
}
}
}
@@ -0,0 +1 @@
<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://A"><code>A</code></a></b></small><PRE>public <a href="psi_element://java.lang.String"><code>String</code></a> <b>strings = &quot;A&lt;BLANK&gt;B&quot;</b></PRE></body></html>
@@ -0,0 +1,3 @@
class A {
public String strings = "A<BLANK>B";
}
@@ -60,6 +60,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
doTestField();
}
public void testInitializerWithLiteral() throws Exception {
doTestField();
}
public void testInitializerWithReference() throws Exception {
doTestField();
}