mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-138967 \unnnn notation doesn't work in quick docs
This commit is contained in:
@@ -1269,7 +1269,7 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
}
|
||||
else {
|
||||
buffer.append(element.getText());
|
||||
buffer.append(StringUtil.replaceUnicodeEscapeSequences(element.getText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1291,7 +1291,7 @@ public class JavaDocInfoGenerator {
|
||||
text = text.replaceAll("<", LT);
|
||||
text = text.replaceAll(">", GT);
|
||||
|
||||
buffer.append(text);
|
||||
buffer.append(StringUtil.replaceUnicodeEscapeSequences(text));
|
||||
}
|
||||
|
||||
private static void generateLinkValue(PsiInlineDocTag tag, StringBuilder buffer, boolean plainLink) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<html><head><base href="placeholder"> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><PRE>class <b>Pattern</b>
|
||||
extends <a href="psi_element://java.lang.Object"><code>Object</code></a></PRE>
|
||||
\W \u03A9</body></html>
|
||||
\W \n</body></html>
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \W \u03A9
|
||||
* \W \n
|
||||
*/
|
||||
class Pattern {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<html><head><base href="placeholder"> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><PRE>class <b>Test</b>
|
||||
extends <a href="psi_element://java.lang.Object"><code>Object</code></a></PRE>
|
||||
a@b c@d</body></html>
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* a\u0040b {@literal c\u0040d}
|
||||
*/
|
||||
class Test {}
|
||||
@@ -77,6 +77,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
|
||||
verifyJavaDoc(getTestClass());
|
||||
}
|
||||
|
||||
public void testUnicodeEscapes() throws Exception {
|
||||
verifyJavaDoc(getTestClass());
|
||||
}
|
||||
|
||||
public void testEnumValueOf() throws Exception {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
@@ -3169,6 +3169,28 @@ public class StringUtil extends StringUtilRt {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static final Pattern UNICODE_CHAR = Pattern.compile("\\\\u[0-9a-eA-E]{4}");
|
||||
|
||||
public static String replaceUnicodeEscapeSequences(String text) {
|
||||
if (text == null) return null;
|
||||
|
||||
final Matcher matcher = UNICODE_CHAR.matcher(text);
|
||||
if (!matcher.find()) return text; // fast path
|
||||
|
||||
matcher.reset();
|
||||
int lastEnd = 0;
|
||||
final StringBuilder sb = new StringBuilder(text.length());
|
||||
while (matcher.find()) {
|
||||
sb.append(text.substring(lastEnd, matcher.start()));
|
||||
final char c = (char)Integer.parseInt(matcher.group().substring(2), 16);
|
||||
sb.append(c);
|
||||
lastEnd = matcher.end();
|
||||
}
|
||||
sb.append(text.substring(lastEnd, text.length()));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Expirable CharSequence. Very useful to control external library execution time,
|
||||
* i.e. when java.util.regex.Pattern match goes out of control.
|
||||
|
||||
Reference in New Issue
Block a user