Skip to content

Commit 3345082

Browse files
committed
Fix attempt
1 parent f47c7b2 commit 3345082

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Sources/SwiftParserDiagnostics/MissingNodesError.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ func nodesDescriptionAndCommonParent<SyntaxType: SyntaxProtocol>(_ nodes: [Synta
120120
let firstToken = commonAncestor.firstToken(viewMode: .all),
121121
let lastToken = commonAncestor.lastToken(viewMode: .all),
122122
missingSyntaxNodes.contains(Syntax(firstToken)),
123-
missingSyntaxNodes.contains(Syntax(lastToken)),
124-
nodes.only?.as(TokenSyntax.self)?.text != nil
123+
missingSyntaxNodes.contains(Syntax(lastToken))
125124
{
126125
if let nodeTypeName = commonAncestor.nodeTypeNameForDiagnostics(allowBlockNames: true) {
127126
return (commonAncestor, nodeTypeName)

Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ public struct ReplaceTokensFixIt: ParserFixIt {
614614
public let replacements: [TokenSyntax]
615615

616616
public var message: String {
617-
"replace \(nodesDescription(replaceTokens, format: false)) with \(nodesDescription(replacements, format: false))"
617+
if replacements.count == 1 {
618+
return "replace \(nodesDescription(replaceTokens, format: false)) with '\(replacements[0].text)'"
619+
} else {
620+
return "replace \(nodesDescription(replaceTokens, format: false)) with \(nodesDescription(replacements, format: false))"
621+
}
618622
}
619623
}

0 commit comments

Comments
 (0)