diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0f20d19d46f..b8978a87286 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -15,5 +15,3 @@ jobs: api_breakage_check_allowlist_path: "Release Notes/api-breakages.txt" # https://github.com/swiftlang/swift-syntax/issues/2987 docs_check_enabled: false - # https://github.com/swiftlang/swift-syntax/issues/2988 - format_check_enabled: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d03d7b22926..0c29132cbe3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,9 @@ swift-syntax is formatted using [swift-format](http://github.com/swiftlang/swift To format your changes run the formatter using the following command ```bash -./swift-syntax-dev-utils format +swift format --in-place --parallel --recursive . +# Or alternatively +swift format -ipr . ``` It will build a local copy of swift-format from the `main` branch and format the repository. Since it is building a release version of `swift-format`, the first run will take few minutes. Subsequent runs take less than 2 seconds. @@ -38,7 +40,7 @@ Generated source code is not formatted to make it easier to spot changes when re > #!/usr/bin/env bash > set -e > SOURCE_DIR=$(realpath "$(dirname $0)/../..") -> swift "$SOURCE_DIR/swift-syntax-dev-utils" format --lint +> swift format lint --strict --parallel --recursive $SOURCE_DIR > ``` > 2. Mark the file as executable: `chmod a+x swift-syntax/.git/hooks/pre-commit` > 3. If you have global git hooks installed, be sure to call them at the end of the script with `path/to/global/hooks/pre-commit "$@"` diff --git a/CodeGeneration/Sources/Utils/CopyrightHeader.swift b/CodeGeneration/Sources/Utils/CopyrightHeader.swift index b185d224679..084cce2077b 100644 --- a/CodeGeneration/Sources/Utils/CopyrightHeader.swift +++ b/CodeGeneration/Sources/Utils/CopyrightHeader.swift @@ -25,6 +25,7 @@ public var copyrightHeader: Trivia = // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// - //// Automatically generated by generate-swift-syntax - //// Do not edit directly! + // Automatically generated by generate-swift-syntax + // Do not edit directly! + // swift-format-ignore-file """ + .newlines(2) diff --git a/Sources/SwiftParser/generated/ExperimentalFeatures.swift b/Sources/SwiftParser/generated/ExperimentalFeatures.swift index 9783cc6c814..72720177b57 100644 --- a/Sources/SwiftParser/generated/ExperimentalFeatures.swift +++ b/Sources/SwiftParser/generated/ExperimentalFeatures.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file extension Parser { @_spi(ExperimentalLanguageFeatures) diff --git a/Sources/SwiftParser/generated/IsLexerClassified.swift b/Sources/SwiftParser/generated/IsLexerClassified.swift index d3efb6fb63a..52e0a81f989 100644 --- a/Sources/SwiftParser/generated/IsLexerClassified.swift +++ b/Sources/SwiftParser/generated/IsLexerClassified.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) public import SwiftSyntax diff --git a/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift b/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift index 793f422e211..c880b12f8e5 100644 --- a/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift +++ b/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) public import SwiftSyntax diff --git a/Sources/SwiftParser/generated/Parser+TokenSpecSet.swift b/Sources/SwiftParser/generated/Parser+TokenSpecSet.swift index 9dceec184c1..bcdb11f0b95 100644 --- a/Sources/SwiftParser/generated/Parser+TokenSpecSet.swift +++ b/Sources/SwiftParser/generated/Parser+TokenSpecSet.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) public import SwiftSyntax diff --git a/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift b/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift index 62c099aac30..853e2fbb690 100644 --- a/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift +++ b/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) internal import SwiftSyntax diff --git a/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift index 333b269210e..dd887957a01 100644 --- a/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift +++ b/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) internal import SwiftSyntax diff --git a/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift index ae282ef39a8..4a586778cf0 100644 --- a/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift +++ b/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) internal import SwiftSyntax diff --git a/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift index 85e86b60a68..4d1a90253da 100644 --- a/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift +++ b/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) internal import SwiftSyntax diff --git a/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift b/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift index 960248257cb..838a3f512d0 100644 --- a/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift +++ b/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// If the keyPath is one from a layout structure, return the property name /// of it. diff --git a/Sources/SwiftSyntax/generated/Keyword.swift b/Sources/SwiftSyntax/generated/Keyword.swift index e941ff4f59f..7b85cc8e050 100644 --- a/Sources/SwiftSyntax/generated/Keyword.swift +++ b/Sources/SwiftSyntax/generated/Keyword.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file public enum Keyword: UInt8, Hashable, Sendable { case __consuming diff --git a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift index 45caa498d7c..88518daf105 100644 --- a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift +++ b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file extension AccessorDeclSyntax { @available(*, deprecated, renamed: "unexpectedBetweenModifierAndAccessorSpecifier") diff --git a/Sources/SwiftSyntax/generated/RenamedNodesCompatibility.swift b/Sources/SwiftSyntax/generated/RenamedNodesCompatibility.swift index 364bec48f3a..4dd1ceb44b2 100644 --- a/Sources/SwiftSyntax/generated/RenamedNodesCompatibility.swift +++ b/Sources/SwiftSyntax/generated/RenamedNodesCompatibility.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @available(*, deprecated, renamed: "ImportPathComponentListSyntax") public typealias AccessPathSyntax = ImportPathComponentListSyntax diff --git a/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift b/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift index 17a6e1fa0a5..904bf392855 100644 --- a/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift +++ b/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// A `SyntaxVisitor` that can visit the nodes as generic ``Syntax`` values. /// diff --git a/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift b/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift index 255f7fc5214..c61253c2a70 100644 --- a/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift +++ b/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - DeclSyntax diff --git a/Sources/SwiftSyntax/generated/SyntaxCollections.swift b/Sources/SwiftSyntax/generated/SyntaxCollections.swift index 6c1f3cf0937..05305c97829 100644 --- a/Sources/SwiftSyntax/generated/SyntaxCollections.swift +++ b/Sources/SwiftSyntax/generated/SyntaxCollections.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// ### Children /// diff --git a/Sources/SwiftSyntax/generated/SyntaxEnum.swift b/Sources/SwiftSyntax/generated/SyntaxEnum.swift index 6509d707e63..634affebfc8 100644 --- a/Sources/SwiftSyntax/generated/SyntaxEnum.swift +++ b/Sources/SwiftSyntax/generated/SyntaxEnum.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// Enum to exhaustively switch over all different syntax nodes. public enum SyntaxEnum: Sendable { diff --git a/Sources/SwiftSyntax/generated/SyntaxKind.swift b/Sources/SwiftSyntax/generated/SyntaxKind.swift index f0369af7f5b..b83078c7a5d 100644 --- a/Sources/SwiftSyntax/generated/SyntaxKind.swift +++ b/Sources/SwiftSyntax/generated/SyntaxKind.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// Enumerates the known kinds of Syntax represented in the Syntax tree. public enum SyntaxKind: Sendable { diff --git a/Sources/SwiftSyntax/generated/SyntaxRewriter.swift b/Sources/SwiftSyntax/generated/SyntaxRewriter.swift index d6943bec078..ed2cbf394de 100644 --- a/Sources/SwiftSyntax/generated/SyntaxRewriter.swift +++ b/Sources/SwiftSyntax/generated/SyntaxRewriter.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // // This file defines the SyntaxRewriter, a class that performs a standard walk diff --git a/Sources/SwiftSyntax/generated/SyntaxTraits.swift b/Sources/SwiftSyntax/generated/SyntaxTraits.swift index ea73d621500..bf4e7438523 100644 --- a/Sources/SwiftSyntax/generated/SyntaxTraits.swift +++ b/Sources/SwiftSyntax/generated/SyntaxTraits.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - BracedSyntax diff --git a/Sources/SwiftSyntax/generated/SyntaxVisitor.swift b/Sources/SwiftSyntax/generated/SyntaxVisitor.swift index addc5278115..d4f0837a3d1 100644 --- a/Sources/SwiftSyntax/generated/SyntaxVisitor.swift +++ b/Sources/SwiftSyntax/generated/SyntaxVisitor.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// The enum describes how the ``SyntaxVisitor`` should continue after visiting /// the current node. diff --git a/Sources/SwiftSyntax/generated/TokenKind.swift b/Sources/SwiftSyntax/generated/TokenKind.swift index 74946e17d78..10589e1b4e4 100644 --- a/Sources/SwiftSyntax/generated/TokenKind.swift +++ b/Sources/SwiftSyntax/generated/TokenKind.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// Enumerates the kinds of tokens in the Swift language. public enum TokenKind: Hashable, Sendable { diff --git a/Sources/SwiftSyntax/generated/Tokens.swift b/Sources/SwiftSyntax/generated/Tokens.swift index 73e803bf07a..421aa3ed3d9 100644 --- a/Sources/SwiftSyntax/generated/Tokens.swift +++ b/Sources/SwiftSyntax/generated/Tokens.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file extension TokenSyntax { public static func arrowToken( diff --git a/Sources/SwiftSyntax/generated/TriviaPieces.swift b/Sources/SwiftSyntax/generated/TriviaPieces.swift index 8420696d9dc..448a692506a 100644 --- a/Sources/SwiftSyntax/generated/TriviaPieces.swift +++ b/Sources/SwiftSyntax/generated/TriviaPieces.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// A contiguous stretch of a single kind of trivia. The constituent part of /// a ``Trivia`` collection. diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesAB.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesAB.swift index dc94c05db62..530a95fad51 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesAB.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesAB.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(ExperimentalLanguageFeatures) @_spi(RawSyntax) diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesC.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesC.swift index 26628d62c31..0ba00f62983 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesC.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesC.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public struct Raw_CanImportExprSyntax: RawExprSyntaxNodeProtocol { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesD.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesD.swift index bfb6248909d..d9f5b337aea 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesD.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesD.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public protocol RawDeclSyntaxNodeProtocol: RawSyntaxNodeProtocol {} diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesEF.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesEF.swift index 0f22f3561e4..5d4947c2166 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesEF.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesEF.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public protocol RawExprSyntaxNodeProtocol: RawSyntaxNodeProtocol {} diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesGHI.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesGHI.swift index 98a08bbcf8a..0d7cdbbd7b0 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesGHI.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesGHI.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public struct RawGenericArgumentClauseSyntax: RawSyntaxNodeProtocol { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift index 8943c340f96..716500d56e9 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public struct RawKeyPathComponentListSyntax: RawSyntaxNodeProtocol { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesOP.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesOP.swift index 92769c67809..519ec0aa7de 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesOP.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesOP.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public protocol RawPatternSyntaxNodeProtocol: RawSyntaxNodeProtocol {} diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift index a470f1fcd20..fdfa430ff8e 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public protocol RawStmtSyntaxNodeProtocol: RawSyntaxNodeProtocol {} diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesTUVWXYZ.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesTUVWXYZ.swift index 7b4cd43f3d1..93d810ff8b0 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesTUVWXYZ.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesTUVWXYZ.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file @_spi(RawSyntax) public protocol RawTypeSyntaxNodeProtocol: RawSyntaxNodeProtocol {} diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index 29fa79504f0..29ea1d169ed 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file /// Check that the `layout` is valid for the given 'SyntaxKind'. /// diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift index 9eb5c55c70d..a618d979adb 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - ABIAttributeArgumentsSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift index 2b2ff47ac3b..e8873066ac2 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - _CanImportExprSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift index 3489e4b7b02..6c8b49198a3 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - DeclModifierDetailSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesEF.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesEF.swift index 16ba2c3789c..f56998d366c 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesEF.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesEF.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - EditorPlaceholderDeclSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift index a5ea4e5b12d..a44e3dee26f 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - GenericArgumentClauseSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift index 882d54cd112..585f1d5b30a 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - KeyPathComponentSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesOP.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesOP.swift index 7a05bae1bb1..eded78ece74 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesOP.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesOP.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - ObjCSelectorPieceSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift index 45a63b99074..61006bd6478 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - RegexLiteralExprSyntax diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift index d0a1ee418c8..87ac2d7cae0 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file // MARK: - TernaryExprSyntax diff --git a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift index dac72f24a88..e4f0ef83342 100644 --- a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift +++ b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) public import SwiftSyntax diff --git a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift index 315c88c4396..6629c0a42de 100644 --- a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift +++ b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) public import SwiftSyntax diff --git a/Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift b/Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift index b25f3fe36e5..c6c34003dfa 100644 --- a/Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift +++ b/Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) public import SwiftSyntax diff --git a/Sources/SwiftSyntaxBuilder/generated/SyntaxExpressibleByStringInterpolationConformances.swift b/Sources/SwiftSyntaxBuilder/generated/SyntaxExpressibleByStringInterpolationConformances.swift index a4df90cbb35..eaab028c7a1 100644 --- a/Sources/SwiftSyntaxBuilder/generated/SyntaxExpressibleByStringInterpolationConformances.swift +++ b/Sources/SwiftSyntaxBuilder/generated/SyntaxExpressibleByStringInterpolationConformances.swift @@ -9,8 +9,9 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -//// Automatically generated by generate-swift-syntax -//// Do not edit directly! +// Automatically generated by generate-swift-syntax +// Do not edit directly! +// swift-format-ignore-file #if compiler(>=6) @_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) @_spi(Compiler) internal import SwiftSyntax diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift index 5627fb504d9..15f1e3f4269 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/SwiftSyntaxDevUtils.swift @@ -26,7 +26,6 @@ struct SwiftSyntaxDevUtils: ParsableCommand { """, subcommands: [ Build.self, - Format.self, GenerateSourceCode.self, LocalPrPrecheck.self, Test.self, diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Format.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Format.swift deleted file mode 100644 index a5c8248af9d..00000000000 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Format.swift +++ /dev/null @@ -1,314 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import ArgumentParser -import Foundation - -/// Directories that should not be formatted. -fileprivate let directoriesToExclude = [ - "lit_tests", - "generated", - "build", - "Inputs", - ".build", - ".index-build", - ".swift-format-build", -] - -struct Format: ParsableCommand { - static let configuration = CommandConfiguration( - abstract: "Format files in SwiftSyntax using swift-format.", - discussion: """ - This command automatically builds the '\(FormatExecutor.swiftFormatBranch)' branch \ - of swift-format in the '\(Paths.swiftFormatBuildDir.lastPathComponent)' \ - directory of this repository and uses the build to format the swift-syntax \ - sources. - """ - ) - - @Flag(help: "Update the sources of swift-format and rebuild swift-format") - var update: Bool = false - - @Flag( - help: """ - Instead of formatting in-place, verify that the files are correctly formatted. \ - Exit with 1 if files are not correctly formatted. - """ - ) - var lint: Bool = false - - @Option( - help: """ - Instead of building a local swift-format, use this swift-format executable. \ - Should primarily be used for CI, which has already built swift-format. - """ - ) - var swiftFormat: String? = nil - - @Flag(help: "Enable verbose logging.") - var verbose: Bool = false - - func run() throws { - let executor = FormatExecutor( - update: update, - lint: lint, - swiftFormat: swiftFormat, - verbose: verbose - ) - try executor.run() - } -} - -struct FormatExecutor { - private enum Error: Swift.Error, CustomStringConvertible { - case swiftFormatNotFound - case lintFailed - - var description: String { - switch self { - case .swiftFormatNotFound: - return "The locally built swift-format could not be found" - case .lintFailed: - return """ - The swift-syntax repo is not formatted according to the style guides. - - Run the following command to format swift-syntax - - ./swift-syntax-dev-utils format - - If the issue persists, try updating swift-format by running - - ./swift-syntax-dev-utils format --update - - Should that still fail, fix any remaining issues manually and verify they match the swift-format style using - - ./swift-syntax-dev-utils format --lint - """ - } - } - } - - /// Update the sources of swift-format and rebuild swift-format - private let update: Bool - - /// Instead of formatting in-place, verify that the files are correctly formatted. - /// - /// Exit with 1 if files are not correctly formatted. - private let lint: Bool - - /// Instead of building a local swift-format, use this swift-format executable. - /// - /// Should primarily be used for CI, which has already built swift-format. - private let swiftFormat: String? - - /// Enable verbose logging. - private let verbose: Bool - - /// The branch of swift-format to build. - static let swiftFormatBranch: String = "main" - - /// The configuration to build swift-format in. - private static let swiftFormatBuildConfiguration: String = "release" - - /// Creates an Executor - /// - Parameters: - /// - update: Update the sources of swift-format and rebuild swift-format - /// - lint: Instead of formatting in-place, verify that the files are correctly formatted. - /// - swiftFormat: Instead of building a local swift-format, use this swift-format executable. - /// - verbose: Enable verbose logging. - init( - update: Bool, - lint: Bool = false, - swiftFormat: String? = nil, - verbose: Bool = false - ) { - self.update = update - self.lint = lint - self.swiftFormat = swiftFormat - self.verbose = verbose - } - - /// Run `git` in the .swift-format-build directory with the provided arguments. - private func runGitCommand(_ arguments: String...) throws { - try ProcessRunner( - executableURL: Paths.gitExec, - arguments: ["-C", Paths.swiftFormatBuildDir.path] + arguments - ).run( - captureStdout: false, - captureStderr: false, - verbose: verbose - ) - } - - /// Run `swift` for the `.swift-format-build` package with the provided arguments. - private func runSwiftCommand(_ action: String, _ arguments: String...) throws { - try ProcessRunner( - executableURL: Paths.swiftExec, - arguments: [action, "--package-path", Paths.swiftFormatBuildDir.path] + arguments - ).run( - captureStdout: false, - captureStderr: false, - verbose: verbose - ) - } - - /// Ensure that we have an up-to-date checkout of swift-format in `.swift-format-build`. - private func cloneOrUpdateSwiftFormat() throws { - if FileManager.default.fileExists(atPath: Paths.swiftFormatBuildDir.appendingPathComponent(".git").path) { - try runGitCommand("checkout", Self.swiftFormatBranch) - try runGitCommand("pull") - } else { - try FileManager.default.createDirectory(atPath: Paths.swiftFormatBuildDir.path, withIntermediateDirectories: true) - try runGitCommand("clone", "https://github.com/swiftlang/swift-format.git", ".") - try runGitCommand("checkout", Self.swiftFormatBranch) - } - try runSwiftCommand("package", "update") - } - - /// Build the swift-format executable. - private func buildSwiftFormat() throws { - try runSwiftCommand("build", "--product", "swift-format", "--configuration", Self.swiftFormatBuildConfiguration) - } - - /// Get the URL of the locally-built swift-format executable. - private func findSwiftFormatExecutable() throws -> URL { - if let swiftFormat = swiftFormat { - return URL(fileURLWithPath: swiftFormat) - } - - // We could run `swift build --show-bin-path` here but that takes 0.4s. - // Since the path seems really stable, let’s build the path ourselves. - let swiftFormatExec = URL(fileURLWithPath: Paths.swiftFormatBuildDir.path) - .appendingPathComponent(".build") - .appendingPathComponent(Self.swiftFormatBuildConfiguration) - .appendingPathComponent("swift-format") - if !swiftFormatExec.isExecutableFile { - throw Error.swiftFormatNotFound - } - return swiftFormatExec - } - - /// Get the list of files that should be formatted using swift-format. - /// - /// This excludes some files like generated files or test inputs. - private func filesToFormat() -> [URL] { - guard - let enumerator = FileManager.default.enumerator( - at: Paths.packageDir.resolvingSymlinksInPath(), - includingPropertiesForKeys: [], - options: [] - ) - else { - return [] - } - - var result: [URL] = [] - for case let url as URL in enumerator { - if directoriesToExclude.contains(url.lastPathComponent) { - enumerator.skipDescendants() - } - if url.pathExtension == "swift" { - result.append(url) - } - } - - return result - } - - /// Format all files in the repo using the locally-built swift-format. - private func formatFilesInRepo() throws { - let swiftFormatExecutable = try findSwiftFormatExecutable() - - let filesToFormat = self.filesToFormat() - - try ProcessRunner( - executableURL: swiftFormatExecutable, - arguments: [ - "format", - "--in-place", - "--parallel", - ] + filesToFormat.map { $0.path } - ) - .run( - captureStdout: false, - captureStderr: false, - verbose: verbose - ) - } - - /// Lint all files in the repo using the locally-built swift-format. - private func lintFilesInRepo() throws { - let swiftFormatExecutable = try findSwiftFormatExecutable() - - let filesToFormat = self.filesToFormat() - - do { - try ProcessRunner( - executableURL: swiftFormatExecutable, - arguments: [ - "lint", - "--strict", - "--parallel", - ] + filesToFormat.map { $0.path } - ) - .run( - captureStdout: false, - captureStderr: false, - verbose: verbose - ) - } catch is NonZeroExitCodeError { - throw Error.lintFailed - } - } - - func run() throws { - #if compiler(<5.10) - print( - "💡 You are building running the format script with Swift 5.9 or lower. Running it with SwiftPM 5.10 is about 10s faster." - ) - #endif - - try run(updateAndBuild: update) - } - - /// - Parameter updateAndBuild: Whether to update the locally checked out - /// swift-format sources and rebuild swift-format. - private func run(updateAndBuild: Bool) throws { - if updateAndBuild { - try cloneOrUpdateSwiftFormat() - try buildSwiftFormat() - } - do { - if lint { - try lintFilesInRepo() - } else { - try formatFilesInRepo() - } - } catch Error.swiftFormatNotFound { - if !updateAndBuild { - print( - """ - No build of swift-format was found in '\(Paths.swiftFormatBuildDir.lastPathComponent)'. - Building swift-format now. This may take a couple of minutes. - Future invocations of this command will re-use the build and are much faster. - - """ - ) - - // If swift-format cannot be found, try again, updating (aka cloning + building) swift-format this time - try run(updateAndBuild: true) - } else { - throw Error.swiftFormatNotFound - } - } - } -} diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/LocalPrPrecheck.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/LocalPrPrecheck.swift index 3eec83dc46d..1d03ed4f2ff 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/LocalPrPrecheck.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/LocalPrPrecheck.swift @@ -33,7 +33,7 @@ struct LocalPrPrecheck: ParsableCommand { } struct LocalPrPrecheckExecutor { - private let formatExecutor: FormatExecutor + private let verbose: Bool private let generateSourceCodeExecutor: GenerateSourceCodeExecutor private let buildExecutor: BuildExecutor private let testExecutor: TestExecutor @@ -43,7 +43,7 @@ struct LocalPrPrecheckExecutor { /// - toolchain: The path to the toolchain that shall be used to build SwiftSyntax. /// - verbose: Enable verbose logging. init(toolchain: URL, verbose: Bool = false) { - self.formatExecutor = FormatExecutor(update: false, verbose: verbose) + self.verbose = verbose self.generateSourceCodeExecutor = GenerateSourceCodeExecutor(toolchain: toolchain, verbose: verbose) self.buildExecutor = BuildExecutor( swiftPMBuilder: SwiftPMBuilder(toolchain: toolchain, useLocalDeps: false, verbose: verbose) @@ -53,8 +53,16 @@ struct LocalPrPrecheckExecutor { ) } + private func checkFormatting() throws { + try ProcessRunner( + executableURL: Paths.swiftExec, + arguments: ["format", "lint", "--strict", "--parallel", "--recursive", Paths.sourcesDir.path] + ) + .run(captureStdout: false, captureStderr: false, verbose: verbose) + } + func run() throws { - try formatExecutor.run() + try checkFormatting() try generateSourceCodeExecutor.run(sourceDir: Paths.sourcesDir) try buildExecutor.run() try testExecutor.run()