Skip to content

Remove usages of functions that shouldn’t be part of SwiftSyntax’s public API #504

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
merged 1 commit into from
Apr 11, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public final class FileScopedDeclarationPrivacy: SyntaxFormatRule {
let name = modifier.name
if name.tokenKind == invalidAccess {
diagnose(diagnostic, on: name)
return modifier.with(\.name, name.withKind(validAccess))
return modifier.with(\.name, name.with(\.tokenKind, validAccess))
}
return modifier
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ extension ModifierListSyntax {
/// Returns modifier list without the given modifier.
func remove(name: String) -> ModifierListSyntax {
guard has(modifier: name) else { return self }
for mod in self {
for (index, mod) in self.enumerated() {
if mod.name.text == name {
return removing(childAt: mod.indexInParent)
return removing(childAt: index)
}
}
return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class NoAccessLevelOnExtensionDeclaration: SyntaxFormatRule {
let accessKeywordToAdd: DeclModifierSyntax
if keywordKind == .keyword(.private) {
accessKeywordToAdd
= accessKeyword.with(\.name, accessKeyword.name.withKind(.keyword(.fileprivate)))
= accessKeyword.with(\.name, accessKeyword.name.with(\.tokenKind, .keyword(.fileprivate)))
} else {
accessKeywordToAdd = accessKeyword
}
Expand Down