Open
Description
Currently, if you do the following
let node = EnumCaseParameterSyntax(firstName: "label", type: TypeSyntax("MyType"))
print(node.formatted())
you get label MyType
, which is surprising because the colon is missing and you would expect the colon to be present if there is a first name of the enum case parameter.
To fix this, we should add a hand-written initializer of EnumCaseParameterSyntax
, which takes a non-optional firstName
and automatically adds a colon, because it knows that the firstName
exists. The above call would pick that overload and thus add a colon.
And the same strategy can also be applied
- to other nodes that have an optional colon
ClosureCaptureSyntax.equal
- to automatically add parentheses for the following nodes if arguments are present
AttributeSyntax
MacroExpansionDeclSyntax
ClosureCaptureModifierSyntax
FunctionCallExprSyntax
FreestandingMacroExpansionSyntax
rdar://107794232