-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Reduce duplication between code and snippet generation #3127
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
base: main
Are you sure you want to change the base?
Conversation
cucumber-core/src/main/java/io/cucumber/core/snippets/GherkinKeywordNormalizer.java
Show resolved
Hide resolved
cucumber-core/src/main/java/io/cucumber/core/codegen/GherkinKeywordNormalizer.java
Outdated
Show resolved
Hide resolved
|
Build fail with error : [ERROR] java.class.externalClassExposedInAPI: class io.cucumber.gherkin.GherkinDialect: A class from supplementary archives is used in a public capacity in the API. [io.cucumber:gherkin:jar:36.1.0] @mpkorstanje can you advice in which module should i put GherkinKeywordNormalizer class ? |
|
I'll have to think about that for a minute. It might be that we'd have to move this to the |
|
@mpkorstanje that makes perfect sense. Shifting this to the |
|
I thought about it for a while. And normalization happens in a context. In this case we want identifiers that are safe to use in Java class and package names. That context is lost if this were to be moved to the Gherkin library. |
mpkorstanje
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I've pushed some small changes while reviewing. Please do:
- Remove
capitalizefrom the public API - Add a few test for both remaining public methods.
| return language.replaceAll("[\\s-]", "_").toLowerCase(); | ||
| } | ||
|
|
||
| public static String capitalize(String str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't quite belong. Please make private and duplicate as needed.
|
@mpkorstanje done. Thanks for your review! |
Fixes #3063
🤔 What's changed?
⚡️ What's your motivation?
As seen in #3062 currently boths GenerateI18n classes for cucumber-java[8] and SnippetGenerator turn Gherkin keywords into code. This code is now duplicated 3 times over. Each with a special exception for Emoji.
🏷️ What kind of change is this?
🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)
I agree to respect and uphold the Cucumber Community Code of Conduct