mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RegExp: Escape ] correctly if it was unnecessarily escaped before (IDEA-195762)
This commit is contained in:
+7
-1
@@ -105,7 +105,13 @@ public class SingleCharAlternationInspection extends LocalInspectionTool {
|
||||
final RegExpChar ch = (RegExpChar)child;
|
||||
final IElementType type = ch.getNode().getFirstChildNode().getElementType();
|
||||
if (type == RegExpTT.REDUNDANT_ESCAPE) {
|
||||
text.append((char)ch.getValue());
|
||||
final int value = ch.getValue();
|
||||
if (value == ']') {
|
||||
text.append(ch.getUnescapedText());
|
||||
}
|
||||
else {
|
||||
text.append((char)value);
|
||||
}
|
||||
}
|
||||
else if (type == RegExpTT.ESC_CHARACTER) {
|
||||
final int value = ch.getValue();
|
||||
|
||||
+4
@@ -39,6 +39,10 @@ public class SingleCharAlternationInspectionTest extends RegExpInspectionTestCas
|
||||
"([.\\[\\](){}^?*|+\\-$])ab", "Replace with '[.\\[\\](){}^?*|+\\-$]'");
|
||||
}
|
||||
|
||||
public void testRedundantEscapeReplacement() {
|
||||
quickfixTest("(<warning descr=\"Single character alternation in RegExp\">\\[<caret>|\\]</warning>)", "([\\[\\]])", "Replace with '[\\[\\]]");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool getInspection() {
|
||||
|
||||
Reference in New Issue
Block a user