RegExp: report error when atomic groups are not supported

This commit is contained in:
Bas Leijdekkers
2017-02-07 12:43:53 +01:00
parent 794018089a
commit 051acded35
2 changed files with 5 additions and 2 deletions
@@ -121,8 +121,8 @@ public final class RegExpLanguageHosts extends ClassExtension<RegExpLanguageHost
return host != null && host.supportsPythonConditionalRefs();
}
public boolean supportsPossessiveQuantifiers(@Nullable final RegExpQuantifier quantifier) {
final RegExpLanguageHost host = findRegExpHost(quantifier);
public boolean supportsPossessiveQuantifiers(@Nullable final RegExpElement context) {
final RegExpLanguageHost host = findRegExpHost(context);
return host == null || host.supportsPossessiveQuantifiers();
}
@@ -280,6 +280,9 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
myHolder.createErrorAnnotation(group, "This named group syntax is not supported");
}
}
if (group.getType() == RegExpGroup.Type.ATOMIC && !myLanguageHosts.supportsPossessiveQuantifiers(group)) {
myHolder.createErrorAnnotation(group, "Atomic groups are not supported in this regex dialect");
}
final String name = group.getName();
if (name != null && !myLanguageHosts.isValidGroupName(name, group)) {
final ASTNode node = group.getNode().findChildByType(RegExpTT.NAME);