swiftlang / swiftlang/swift-syntax

Further generalize parse diagnostics functions

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

Description

### Description

#2731 has embarked on the generalization of parse diagnostics functions. It was driven by the necessity of manipulating a whole `TypeSyntax` (the thrown type) instead of discrete `TokenSyntax`s which the functions were originally designed for.

The refactoring effort stopped at generalizing `ParseDiagnosticsGenerator.exchangeTokens` into `ParseDiagnosticsGenerator.exchangeNodes` that has relaxed the accepted input type from `TokenSyntax` to `Syntax`. However several implementations of `ParserError` such as `EffectsSpecifierAfterArrow`, and implementations of `ParserFixIt` such as `MoveTokensAfterFixIt` that constitute `Diagnostic` still expect `TokenSyntax`. More importantly, `nodesDescriptionAndCommonParent`, the common utility function responsible for rendering several messages in the diagnostic, expects a list of `TokenSyntax` as its input.

We should continue refactoring on these functions to further improve generality.

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.