Skip to content

Commit ab6cc50

Browse files
committed
feat: Warn && not supported in PCRE
1 parent b91a0f7 commit ab6cc50

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

src/DiagnosticCollection.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,17 @@ function diagnosticsRegularExpressionErrors(diagnostics: Diagnostic[], document:
556556
// https://github.com/github-linguist/linguist/blob/main/tools/grammars/pcre/pcre.go#L35
557557
pcreConstants.DUPNAMES | pcreConstants.UTF8 | pcreConstants.NEWLINE_ANYCRLF,
558558
);
559+
560+
const regexTree = trees.regexTrees.get(regexNode.id);
561+
if (regexTree) {
562+
const intersectionQuery = `;scm
563+
(character_class (literal) @literal (#match? @literal "&&"))
564+
`;
565+
const intersectionCaptures = queryNode(regexTree.rootNode, intersectionQuery);
566+
if (intersectionCaptures.length) {
567+
errorCodePCRE = 'Character Class Intersection "&&" is not supported';
568+
}
569+
}
559570
}
560571
} catch (error: any) {
561572
errorCodePCRE = error?.message || String(error);

0 commit comments

Comments
 (0)