Skip to content

Fix RawSyntax's leading/trailingTrivia computation to return nil if the outermost children don't have leading/trailing trivia #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/RawSyntax.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ extension RawSyntax {
case .node(_, let layout):
for child in layout {
guard let child = child else { continue }
guard let result = child.leadingTrivia else { continue }
guard let result = child.leadingTrivia else { break }
return result
}
return nil
Expand All @@ -364,7 +364,7 @@ extension RawSyntax {
case .node(_, let layout):
for child in layout.reversed() {
guard let child = child else { continue }
guard let result = child.trailingTrivia else { continue }
guard let result = child.trailingTrivia else { break }
return result
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftSyntaxTest/Inputs/visitor.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
func foo() {
func foo() {
public func foo() {
func foo() {
/*Unknown token */0xG
}
Expand Down