Skip to content

Add a new change that can replace a note #2298

Closed as not planned
Closed as not planned
@kimdv

Description

@kimdv

Description

From #2286 (comment)

Hmm, it’s not easily possible in the current design where we assume all nodes for the Fix-It to already be present in the syntax tree so that we just need to flip the token presence.

I would say that it’s good enough for now but adding support for these kinds of Fix-Its might be useful in general. What we need for that is, IMO, a new Fixit.Change that takes a syntax node, a key path within that node and a replacement node, i.e. something like case replace<NodeType, ChildType>(node: NodeType, path: KeyPath<NodeType, ChildType>, child: ChildType) – and yes I see the irony of declaring a generic enum case here, you would need to come up with some design that actually compiles, I haven’t thought about it too much yet.

I think this kind of Fix-It change might also be useful for macro authors. IIRC it came up once or twice but was never super important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SwiftParserBugs in the (new) Parser written in SwiftenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions