mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RegExp: warn about duplicate char in character class with intersection (IJPL-193556)
for "Duplicate character in character class" inspection GitOrigin-RevId: 455aff90e2c52c735df582fced65225b5ecbb2f0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9744fab524
commit
0498719d54
+7
-1
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.intellij.lang.regexp.inspection;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
@@ -63,6 +63,12 @@ public class DuplicateCharacterInClassInspection extends LocalInspectionTool {
|
||||
new DuplicateCharacterInClassFix(regExpSimpleClass));
|
||||
}
|
||||
}
|
||||
else if (element instanceof RegExpIntersection intersection) {
|
||||
final HashSet<Object> visited = new HashSet<>();
|
||||
for (RegExpClassElement operand : intersection.getOperands()) {
|
||||
checkForDuplicates(operand, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.intellij.lang.regexp.inspection;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
@@ -8,6 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
@SuppressWarnings("RegExpDuplicateCharacterInClass")
|
||||
public class DuplicateCharacterInClassInspectionTest extends RegExpInspectionTestCase {
|
||||
|
||||
public void testPredefinedCharacterClass() {
|
||||
@@ -34,6 +35,10 @@ public class DuplicateCharacterInClassInspectionTest extends RegExpInspectionTes
|
||||
public void testNestedClass() {
|
||||
highlightTest("[<[^<>]*>]*<[^<>]*");
|
||||
}
|
||||
|
||||
public void testIntersection() {
|
||||
highlightTest("[\\w<warning descr=\"Duplicate predefined character class '\\w' inside character class\">\\w</warning>&&[^_]]");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull LocalInspectionTool getInspection() {
|
||||
|
||||
Reference in New Issue
Block a user