Skip to content

Commit 69d4084

Browse files
committed
Finish adding SPIs and lowering access levels.
1 parent ca113c0 commit 69d4084

24 files changed

+44
-20
lines changed

Sources/SwiftFormat/Core/Context.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import SwiftParser
2020
///
2121
/// Specifically, it is the container for the shared configuration, diagnostic consumer, and URL of
2222
/// the current file.
23+
@_spi(Rules)
2324
public final class Context {
2425

2526
/// Tracks whether `XCTest` has been imported so that certain logic can be modified for files that

Sources/SwiftFormat/Core/DocumentationComment.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import SwiftSyntax
1919
/// also the nested information that can be provided on a parameter. For example, when a parameter
2020
/// is a function type, it can provide not only a brief summary but also its own parameter and
2121
/// return value descriptions.
22+
@_spi(Testing)
2223
public struct DocumentationComment {
2324
/// A description of a parameter in a documentation comment.
2425
public struct Parameter {

Sources/SwiftFormat/Core/DocumentationCommentText.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import SwiftSyntax
1717
/// This type should be used when only the text of the comment is important, not the Markdown
1818
/// structural organization. It automatically handles trimming leading indentation from comments as
1919
/// well as "ASCII art" in block comments (i.e., leading asterisks on each line).
20+
@_spi(Testing)
2021
public struct DocumentationCommentText {
2122
/// Denotes the kind of punctuation used to introduce the comment.
2223
public enum Introducer {

Sources/SwiftFormat/Core/ImportsXCTestVisitor.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private class ImportsXCTestVisitor: SyntaxVisitor {
5252
/// - Parameters:
5353
/// - context: The context information of the target source file.
5454
/// - sourceFile: The file to be visited.
55+
@_spi(Testing)
5556
public func setImportsXCTest(context: Context, sourceFile: SourceFileSyntax) {
5657
guard context.importsXCTest == .notDetermined else { return }
5758
let visitor = ImportsXCTestVisitor(context: context)

Sources/SwiftFormat/Core/LegacyTriviaBehavior.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import SwiftSyntax
55
///
66
/// Eventually we should get rid of this and update the core formatting code to adjust to the new
77
/// behavior, but this workaround lets us keep the current implementation without larger changes.
8+
@_spi(Testing)
89
public func restoringLegacyTriviaBehavior(_ sourceFile: SourceFileSyntax) -> SourceFileSyntax {
910
return LegacyTriviaBehaviorRewriter().visit(sourceFile)
1011
}

Sources/SwiftFormat/Core/Rule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Foundation
1414
import SwiftSyntax
1515

1616
/// A Rule is a linting or formatting pass that executes in a given context.
17+
@_spi(Rules)
1718
public protocol Rule {
1819
/// The context in which the rule is executed.
1920
var context: Context { get }

Sources/SwiftFormat/Core/RuleMask.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import SwiftSyntax
3737
///
3838
/// The rules themselves reference RuleMask to see if it is disabled for the line it is currently
3939
/// examining.
40+
@_spi(Testing)
4041
public class RuleMask {
4142
/// Stores the source ranges in which all rules are ignored.
4243
private var allRulesIgnoredRanges: [SourceRange] = []

Sources/SwiftFormat/Core/RuleNameCache+Generated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// This file is automatically generated with generate-pipeline. Do Not Edit!
1414

1515
/// By default, the `Rule.ruleName` should be the name of the implementing rule type.
16+
@_spi(Testing)
1617
public let ruleNameCache: [ObjectIdentifier: String] = [
1718
ObjectIdentifier(AllPublicDeclarationsHaveDocumentation.self): "AllPublicDeclarationsHaveDocumentation",
1819
ObjectIdentifier(AlwaysUseLowerCamelCase.self): "AlwaysUseLowerCamelCase",

Sources/SwiftFormat/Core/RuleState.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/// The enablement of a lint/format rule based on the presence or absence of comment directives in
1414
/// the source file.
15+
@_spi(Testing)
1516
public enum RuleState {
1617

1718
/// There is no explicit information in the source file about whether the rule should be enabled

Sources/SwiftFormat/Core/SyntaxFormatRule.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
import SwiftSyntax
1414

1515
/// A rule that both formats and lints a given file.
16-
open class SyntaxFormatRule: SyntaxRewriter, Rule {
16+
@_spi(Rules)
17+
public class SyntaxFormatRule: SyntaxRewriter, Rule {
1718
/// Whether this rule is opt-in, meaning it's disabled by default. Rules are opt-out unless they
1819
/// override this property.
19-
open class var isOptIn: Bool {
20+
public class var isOptIn: Bool {
2021
return false
2122
}
2223

@@ -28,7 +29,7 @@ open class SyntaxFormatRule: SyntaxRewriter, Rule {
2829
self.context = context
2930
}
3031

31-
open override func visitAny(_ node: Syntax) -> Syntax? {
32+
public override func visitAny(_ node: Syntax) -> Syntax? {
3233
// If the rule is not enabled, then return the node unmodified; otherwise, returning nil tells
3334
// SwiftSyntax to continue with the standard dispatch.
3435
guard context.isRuleEnabled(type(of: self), node: node) else { return node }

0 commit comments

Comments
 (0)