Formatter: Add feature flag for method_signature_yield#13215
Conversation
method_signature_yield disabled by defaultmethod_signature_yield
| assert_format "macro f\n yield\n {{ yield }}\nend", flags: %w[method_signature_yield] | ||
| end | ||
|
|
||
| context "does not add `&` without flag `method_signature_yield`" do |
There was a problem hiding this comment.
I'd suggest to automate it within the assert_format method.
Checking whether the code doesn't change should be sufficient.
There was a problem hiding this comment.
Checking whether the code doesn't change should be sufficient.
Not it's not.
The majority of test cases actually expects the format to change. It's just two different results with and without the flag.
Putting both in the same assert would be quite tedious.
There was a problem hiding this comment.
What I was thinking of is checking it within the same call, so first it would check the formatting expectation with the given flags and next, check if the code stays the same without applying the flags.
There was a problem hiding this comment.
I think that would be too confusing. Having separate examples is fine.
This way it's easy to remove the entire non-flag group when the flag gets enabled.
| @vars = [Set(String).new] | ||
| end | ||
|
|
||
| def flag?(flag) |
There was a problem hiding this comment.
Crystal::Program uses #has_flag?, let's use the same name here
There was a problem hiding this comment.
The macro language uses flag?... maybe we should change has_flag? 🤔
Adds support for feature flags in the formatter. So far, this is only exposed in the internal API and not the CLI.
This allows us to merge formatter changes into master without enabling them in the compiler tool yet, for the purpose of bundling multiple changes into a single release as discussed in #13002.
The only feature flag so far is
method_signature_yieldwhich guards the behaviour introduced in #12951 that adds a&to yielding methods' signatures.As a result, this behaviour is now disabled in
crystal tool formatper #13002 (comment)Specs ensure proper formatter behaviour with and without the flag.