don't warn on empty regexp element

This commit is contained in:
Bas Leijdekkers
2017-02-13 20:34:41 +01:00
parent 0f36864435
commit 5703d46f06
2 changed files with 7 additions and 0 deletions
@@ -56,6 +56,9 @@ public class DuplicateAlternationBranchInspection extends LocalInspectionTool {
final RegExpBranch[] branches = pattern.getBranches();
for (int i = 0; i < branches.length - 1; i++) {
final RegExpBranch branch1 = branches[i];
if (branch1.getAtoms().length == 0) {
continue;
}
for (int j = i + 1; j < branches.length; j++) {
final RegExpBranch branch2 = branches[j];
if (RegExpEquivalenceChecker.areElementsEquivalent(branch1, branch2)) {
@@ -35,6 +35,10 @@ public class DuplicateAlternationBranchInspectionTest extends RegExpInspectionTe
highlightTest("<warning descr=\"Duplicate branch in alternation\">[abc]</warning>|<warning descr=\"Duplicate branch in alternation\">[cba]</warning>");
}
public void testEmptyBranches() {
highlightTest("|||");
}
@NotNull
@Override
protected LocalInspectionTool getInspection() {