swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.55k stars 231 forks source link

Add cli options for passing experimental features to swift-syntax #875

Closed rauhul closed 2 weeks ago

rauhul commented 2 weeks ago

See title, when trying to format code using value generics, I had to patch the formatter to pass .valueGenerics to swift-syntax instead of being able to use a CLI flag.

ahoppen commented 2 weeks ago

Synced to Apple’s issue tracker as rdar://139474306

allevato commented 2 weeks ago

@ahoppen I was planning to take a look at this soon. I could do it entirely inside swift-format, but since ExperimentalFeatures is just a bitmask, we'd have to manually keep the string names consistent.

So I'm thinking of updating swift-syntax codegen to generate an ExperimentalFeature.init?(String) initializer that we could use. The initializer isn't really needed by swift-syntax itself but it would at least ensure that they're always in sync.

Thoughts?

allevato commented 2 weeks ago

I've created https://github.com/swiftlang/swift-syntax/pull/2895 for the bits needed to translate the strings to option set values.