swiftlang / swiftlang/swift-syntax

[Diagnostics] Intra-group trivia not preserved when moving a node group

Open
#2,850 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
3.7k
Forks
553
Avg merge
5d 13h
Merged PRs (30d)
16

Description

### Description

When a Fix-it moves a group of consecutive nodes, the intra-group trivia won't be preserved,
```swift
func test() -> throws(any /**/ Error) Int
// after Fix-it
func test() throws(any Error) -> Int
```
It's because the nodes aren't actually "moved" when applying a Fix-it. Rather the misplaced nodes carrying the trivia are removed, and the missing nodes created by the parser (without the trivia) are presented at the designated site.

Currently trivia at the sides of a node group to move are transferred to its adjacent tokens, we should create facilities to transfer intra-group trivia from the misplaced nodes to the missing nodes.

### Steps to Reproduce

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.