swiftlang / swift-syntax

A set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code.
Apache License 2.0
3.24k stars 413 forks source link

Support functional decomposition of code blocks #470

Closed tachyonics closed 2 years ago

tachyonics commented 2 years ago

Feature Request: Support functional decomposition of code blocks

Description

Being able to decompose code blocks into separate functions can improve code readability and reuse.

Motivation

Allow developers to decompose code blocks into different functions.

Importance

This will allow for cleaner and more modular code.

Example: https://github.com/amzn/smoke-framework-application-generate/blob/swift_syntax/Sources/SmokeFrameworkCodeGeneration/ServiceModelCodeGenerator%2BgenerateHandlerSelector.swift#L64

Alternatives Considered

I have tested this ability with the following change- https://github.com/tachyonics/swift-syntax/commit/27c159b653fce0783aa612a56fa4d3e5fdda5a16

However I hadn't created a pull request on this change immediately as I am looking for guidance on if this change is a good idea, if there is some other way to achieve this or if this is the best way to incorporate it into the repository.

ahoppen commented 2 years ago

I think what you are asking for is exactly what is being fixed by https://github.com/apple/swift-syntax/pull/462, right?

tachyonics commented 2 years ago

Yes, exactly. Thanks for point that out.

I'll resolve this in favour of the change in #462.