Skip to content

Commit 50eecb7

Browse files
committed
Reduce visibility of some things to internal.
These changes are only the ones that don't cause compilation errors.
1 parent 0ddb4c0 commit 50eecb7

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

Sources/SwiftFormat/Core/Context.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ public final class Context {
3737
}
3838

3939
/// The configuration for this run of the pipeline, provided by a configuration JSON file.
40-
public let configuration: Configuration
40+
let configuration: Configuration
4141

4242
/// Defines the operators and their precedence relationships that were used during parsing.
43-
public let operatorTable: OperatorTable
43+
let operatorTable: OperatorTable
4444

4545
/// Emits findings to the finding consumer.
46-
public let findingEmitter: FindingEmitter
46+
let findingEmitter: FindingEmitter
4747

4848
/// The URL of the file being linted or formatted.
49-
public let fileURL: URL
49+
let fileURL: URL
5050

5151
/// Indicates whether the file is known to import XCTest.
5252
public var importsXCTest: XCTestImportState
5353

5454
/// An object that converts `AbsolutePosition` values to `SourceLocation` values.
55-
public let sourceLocationConverter: SourceLocationConverter
55+
let sourceLocationConverter: SourceLocationConverter
5656

5757
/// Contains the rules have been disabled by comments for certain line numbers.
58-
public let ruleMask: RuleMask
58+
let ruleMask: RuleMask
5959

6060
/// Contains all the available rules' names associated to their types' object identifiers.
61-
public let ruleNameCache: [ObjectIdentifier: String]
61+
let ruleNameCache: [ObjectIdentifier: String]
6262

