From f4ea614be63ff1cb0863dc45940577212b496617 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Tue, 2 Jul 2024 11:06:35 +0200 Subject: [PATCH] Set `prioritizeKeepingFunctionOutputTogether` in `.swift-format` --- .swift-format | 1 + Sources/SKTestSupport/MultiFileTestProject.swift | 7 ++++--- Sources/SemanticIndex/CheckedIndex.swift | 7 ++++--- Sources/SourceKitLSP/Swift/SyntaxHighlightingTokens.swift | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.swift-format b/.swift-format index 22b48e090..41a022f26 100644 --- a/.swift-format +++ b/.swift-format @@ -6,6 +6,7 @@ }, "lineBreakBeforeEachArgument": true, "indentConditionalCompilationBlocks": false, + "prioritizeKeepingFunctionOutputTogether": true, "rules": { "AlwaysUseLowerCamelCase": false, "AmbiguousTrailingClosureOverload": false, diff --git a/Sources/SKTestSupport/MultiFileTestProject.swift b/Sources/SKTestSupport/MultiFileTestProject.swift index 5303cf46a..763e8f9ef 100644 --- a/Sources/SKTestSupport/MultiFileTestProject.swift +++ b/Sources/SKTestSupport/MultiFileTestProject.swift @@ -137,9 +137,10 @@ public class MultiFileTestProject { /// Opens the document with the given file name in the SourceKit-LSP server. /// /// - Returns: The URI for the opened document and the positions of the location markers. - public func openDocument(_ fileName: String, language: Language? = nil) throws -> ( - uri: DocumentURI, positions: DocumentPositions - ) { + public func openDocument( + _ fileName: String, + language: Language? = nil + ) throws -> (uri: DocumentURI, positions: DocumentPositions) { guard let fileData = self.fileData[fileName] else { throw Error.fileNotFound } diff --git a/Sources/SemanticIndex/CheckedIndex.swift b/Sources/SemanticIndex/CheckedIndex.swift index 76d115eda..80f0ce52c 100644 --- a/Sources/SemanticIndex/CheckedIndex.swift +++ b/Sources/SemanticIndex/CheckedIndex.swift @@ -298,9 +298,10 @@ private struct IndexOutOfDateChecker { /// `documentManager` must always be the same between calls to `hasFileInMemoryModifications` since it is not part of /// the cache key. This is fine because we always assume the `documentManager` to come from the associated value of /// `CheckLevel.imMemoryModifiedFiles`, which is constant. - private mutating func fileHasInMemoryModifications(_ uri: DocumentURI, documentManager: InMemoryDocumentManager) - -> Bool - { + private mutating func fileHasInMemoryModifications( + _ uri: DocumentURI, + documentManager: InMemoryDocumentManager + ) -> Bool { if let cached = fileHasInMemoryModificationsCache[uri] { return cached } diff --git a/Sources/SourceKitLSP/Swift/SyntaxHighlightingTokens.swift b/Sources/SourceKitLSP/Swift/SyntaxHighlightingTokens.swift index 4515861cf..62506517b 100644 --- a/Sources/SourceKitLSP/Swift/SyntaxHighlightingTokens.swift +++ b/Sources/SourceKitLSP/Swift/SyntaxHighlightingTokens.swift @@ -68,9 +68,9 @@ public struct SyntaxHighlightingTokens: Sendable { } /// Sorts the tokens in this array by their start position. - public func sorted(_ areInIncreasingOrder: (SyntaxHighlightingToken, SyntaxHighlightingToken) -> Bool) - -> SyntaxHighlightingTokens - { + public func sorted( + _ areInIncreasingOrder: (SyntaxHighlightingToken, SyntaxHighlightingToken) -> Bool + ) -> SyntaxHighlightingTokens { SyntaxHighlightingTokens(tokens: tokens.sorted(by: areInIncreasingOrder)) } }