mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
regex: \# is not a redundant escape in comment mode (IDEA-221089)
GitOrigin-RevId: ff2e9337cdf051134b088a7f32a732b5c27798fa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c495851647
commit
d6d3d67404
File diff suppressed because it is too large
Load Diff
@@ -381,6 +381,7 @@ BACK_REFERENCES_GROUP = [1-9][0-9]{0,2}
|
||||
}
|
||||
|
||||
{ESCAPE} [A-Za-z] { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; }
|
||||
{ESCAPE} "#" { return commentMode ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
|
||||
{ESCAPE} {ANY} { return RegExpTT.REDUNDANT_ESCAPE; }
|
||||
{ESCAPE} { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; }
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// 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;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
@@ -733,6 +733,15 @@ public class RegExpLexerTest extends LexerTestCase {
|
||||
"ESC_CHARACTER ('\\^')", lexer);
|
||||
}
|
||||
|
||||
public void testPoundSign() {
|
||||
final RegExpLexer lexer = new RegExpLexer(EnumSet.noneOf(RegExpCapability.class));
|
||||
doTest("\\#(?x)\\#", "REDUNDANT_ESCAPE ('\\#')\n" +
|
||||
"SET_OPTIONS ('(?')\n" +
|
||||
"OPTIONS_ON ('x')\n" +
|
||||
"GROUP_END (')')\n" +
|
||||
"ESC_CHARACTER ('\\#')", lexer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Lexer createLexer() {
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// 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.inspection;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
@@ -29,6 +29,10 @@ public class RedundantEscapeInspectionTest extends RegExpInspectionTestCase {
|
||||
new RegExpFileType(EcmaScriptRegexpLanguage.INSTANCE));
|
||||
}
|
||||
|
||||
public void testPoundSign() {
|
||||
highlightTest("<warning descr=\"Redundant character escape '\\#' in RegExp\">\\#</warning>(?x)\\#");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool getInspection() {
|
||||
|
||||
Reference in New Issue
Block a user