-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return optionals as part of a Cucumber Expression match #125
Comments
Currently you can not assign special meaning to groups because every possible regex generated by a Cucumber expression is also a regular valid regular regex that may be provided by a user. For example the regex:
Would be capturing when used with Cucumber, but non capturing in the Language Server. And while it is unlikely a user may have guessed Now I'm not opposed to adding named group support to the tree regex. These names could be used when generating step definitions based of regular regexes for example. However the proposed This may require some refactoring. |
I wrote in cucumber/language-service#57 that we could change
We could pass a (regex, count) => `(?:${regex})?` That way, the language server could pass its own: (regex, count) => `(?<optional-${count}>${regex})` |
That interface is very language server specific. For example:
Ideally we define the Cucumber expression API in its own domain terms. So I think some refactoring is in order. |
It does come to mind that currently we also assume that all capture groups are parameters. If you write optionals as capturing then Maybe you can extract the code that rewrites the AST, add support for named groups to tree-regex and then use those in a class that is not |
🤔 What's the problem you're trying to solve?
I want to provide syntax highlighting (LSP semantic tokens) for the parts of a Gherkin step that is optional in the corresponding Cucumber Expression.
✨ What's your proposed solution?
Use named capture groups for optionals, as explained in cucumber/language-service#57
The return type of
match
would change fromArgument[] | null
toMatch | null
:⛏ Have you considered any alternatives or workarounds?
If we want to support this, I can't think of any other option.
The text was updated successfully, but these errors were encountered: