Skip to content

Commit 98cd30b

Browse files
committed
Apply exhaustive swift-format configuration from swift-syntax
Apply the exhaustive swift-format configuration from swiftlang/swift-syntax#3117 to sourcekit-lsp. Also apply all automatic formattings.
1 parent 10411dd commit 98cd30b

File tree

87 files changed

+264
-211
lines changed

Some content is hidden

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

87 files changed

+264
-211
lines changed

.swift-format

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,76 @@
11
{
2-
"version": 1,
3-
"lineLength": 120,
2+
"fileScopedDeclarationPrivacy": {
3+
"accessLevel": "private"
4+
},
5+
"indentConditionalCompilationBlocks": false,
6+
"indentSwitchCaseLabels": false,
47
"indentation": {
58
"spaces": 2
69
},
10+
"lineBreakAroundMultilineExpressionChainComponents": false,
11+
"lineBreakBeforeControlFlowKeywords": false,
712
"lineBreakBeforeEachArgument": true,
8-
"indentConditionalCompilationBlocks": false,
13+
"lineBreakBeforeEachGenericRequirement": false,
14+
"lineBreakBetweenDeclarationAttributes": false,
15+
"lineLength": 120,
16+
"maximumBlankLines": 1,
17+
"multiElementCollectionTrailingCommas": true,
18+
"noAssignmentInExpressions": {
19+
"allowedFunctions": [
20+
"XCTAssertNoThrow"
21+
]
22+
},
923
"prioritizeKeepingFunctionOutputTogether": true,
24+
"reflowMultilineStringLiterals": {
25+
"never": {
26+
27+
}
28+
},
29+
"respectsExistingLineBreaks": true,
1030
"rules": {
31+
"AllPublicDeclarationsHaveDocumentation": false,
32+
"AlwaysUseLiteralForEmptyCollectionInit": false,
1133
"AlwaysUseLowerCamelCase": false,
1234
"AmbiguousTrailingClosureOverload": false,
35+
"BeginDocumentationCommentWithOneLineSummary": false,
36+
"DoNotUseSemicolons": false,
37+
"DontRepeatTypeInStaticProperties": false,
38+
"FileScopedDeclarationPrivacy": true,
39+
"FullyIndirectEnum": true,
40+
"GroupNumericLiterals": true,
41+
"IdentifiersMustBeASCII": true,
42+
"NeverForceUnwrap": false,
43+
"NeverUseForceTry": false,
44+
"NeverUseImplicitlyUnwrappedOptionals": false,
45+
"NoAccessLevelOnExtensionDeclaration": false,
46+
"NoAssignmentInExpressions": true,
1347
"NoBlockComments": false,
48+
"NoCasesWithOnlyFallthrough": true,
49+
"NoEmptyTrailingClosureParentheses": true,
50+
"NoLabelsInCasePatterns": true,
51+
"NoLeadingUnderscores": false,
52+
"NoParensAroundConditions": true,
53+
"NoPlaygroundLiterals": true,
54+
"NoVoidReturnOnFunctionSignature": true,
55+
"OmitExplicitReturns": false,
56+
"OneCasePerLine": true,
57+
"OneVariableDeclarationPerLine": true,
58+
"OnlyOneTrailingClosureArgument": true,
1459
"OrderedImports": true,
60+
"ReplaceForEachWithForLoop": true,
61+
"ReturnVoidInsteadOfEmptyTuple": true,
62+
"TypeNamesShouldBeCapitalized": true,
63+
"UseEarlyExits": false,
64+
"UseExplicitNilCheckInConditions": true,
1565
"UseLetInEveryBoundCaseVariable": false,
66+
"UseShorthandTypeNames": true,
67+
"UseSingleLinePropertyGetter": true,
1668
"UseSynthesizedInitializer": false,
17-
"ReturnVoidInsteadOfEmptyTuple": true,
18-
"NoVoidReturnOnFunctionSignature": true,
19-
}
69+
"UseTripleSlashForDocumentationComments": true,
70+
"UseWhereClausesInForLoops": false,
71+
"ValidateDocumentationComments": false
72+
},
73+
"spacesAroundRangeFormationOperators": false,
74+
"spacesBeforeEndOfLineComments": 2,
75+
"version": 1,
2076
}

SourceKitLSPDevUtils/Sources/ConfigSchemaGen/JSONSchema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ struct JSONSchemaBuilder {
101101
case .integer: schema.type = "integer"
102102
case .number: schema.type = "number"
103103
case .string: schema.type = "string"
104-
case .array(value: let value):
104+
case .array(let value):
105105
schema.type = "array"
106106
schema.items = try buildJSONSchema(from: value)
107-
case .dictionary(value: let value):
107+
case .dictionary(let value):
108108
schema.type = "object"
109109
schema.additionalProperties = try buildJSONSchema(from: value)
110110
case .struct(let structInfo):

Sources/BuildServerIntegration/BuildServerManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ package import ToolchainRegistry
2424

2525
import struct TSCBasic.RelativePath
2626

27-
fileprivate typealias RequestCache<Request: RequestType & Hashable> = Cache<Request, Request.Response>
27+
private typealias RequestCache<Request: RequestType & Hashable> = Cache<Request, Request.Response>
2828

2929
/// An output path returned from the build server in the `SourceItem.data.outputPath` field.
3030
package enum OutputPath: Hashable, Comparable, CustomLogStringConvertible {
@@ -1627,7 +1627,7 @@ fileprivate extension TextDocumentSourceKitOptionsResponse {
16271627
}
16281628
}
16291629

1630-
fileprivate let supplementalClangIndexingArgs: [String] = [
1630+
private let supplementalClangIndexingArgs: [String] = [
16311631
// Retain extra information for indexing
16321632
"-fretain-comments-from-system-headers",
16331633
// Pick up macro definitions during indexing

Sources/BuildServerIntegration/CompilerCommandLineOption.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ package struct CompilerCommandLineOption {
151151
}
152152
}
153153

154-
extension Array<CompilerCommandLineOption> {
154+
extension [CompilerCommandLineOption] {
155155
func firstMatch(for argument: String) -> CompilerCommandLineOption.Match? {
156156
for optionToRemove in self {
157157
if let match = optionToRemove.matches(argument: argument) {

Sources/BuildServerIntegration/SplitShellCommand.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// MARK: - Unix
1414

15-
fileprivate struct UnixCommandParser {
15+
private struct UnixCommandParser {
1616
var content: Substring
1717
var i: Substring.UTF8View.Index
1818
var result: [String] = []
@@ -162,7 +162,7 @@ fileprivate extension Character {
162162
}
163163
}
164164

165-
fileprivate struct WindowsCommandParser {
165+
private struct WindowsCommandParser {
166166
/// The content of the entire command that shall be parsed.
167167
private let content: String
168168

Sources/BuildServerIntegration/SwiftPMBuildServer.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import struct TSCBasic.AbsolutePath
3636
import class TSCBasic.Process
3737
package import class ToolchainRegistry.Toolchain
3838

39-
fileprivate typealias AbsolutePath = Basics.AbsolutePath
39+
private typealias AbsolutePath = Basics.AbsolutePath
4040

4141
/// A build target in SwiftPM
4242
package typealias SwiftBuildTarget = SourceKitLSPAPI.BuildTarget
@@ -78,7 +78,7 @@ fileprivate extension TSCBasic.AbsolutePath {
7878
}
7979
}
8080

81-
fileprivate let preparationTaskID: AtomicUInt32 = AtomicUInt32(initialValue: 0)
81+
private let preparationTaskID: AtomicUInt32 = AtomicUInt32(initialValue: 0)
8282

8383
/// Swift Package Manager build server and workspace support.
8484
///
@@ -779,7 +779,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {
779779
switch exitStatus {
780780
case .terminated(code: 0):
781781
break
782-
case .terminated(code: let code):
782+
case .terminated(let code):
783783
// This most likely happens if there are compilation errors in the source file. This is nothing to worry about.
784784
let stdout = (try? String(bytes: result.output.get(), encoding: .utf8)) ?? "<no stderr>"
785785
let stderr = (try? String(bytes: result.stderrOutput.get(), encoding: .utf8)) ?? "<no stderr>"
@@ -792,14 +792,14 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {
792792
\(stdout)
793793
"""
794794
)
795-
case .signalled(signal: let signal):
795+
case .signalled(let signal):
796796
if !Task.isCancelled {
797797
// The indexing job finished with a signal. Could be because the compiler crashed.
798798
// Ignore signal exit codes if this task has been cancelled because the compiler exits with SIGINT if it gets
799799
// interrupted.
800800
logger.error("Preparation of target \(target.forLogging) signaled \(signal)")
801801
}
802-
case .abnormal(exception: let exception):
802+
case .abnormal(let exception):
803803
if !Task.isCancelled {
804804
logger.error("Preparation of target \(target.forLogging) exited abnormally \(exception)")
805805
}

Sources/BuildServerProtocol/Messages.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public import LanguageServerProtocol
1414

15-
fileprivate let requestTypes: [_RequestType.Type] = [
15+
private let requestTypes: [_RequestType.Type] = [
1616
BuildShutdownRequest.self,
1717
BuildTargetPrepareRequest.self,
1818
BuildTargetSourcesRequest.self,
@@ -24,7 +24,7 @@ fileprivate let requestTypes: [_RequestType.Type] = [
2424
WorkspaceWaitForBuildSystemUpdatesRequest.self,
2525
]
2626

27-
fileprivate let notificationTypes: [NotificationType.Type] = [
27+
private let notificationTypes: [NotificationType.Type] = [
2828
CancelRequestNotification.self,
2929
FileOptionsChangedNotification.self,
3030
OnBuildExitNotification.self,

Sources/CompletionScoring/Semantics/Components/PopularityTable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ package struct PopularityTable {
138138
}
139139
}
140140

141-
extension Dictionary<String, Popularity> {
141+
extension [String: Popularity] {
142142
fileprivate mutating func record(scoreComponent: Double, for key: String) {
143143
let leastPopular = Popularity(scoreComponent: -Double.infinity)
144144
if self[key, default: leastPopular].scoreComponent < scoreComponent {

Sources/CompletionScoring/Semantics/SemanticClassification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ extension SemanticClassification {
155155
}
156156

157157
/// Used for debugging.
158-
fileprivate protocol CompletionScoreComponent {
158+
private protocol CompletionScoreComponent {
159159
var name: String { get }
160160

161161
var instance: String { get }

Sources/CompletionScoring/Text/InfluencingIdentifiers.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import Foundation
1414

15-
fileprivate typealias UTF8Bytes = Pattern.UTF8Bytes
15+
private typealias UTF8Bytes = Pattern.UTF8Bytes
1616

1717
package struct InfluencingIdentifiers: Sendable {
1818
// `nonisolated(unsafe)` is fine because the underlying buffer is not modified until `deallocate` is called and the
@@ -91,9 +91,7 @@ package struct InfluencingIdentifiers: Sendable {
9191
// TODO: We could turn this loop inside out to walk the candidate tokens first, and skip the ones that are shorter
9292
// than the shortest token, or keep bit for each length we have, and skip almost all of them.
9393
let matchedTokenCount = identifier.tokens.countOf { token in
94-
if (RejectionFilter.match(pattern: token.rejectionFilter, candidate: candidate.rejectionFilter)
95-
== .maybe)
96-
{
94+
if RejectionFilter.match(pattern: token.rejectionFilter, candidate: candidate.rejectionFilter) == .maybe {
9795
let candidateTokenization = candidateTokenization.lazyInitialize {
9896
Pattern.Tokenization.allocate(
9997
mixedcaseBytes: candidate.bytes,

0 commit comments

Comments
 (0)