mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-38470: highlight unicode property escapes if not supported in dialect (JS before ES6, non-unicode regexps)
GitOrigin-RevId: 1a92beb95a2e7b868ef57ab0e1e24bedc1bcb134
This commit is contained in:
committed by
intellij-monorepo-bot
parent
44239585c3
commit
3d7bdf7977
@@ -106,6 +106,10 @@ public interface RegExpLanguageHost {
|
||||
return EMPTY_COMPLETION_ITEMS_ARRAY;
|
||||
}
|
||||
|
||||
default boolean supportsPropertySyntax(@NotNull PsiElement context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
enum Lookbehind {
|
||||
/** Lookbehind not supported. */
|
||||
NOT_SUPPORTED,
|
||||
|
||||
@@ -94,6 +94,11 @@ public final class RegExpLanguageHosts extends ClassExtension<RegExpLanguageHost
|
||||
return host != null && host.supportsLiteralBackspace(regExpChar);
|
||||
}
|
||||
|
||||
public boolean supportsPropertySyntax(@NotNull PsiElement context) {
|
||||
RegExpLanguageHost host = findRegExpHost(context);
|
||||
return host != null && host.supportsPropertySyntax(context);
|
||||
}
|
||||
|
||||
public boolean supportsNamedGroupSyntax(@Nullable final RegExpGroup group) {
|
||||
final RegExpLanguageHost host = findRegExpHost(group);
|
||||
return host != null && host.supportsNamedGroupSyntax(group);
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ public class EcmaScriptRegexpParserDefinition extends RegExpParserDefinition {
|
||||
private final EnumSet<RegExpCapability> CAPABILITIES = EnumSet.of(RegExpCapability.OCTAL_NO_LEADING_ZERO,
|
||||
RegExpCapability.DANGLING_METACHARACTERS,
|
||||
RegExpCapability.ALLOW_EMPTY_CHARACTER_CLASS,
|
||||
RegExpCapability.PROPERTY_VALUES,
|
||||
RegExpCapability.MAX_OCTAL_377);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -219,6 +219,10 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
|
||||
if (category == null) {
|
||||
return;
|
||||
}
|
||||
if (!myLanguageHosts.supportsPropertySyntax(property)) {
|
||||
myHolder.createErrorAnnotation(property, "Property escape sequences are not supported in this regex dialect");
|
||||
return;
|
||||
}
|
||||
String propertyName = category.getText();
|
||||
if(!myLanguageHosts.isValidCategory(category.getPsi(), propertyName)) {
|
||||
final Annotation a = myHolder.createErrorAnnotation(category, "Unknown character category");
|
||||
|
||||
Reference in New Issue
Block a user