6363
/// Creates a new Context with the provided configuration, diagnostic engine, and file URL.
6464
public init(
@@ -87,7 +87,7 @@ public final class Context {
8787

8888
/// Given a rule's name and the node it is examining, determine if the rule is disabled at this
8989
/// location or not.
90-
public func isRuleEnabled<R: Rule>(_ rule: R.Type, node: Syntax) -> Bool {
90+
func isRuleEnabled<R: Rule>(_ rule: R.Type, node: Syntax) -> Bool {
9191
let loc = node.startLocation(converter: self.sourceLocationConverter)
9292

9393
assert(

Sources/SwiftFormat/Core/Finding+Convenience.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SwiftSyntax
1414

1515
extension Finding.Location {
1616
/// Creates a new `Finding.Location` by converting the given `SourceLocation` from `SwiftSyntax`.
17-
public init(_ sourceLocation: SourceLocation) {
17+
init(_ sourceLocation: SourceLocation) {
1818
self.init(file: sourceLocation.file, line: sourceLocation.line, column: sourceLocation.column)
1919
}
2020
}

Sources/SwiftFormat/Core/FindingEmitter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/// If the consumer function is nil, then the `emit` function is a no-op. This allows callers, such
2020
/// as lint/format rules and the pretty-printer, to emit findings unconditionally, without wrapping
2121
/// each call in a check about whether the client is interested in receiving those findings or not.
22-
public final class FindingEmitter {
22+
final class FindingEmitter {
2323
/// An optional function that will be called and passed a finding each time one is emitted.
2424
private let consumer: ((Finding) -> Void)?
2525

Sources/SwiftFormat/Core/SyntaxProtocol+Convenience.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension SyntaxProtocol {
2424
/// - Parameter index: The index of the trivia piece in the leading trivia whose position should
2525
/// be returned.
2626
/// - Returns: The absolute position of the trivia piece.
27-
public func position(ofLeadingTriviaAt index: Trivia.Index) -> AbsolutePosition {
27+
func position(ofLeadingTriviaAt index: Trivia.Index) -> AbsolutePosition {
2828
guard leadingTrivia.indices.contains(index) else {
2929
preconditionFailure("Index was out of bounds in the node's leading trivia.")
3030
}
@@ -50,7 +50,7 @@ extension SyntaxProtocol {
5050
/// - converter: The `SourceLocationConverter` that was previously initialized using the root
5151
/// tree of this node.
5252
/// - Returns: The source location of the trivia piece.
53-
public func startLocation(
53+
func startLocation(
5454
ofLeadingTriviaAt index: Trivia.Index,
5555
converter: SourceLocationConverter
5656
) -> SourceLocation {
@@ -60,7 +60,7 @@ extension SyntaxProtocol {
6060

6161
extension SyntaxCollection {
6262
/// The first element in the syntax collection if it is the *only* element, or nil otherwise.
63-
public var firstAndOnly: Element? {
63+
var firstAndOnly: Element? {
6464
var iterator = makeIterator()
6565
guard let first = iterator.next() else { return nil }
6666
guard iterator.next() == nil else { return nil }

Sources/SwiftFormat/Core/Trivia+Convenience.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SwiftSyntax
1414

1515
extension Trivia {
16-
public var numberOfComments: Int {
16+
var numberOfComments: Int {
1717
var count = 0
1818
for piece in self {
1919
switch piece {
@@ -27,15 +27,15 @@ extension Trivia {
2727
}
2828

2929
/// Returns whether the trivia contains at least 1 `lineComment`.
30-
public var hasLineComment: Bool {
30+
var hasLineComment: Bool {
3131
return self.contains {
3232
if case .lineComment = $0 { return true }
3333
return false
3434
}
3535
}
3636

3737
/// Returns this set of trivia, without any whitespace characters.
38-
public func withoutSpaces() -> Trivia {
38+
func withoutSpaces() -> Trivia {
3939
return Trivia(
4040
pieces: filter {
4141
if case .spaces = $0 { return false }
@@ -45,7 +45,7 @@ extension Trivia {
4545
}
4646

4747
/// Returns this set of trivia, without any leading spaces.
48-
public func withoutLeadingSpaces() -> Trivia {
48+
func withoutLeadingSpaces() -> Trivia {
4949
return Trivia(
5050
pieces: Array(drop {
5151
if case .spaces = $0 { return false }
@@ -55,7 +55,7 @@ extension Trivia {
5555
}
5656

5757
/// Returns this set of trivia, without any newlines.
58-
public func withoutNewlines() -> Trivia {
58+
func withoutNewlines() -> Trivia {
5959
return Trivia(
6060
pieces: filter {
6161
if case .newlines = $0 { return false }
@@ -66,7 +66,7 @@ extension Trivia {
6666
/// Returns this trivia, excluding the last newline and anything following it.
6767
///
6868
/// If there is no newline in the trivia, it is returned unmodified.
69-
public func withoutLastLine() -> Trivia {
69+
func withoutLastLine() -> Trivia {
7070
var maybeLastNewlineOffset: Int? = nil
7171
for (offset, piece) in self.enumerated() {
7272
switch piece {
@@ -82,30 +82,30 @@ extension Trivia {
8282

8383
/// Returns this set of trivia, with all spaces removed except for one at the
8484
/// end.
85-
public func withOneTrailingSpace() -> Trivia {
85+
func withOneTrailingSpace() -> Trivia {
8686
return withoutSpaces() + .spaces(1)
8787
}
8888

8989
/// Returns this set of trivia, with all spaces removed except for one at the
9090
/// beginning.
91-
public func withOneLeadingSpace() -> Trivia {
91+
func withOneLeadingSpace() -> Trivia {
9292
return .spaces(1) + withoutSpaces()
9393
}
9494

9595
/// Returns this set of trivia, with all newlines removed except for one.
96-
public func withOneLeadingNewline() -> Trivia {
96+
func withOneLeadingNewline() -> Trivia {
9797
return .newlines(1) + withoutNewlines()
9898
}
9999

100100
/// Returns this set of trivia, with all newlines removed except for one.
101-
public func withOneTrailingNewline() -> Trivia {
101+
func withOneTrailingNewline() -> Trivia {
102102
return withoutNewlines() + .newlines(1)
103103
}
104104

105105
/// Walks through trivia looking for multiple separate trivia entities with
106106
/// the same base kind, and condenses them.
107107
/// `[.spaces(1), .spaces(2)]` becomes `[.spaces(3)]`.
108-
public func condensed() -> Trivia {
108+
func condensed() -> Trivia {
109109
guard var prev = first else { return self }
110110
var pieces = [TriviaPiece]()
111111
for piece in dropFirst() {
@@ -136,7 +136,7 @@ extension Trivia {
136136
}
137137

138138
/// Returns `true` if this trivia contains any newlines.
139-
public var containsNewlines: Bool {
139+
var containsNewlines: Bool {
140140
return contains(
141141
where: {
142142
if case .newlines = $0 { return true }
@@ -145,7 +145,7 @@ extension Trivia {
145145
}
146146

147147
/// Returns `true` if this trivia contains any spaces.
148-
public var containsSpaces: Bool {
148+
var containsSpaces: Bool {
149149
return contains(
150150
where: {
151151
if case .spaces = $0 { return true }
@@ -156,7 +156,7 @@ extension Trivia {
156156

157157
/// Returns `true` if this trivia contains any backslahes (used for multiline string newline
158158
/// suppression).
159-
public var containsBackslashes: Bool {
159+
var containsBackslashes: Bool {
160160
return contains(
161161
where: {
162162
if case .backslashes = $0 { return true }

0 commit comments

Comments
 (0)