Comments (4)
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:
A(?<Special-String> non-optional) pattern
Would be capturing when used with Cucumber, but non capturing in the Language Server. And while it is unlikely a user may have guessed Special-String
, it is an indication that this abstraction is leaking.
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 Special-String
should not be used in production code. So consider generating a different regex patterns when transforming the AST to a Cucumber expression while using the langue server.
This may require some refactoring.
from cucumber-expressions.
I wrote in cucumber/language-service#57 that we could change TreeRegexp
. After thinking about it a bit more, I think the correct place to do this is in rewriteOptional
:
We could pass a makeOptionalGroup: (regex: string, count: number) => string
constructor argument to CucumberExpression
(defaulting to this:
(regex, count) => `(?:${regex})?`
That way, the language server could pass its own:
(regex, count) => `(?<optional-${count}>${regex})`
from cucumber-expressions.
That interface is very language server specific.
For example:
- count is not a concept that occurs in cucumber expressions. It exists only for the language server.
- This only and specifically replaces optionals.
Ideally we define the Cucumber expression API in its own domain terms.
So I think some refactoring is in order.
from cucumber-expressions.
It does come to mind that currently we also assume that all capture groups are parameters. If you write optionals as capturing then match
won't work anymore.
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 CucumberExpression
.
from cucumber-expressions.
Related Issues (20)
- java: Not all tests are executed HOT 1
- Remove Python example illustrating how to define parameter types HOT 2
- more powerful optional text HOT 12
- Allow free-form text in optionals HOT 1
- Expression for an argument list HOT 4
- Improve Expression creation performance HOT 2
- Use action-publish-pypi in cucumber-expressions
- Optimize Cucumber expression creation in .Net implementation
- Action Required: Fix Renovate Configuration
- Bad CucumberExpression creation performance HOT 6
- Golang big.Float is not a big decimal HOT 12
- Feature: named capture groups HOT 13
- Missing source for source map
- RegEx "expressions" and defineParameterType feature file examples ?
- Add the ability to ignore a cucumber expression parameter just like a non capturing regex HOT 12
- Nested capture groups are not passed to custom param definition transformer HOT 8
- `end` as a method name / prop can cause some issues HOT 4
- LICENSE file is empty HOT 1
- Typo in error message for use of alternation inside an optional
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cucumber-expressions.