mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
java text blocks: check invalid escape sequence (IDEA-217352)
GitOrigin-RevId: dcf0b4fc8d16a82d6e8adbcab9004422668598ee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c077ae9cc0
commit
8cb91e1346
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.ContainerProvider;
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.codeInsight.JavaModuleSystemEx;
|
||||
@@ -1193,6 +1194,16 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
|
||||
}
|
||||
}
|
||||
StringBuilder chars = new StringBuilder();
|
||||
boolean success = CodeInsightUtilCore.parseStringCharacters(text, chars, null);
|
||||
if (!success) {
|
||||
String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal");
|
||||
TextRange textRange = chars.length() < text.length() - 1 ? new TextRange(chars.length(), chars.length() + 1)
|
||||
: expression.getTextRange();
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(expression, textRange)
|
||||
.descriptionAndTooltip(message).create();
|
||||
}
|
||||
}
|
||||
|
||||
if (value instanceof Float) {
|
||||
|
||||
@@ -4,4 +4,8 @@ class C {
|
||||
String invalid1 = <error descr="Illegal text block start: missing new line after opening quotes">""""""</error>;
|
||||
String invalid2 = <error descr="Illegal text block start: missing new line after opening quotes">""" """</error>;
|
||||
String invalid3 = <error descr="Illegal text block start: missing new line after opening quotes">"""\\n """</error>;
|
||||
String invalid4 = """
|
||||
invalid escape <error descr="Illegal escape character in string literal">\</error>
|
||||
continue;
|
||||
""";
|
||||
}
|
||||
Reference in New Issue
Block a user