regex: escaped closing square bracket is not redundant for JS Unicode Regex (WEB-45812)

GitOrigin-RevId: 9e6a4180d995f96937954318bfbb01aff525cbce
This commit is contained in:
Bas Leijdekkers
2020-06-01 17:31:34 +03:00
committed by intellij-monorepo-bot
parent 934ecb2f45
commit d75cacfaa2
4 changed files with 372 additions and 361 deletions
File diff suppressed because it is too large Load Diff
@@ -253,6 +253,7 @@ BACK_REFERENCES_GROUP = [1-9][0-9]{0,2}
{ESCAPE} {LBRACE} { return (allowDanglingMetacharacters != TRUE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {RBRACE} { return (allowDanglingMetacharacters == FALSE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {RBRACKET} { return (allowDanglingMetacharacters != TRUE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {META2} { return RegExpTT.ESC_CHARACTER; }
}
{ESCAPE} {META1} { return RegExpTT.ESC_CHARACTER; }
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// Copyright 2000-2020 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 org.intellij.lang.regexp.ecmascript;
import com.intellij.openapi.application.ex.PathManagerEx;
@@ -33,6 +33,11 @@ public class EcmaScriptRegExpParsingTest extends ParsingTestCase {
doCodeTest("]");
}
public void testEscapedMetaCharacter() throws IOException {
//noinspection RegExpRedundantEscape
doCodeTest("\\]");
}
public void testExtendedUnicode() throws IOException {
doCodeTest("\\u{9}");
}
@@ -0,0 +1,5 @@
JS_UNICODE_REGEXP_FILE
RegExpPatternImpl: <\]>
RegExpBranchImpl: <\]>
RegExpCharImpl: <\]>
PsiElement(ESC_CHARACTER)('\]')