mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 06:21:25 +07:00
[platform] illegal character highlighting: updated message and test data (IDEA-CR-10947)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
class C {
|
||||
void m() {
|
||||
f(1,<error descr="Expression expected"><error descr="Illegal character: \u00A0"> </error></error><error descr="',' or ')' expected">2</error>);
|
||||
f(1,<error descr="Expression expected"><error descr="Illegal character: U+00A0"> </error></error><error descr="',' or ')' expected">2</error>);
|
||||
}
|
||||
|
||||
void f(int x, int y) {
|
||||
if (x == 0 ||<error descr="')' expected"><error descr="Expression expected"><error descr="Illegal character: \u00A0"> </error></error></error>y == 0<error descr="';' expected"><error descr="Unexpected token">)</error></error> { }
|
||||
if (x == 0 ||<error descr="')' expected"><error descr="Expression expected"><error descr="Illegal character: U+00A0"> </error></error></error>y == 0<error descr="';' expected"><error descr="Unexpected token">)</error></error> { }
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.ErrorQuickFixProvider;
|
||||
@@ -96,8 +95,11 @@ class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
else {
|
||||
ASTNode node = element.getNode();
|
||||
if (node != null && node.getElementType() == TokenType.BAD_CHARACTER) {
|
||||
String message = String.format("Illegal character: \\u%04X", (int)element.textToCharArray()[0]);
|
||||
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(message).create());
|
||||
char c = element.textToCharArray()[0];
|
||||
boolean printable = StringUtil.isPrintableUnicode(c) && !Character.isSpaceChar(c);
|
||||
String hex = String.format("U+%04X", (int)c);
|
||||
String text = "Illegal character: " + (printable ? c + " (" + hex + ")" : hex);
|
||||
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(text).create());
|
||||
}
|
||||
|
||||
if (myRunAnnotators) runAnnotators(element);
|
||||
|
||||
@@ -581,7 +581,7 @@ public class StringUtil extends StringUtilRt {
|
||||
@NotNull @NonNls StringBuilder buffer) {
|
||||
return escapeStringCharacters(length, str, additionalChars, escapeSlash, true, buffer);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static StringBuilder escapeStringCharacters(int length,
|
||||
@NotNull String str,
|
||||
@@ -639,7 +639,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
private static boolean isPrintableUnicode(char c) {
|
||||
public static boolean isPrintableUnicode(char c) {
|
||||
int t = Character.getType(c);
|
||||
return t != Character.UNASSIGNED && t != Character.LINE_SEPARATOR && t != Character.PARAGRAPH_SEPARATOR &&
|
||||
t != Character.CONTROL && t != Character.FORMAT && t != Character.PRIVATE_USE && t != Character.SURROGATE;
|
||||
@@ -796,7 +796,7 @@ public class StringUtil extends StringUtilRt {
|
||||
buffer.append("\\u");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
@@ -817,7 +817,7 @@ public class StringUtil extends StringUtilRt {
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
idx = escapeEnd - 1;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
buffer.append(ch);
|
||||
break;
|
||||
@@ -3365,7 +3365,7 @@ public class StringUtil extends StringUtilRt {
|
||||
|
||||
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
|
||||
|
||||
@@ -3381,7 +3381,7 @@ public class StringUtil extends StringUtilRt {
|
||||
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