Skip to content

Commit a7f16de

Browse files
authored
Merge pull request #593 from allevato/fewer-modules
Collapse almost everything into a single `SwiftFormat` module.
2 parents b896e0f + 69d4084 commit a7f16de

File tree

195 files changed

+226
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+226
-265
lines changed

Package.swift

Lines changed: 11 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ let package = Package(
5050
name: "SwiftFormat",
5151
dependencies: [
5252
"SwiftFormatConfiguration",
53-
"SwiftFormatCore",
54-
"SwiftFormatPrettyPrint",
55-
"SwiftFormatRules",
56-
"SwiftFormatWhitespaceLinter",
53+
.product(name: "Markdown", package: "swift-markdown"),
5754
.product(name: "SwiftSyntax", package: "swift-syntax"),
5855
.product(name: "SwiftOperators", package: "swift-syntax"),
5956
.product(name: "SwiftParser", package: "swift-syntax"),
@@ -64,46 +61,13 @@ let package = Package(
6461
name: "SwiftFormatConfiguration"
6562
),
6663
.target(
67-
name: "SwiftFormatCore",
68-
dependencies: [
69-
"SwiftFormatConfiguration",
70-
.product(name: "Markdown", package: "swift-markdown"),
71-
.product(name: "SwiftOperators", package: "swift-syntax"),
72-
.product(name: "SwiftSyntax", package: "swift-syntax"),
73-
]
74-
),
75-
.target(
76-
name: "SwiftFormatRules",
77-
dependencies: [
78-
"SwiftFormatCore",
79-
"SwiftFormatConfiguration",
80-
.product(name: "Markdown", package: "swift-markdown"),
81-
]
82-
),
83-
.target(
84-
name: "SwiftFormatPrettyPrint",
85-
dependencies: [
86-
"SwiftFormatCore",
87-
"SwiftFormatConfiguration",
88-
.product(name: "SwiftOperators", package: "swift-syntax"),
89-
]
90-
),
91-
.target(
92-
name: "SwiftFormatTestSupport",
64+
name: "_SwiftFormatTestSupport",
9365
dependencies: [
94-
"SwiftFormatCore",
95-
"SwiftFormatRules",
66+
"SwiftFormat",
9667
"SwiftFormatConfiguration",
9768
.product(name: "SwiftOperators", package: "swift-syntax"),
9869
]
9970
),
100-
.target(
101-
name: "SwiftFormatWhitespaceLinter",
102-
dependencies: [
103-
"SwiftFormatCore",
104-
.product(name: "SwiftSyntax", package: "swift-syntax"),
105-
]
106-
),
10771
.plugin(
10872
name: "Format Source Code",
10973
capability: .command(
@@ -133,8 +97,7 @@ let package = Package(
13397
.executableTarget(
13498
name: "generate-pipeline",
13599
dependencies: [
136-
"SwiftFormatCore",
137-
"SwiftFormatRules",
100+
"SwiftFormat",
138101
.product(name: "SwiftSyntax", package: "swift-syntax"),
139102
.product(name: "SwiftParser", package: "swift-syntax"),
140103
]
@@ -144,7 +107,6 @@ let package = Package(
144107
dependencies: [
145108
"SwiftFormat",
146109
"SwiftFormatConfiguration",
147-
"SwiftFormatCore",
148110
.product(name: "ArgumentParser", package: "swift-argument-parser"),
149111
.product(name: "SwiftSyntax", package: "swift-syntax"),
150112
.product(name: "SwiftParser", package: "swift-syntax"),
@@ -155,60 +117,26 @@ let package = Package(
155117
name: "SwiftFormatConfigurationTests",
156118
dependencies: ["SwiftFormatConfiguration"]
157119
),
158-
.testTarget(
159-
name: "SwiftFormatCoreTests",
160-
dependencies: [
161-
"SwiftFormatConfiguration",
162-
"SwiftFormatCore",
163-
.product(name: "Markdown", package: "swift-markdown"),
164-
.product(name: "SwiftSyntax", package: "swift-syntax"),
165-
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
166-
.product(name: "SwiftParser", package: "swift-syntax"),
167-
]
168-
),
169120
.testTarget(
170121
name: "SwiftFormatPerformanceTests",
171122
dependencies: [
172-
"SwiftFormatTestSupport",
173-
"SwiftFormatWhitespaceLinter",
123+
"SwiftFormat",
124+
"_SwiftFormatTestSupport",
174125
.product(name: "SwiftSyntax", package: "swift-syntax"),
175126
.product(name: "SwiftParser", package: "swift-syntax"),
176127
]
177128
),
178129
.testTarget(
179-
name: "SwiftFormatPrettyPrintTests",
130+
name: "SwiftFormatTests",
180131
dependencies: [
132+
"SwiftFormat",
181133
"SwiftFormatConfiguration",
182-
"SwiftFormatCore",
183-
"SwiftFormatPrettyPrint",
184-
"SwiftFormatRules",
185-
"SwiftFormatTestSupport",
186-
.product(name: "SwiftSyntax", package: "swift-syntax"),
134+
"_SwiftFormatTestSupport",
135+
.product(name: "Markdown", package: "swift-markdown"),
187136
.product(name: "SwiftOperators", package: "swift-syntax"),
188137
.product(name: "SwiftParser", package: "swift-syntax"),
189-
]
190-
),
191-
.testTarget(
192-
name: "SwiftFormatRulesTests",
193-
dependencies: [
194-
"SwiftFormatConfiguration",
195-
"SwiftFormatCore",
196-
"SwiftFormatPrettyPrint",
197-
"SwiftFormatRules",
198-
"SwiftFormatTestSupport",
199138
.product(name: "SwiftSyntax", package: "swift-syntax"),
200-
.product(name: "SwiftParser", package: "swift-syntax"),
201-
]
202-
),
203-
.testTarget(
204-
name: "SwiftFormatWhitespaceLinterTests",
205-
dependencies: [
206-
"SwiftFormatConfiguration",
207-
"SwiftFormatCore",
208-
"SwiftFormatTestSupport",
209-
"SwiftFormatWhitespaceLinter",
210-
.product(name: "SwiftSyntax", package: "swift-syntax"),
211-
.product(name: "SwiftParser", package: "swift-syntax"),
139+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
212140
]
213141
),
214142
]

Sources/SwiftFormat/SwiftFormatter.swift renamed to Sources/SwiftFormat/API/SwiftFormatter.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import Foundation
1414
import SwiftDiagnostics
1515
import SwiftFormatConfiguration
16-
import SwiftFormatCore
17-
import SwiftFormatPrettyPrint
18-
import SwiftFormatRules
1916
import SwiftOperators
2017
import SwiftSyntax
2118

Sources/SwiftFormat/SwiftLinter.swift renamed to Sources/SwiftFormat/API/SwiftLinter.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
import Foundation
1414
import SwiftDiagnostics
1515
import SwiftFormatConfiguration
16-
import SwiftFormatCore
17-
import SwiftFormatPrettyPrint
18-
import SwiftFormatRules
19-
import SwiftFormatWhitespaceLinter
2016
import SwiftOperators
2117
import SwiftSyntax
2218

Sources/SwiftFormatRules/AddModifierRewriter.swift renamed to Sources/SwiftFormat/Core/AddModifierRewriter.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import SwiftFormatCore
1413
import SwiftSyntax
1514

1615
fileprivate final class AddModifierRewriter: SyntaxRewriter {

Sources/SwiftFormatCore/Context.swift renamed to Sources/SwiftFormat/Core/Context.swift

Lines changed: 9 additions & 8 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
@@ -37,28 +38,28 @@ public final class Context {
3738
}
3839

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

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

4546
/// Emits findings to the finding consumer.
46-
public let findingEmitter: FindingEmitter
47+
let findingEmitter: FindingEmitter
4748

4849
/// The URL of the file being linted or formatted.
49-
public let fileURL: URL
50+
let fileURL: URL
5051

5152
/// Indicates whether the file is known to import XCTest.
5253
public var importsXCTest: XCTestImportState
5354

5455
/// An object that converts `AbsolutePosition` values to `SourceLocation` values.
55-
public let sourceLocationConverter: SourceLocationConverter
56+
let sourceLocationConverter: SourceLocationConverter
5657

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

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

6364
/// Creates a new Context with the provided configuration, diagnostic engine, and file URL.
6465
public init(
@@ -87,7 +88,7 @@ public final class Context {
8788

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

9394
assert(

Sources/SwiftFormatCore/DocumentationComment.swift renamed to 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 {

0 commit comments

Comments
 (0)