mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
WI-52566 allow duplicated named subpatterns when J modifier is present
GitOrigin-RevId: 02644c6d0da294dd333c374cbe6d81eafe7c4ca8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
751c792a09
commit
aad83a3f2e
@@ -17,6 +17,9 @@ public interface RegExpLanguageHost {
|
||||
boolean characterNeedsEscaping(char c);
|
||||
boolean supportsPerl5EmbeddedComments();
|
||||
boolean supportsPossessiveQuantifiers();
|
||||
default boolean isDuplicateGroupNamesAllowed(@NotNull RegExpGroup group) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true, if this dialects support conditionals, i.e. the following construct: {@code (?(1)then|else)}
|
||||
|
||||
@@ -111,6 +111,11 @@ public final class RegExpLanguageHosts extends ClassExtension<RegExpLanguageHost
|
||||
return host != null && host.isValidGroupName(name, group);
|
||||
}
|
||||
|
||||
public boolean isDuplicateGroupNamesAllowed(@NotNull final RegExpGroup group) {
|
||||
final RegExpLanguageHost host = findRegExpHost(group);
|
||||
return host != null && host.isDuplicateGroupNamesAllowed(group);
|
||||
}
|
||||
|
||||
public boolean supportsPerl5EmbeddedComments(@Nullable final PsiComment comment) {
|
||||
final RegExpLanguageHost host = findRegExpHost(comment);
|
||||
return host != null && host.supportsPerl5EmbeddedComments();
|
||||
|
||||
@@ -270,7 +270,7 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
|
||||
final AnnotationSession session = myHolder.getCurrentAnnotationSession();
|
||||
final Map<String, RegExpGroup> namedGroups = NAMED_GROUP_MAP.get(session, new HashMap<>());
|
||||
if (namedGroups.isEmpty()) session.putUserData(NAMED_GROUP_MAP, namedGroups);
|
||||
if (namedGroups.put(name, group) != null) {
|
||||
if (namedGroups.put(name, group) != null && !myLanguageHosts.isDuplicateGroupNamesAllowed(group)) {
|
||||
final ASTNode node = group.getNode().findChildByType(RegExpTT.NAME);
|
||||
if (node != null) myHolder.newAnnotation(HighlightSeverity.ERROR,
|
||||
RegExpBundle.message("error.group.with.name.0.already.defined", name)).range(node).create();
|
||||
|
||||
Reference in New Issue
Block a user