feat(pattern): support alternation syntax in command name position#91
feat(pattern): support alternation syntax in command name position#91
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #91 +/- ##
==========================================
+ Coverage 88.78% 88.82% +0.03%
==========================================
Files 29 29
Lines 5705 5707 +2
==========================================
+ Hits 5065 5069 +4
+ Misses 640 638 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of ChangesHello @fohte, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the pattern matching capabilities by introducing support for alternation syntax in the command name position. This allows users to define a single pattern that can match multiple command aliases, significantly reducing redundancy and simplifying pattern definitions for tools with aliased commands. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for alternation syntax in the command name position of patterns, allowing rules to apply to multiple command aliases (e.g., "ast-grep|sg"). The changes include adding a new Alternation variant to the CommandPattern enum, updating the matches logic, and integrating it into the parse function. New parameterized tests have been added to cover this functionality, ensuring correctness and adherence to the testing style guide by naming #[case] variants and using rstest effectively. The implementation is clean and directly addresses the stated goal of improving pattern flexibility.
Why
|(alternation) syntax in the command name position of patternsast-grepandsg) currently require duplicating the same rule on two separate linesWhat