mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-52291
This commit is contained in:
@@ -19,6 +19,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface RegExpGroup extends RegExpAtom {
|
||||
boolean isCapturing();
|
||||
|
||||
boolean isSimple();
|
||||
|
||||
@Nullable
|
||||
RegExpPattern getPattern();
|
||||
|
||||
@@ -37,6 +37,11 @@ public class RegExpGroupImpl extends RegExpElementImpl implements RegExpGroup {
|
||||
return node != null && node.getElementType() == RegExpTT.GROUP_BEGIN;
|
||||
}
|
||||
|
||||
public boolean isSimple() {
|
||||
final ASTNode node = getNode().getFirstChildNode();
|
||||
return node != null && (node.getElementType() == RegExpTT.GROUP_BEGIN || node.getElementType() == RegExpTT.NON_CAPT_GROUP);
|
||||
}
|
||||
|
||||
public RegExpPattern getPattern() {
|
||||
final ASTNode node = getNode().findChildByType(RegExpElementTypes.PATTERN);
|
||||
return node != null ? (RegExpPattern)node.getPsi() : null;
|
||||
|
||||
@@ -155,7 +155,12 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
|
||||
} else if (branches.length == 1) {
|
||||
final RegExpAtom[] atoms = branches[0].getAtoms();
|
||||
if (atoms.length == 1 && atoms[0] instanceof RegExpGroup) {
|
||||
myHolder.createWarningAnnotation(group, "Redundant group nesting");
|
||||
if (group.isSimple()) {
|
||||
final RegExpGroup innerGroup = (RegExpGroup)atoms[0];
|
||||
if (group.isCapturing() == innerGroup.isCapturing()) {
|
||||
myHolder.createWarningAnnotation(group, "Redundant group nesting");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -990,4 +990,11 @@
|
||||
<expected>OK</expected>
|
||||
</test>
|
||||
</bug>
|
||||
|
||||
<bug id="IDEA-52291">
|
||||
<test>
|
||||
<pattern>(^|\.)\*(?=(\.|$))</pattern>
|
||||
<expected>OK</expected>
|
||||
</test>
|
||||
</bug>
|
||||
</tests>
|
||||
|
||||
Reference in New Issue
Block a user