diff --git a/.swift-format b/.swift-format index 176687e2845..b7858d911ea 100644 --- a/.swift-format +++ b/.swift-format @@ -1,20 +1,78 @@ { - "version": 1, - "lineLength": 120, + "fileScopedDeclarationPrivacy": { + "accessLevel": "private" + }, + "indentConditionalCompilationBlocks": false, + "indentSwitchCaseLabels": false, "indentation": { "spaces": 2 }, + "lineBreakAroundMultilineExpressionChainComponents": false, + "lineBreakBeforeControlFlowKeywords": false, "lineBreakBeforeEachArgument": true, - "indentConditionalCompilationBlocks": false, + "lineBreakBeforeEachGenericRequirement": false, + "lineBreakBetweenDeclarationAttributes": false, + "lineLength": 120, + "maximumBlankLines": 1, + "multiElementCollectionTrailingCommas": true, + "noAssignmentInExpressions": { + "allowedFunctions": [ + "XCTAssertNoThrow" + ] + }, "prioritizeKeepingFunctionOutputTogether": true, + "reflowMultilineStringLiterals": { + "never": { + + } + }, + "respectsExistingLineBreaks": true, "rules": { + "AllPublicDeclarationsHaveDocumentation": false, + "AlwaysUseLiteralForEmptyCollectionInit": false, "AlwaysUseLowerCamelCase": false, "AmbiguousTrailingClosureOverload": false, + "AvoidRetroactiveConformances": true, + "BeginDocumentationCommentWithOneLineSummary": false, + "DoNotUseSemicolons": false, + "DontRepeatTypeInStaticProperties": true, + "FileScopedDeclarationPrivacy": true, + "FullyIndirectEnum": true, + "GroupNumericLiterals": true, + "IdentifiersMustBeASCII": true, + "NeverForceUnwrap": false, + "NeverUseForceTry": false, + "NeverUseImplicitlyUnwrappedOptionals": false, + "NoAccessLevelOnExtensionDeclaration": false, + "NoAssignmentInExpressions": true, "NoBlockComments": false, + "NoCasesWithOnlyFallthrough": true, + "NoEmptyLinesOpeningClosingBraces": false, + "NoEmptyTrailingClosureParentheses": true, + "NoLabelsInCasePatterns": true, + "NoLeadingUnderscores": false, + "NoParensAroundConditions": true, + "NoPlaygroundLiterals": true, + "NoVoidReturnOnFunctionSignature": true, + "OmitExplicitReturns": false, + "OneCasePerLine": true, + "OneVariableDeclarationPerLine": true, + "OnlyOneTrailingClosureArgument": true, "OrderedImports": true, + "ReplaceForEachWithForLoop": true, + "ReturnVoidInsteadOfEmptyTuple": true, + "TypeNamesShouldBeCapitalized": true, + "UseEarlyExits": false, + "UseExplicitNilCheckInConditions": true, "UseLetInEveryBoundCaseVariable": false, + "UseShorthandTypeNames": true, + "UseSingleLinePropertyGetter": true, "UseSynthesizedInitializer": false, - "ReturnVoidInsteadOfEmptyTuple": true, - "NoVoidReturnOnFunctionSignature": true, - } + "UseTripleSlashForDocumentationComments": true, + "UseWhereClausesInForLoops": false, + "ValidateDocumentationComments": false + }, + "spacesAroundRangeFormationOperators": false, + "spacesBeforeEndOfLineComments": 2, + "version": 1, } diff --git a/CodeGeneration/Sources/SyntaxSupport/Child.swift b/CodeGeneration/Sources/SyntaxSupport/Child.swift index ce631b5950e..e7cd360a28b 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Child.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Child.swift @@ -129,11 +129,11 @@ public class Child: NodeChoiceConvertible { public var syntaxNodeKind: SyntaxNodeKind { switch kind { - case .node(kind: let kind): + case .node(let kind): return kind case .nodeChoices: return .syntax - case .collection(kind: let kind, _, _, _, _): + case .collection(let kind, _, _, _, _): return kind case .token: return .token @@ -284,7 +284,7 @@ public class Child: NodeChoiceConvertible { return choices.isEmpty case .node(let kind): return kind.isBase - case .collection(kind: let kind, _, _, _, _): + case .collection(let kind, _, _, _, _): return kind.isBase case .token: return false diff --git a/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift b/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift index 4d28dff2564..819cbf0f082 100644 --- a/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift +++ b/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift @@ -41,7 +41,7 @@ struct GrammarGenerator { case .nodeChoices(let choices, _): let choicesDescriptions = choices.map { grammar(for: $0) } return "(\(choicesDescriptions.joined(separator: " | ")))\(optionality)" - case .collection(kind: let kind, _, _, _, _): + case .collection(let kind, _, _, _, _): return "\(kind.doccLink)\(optionality)" case .token(let choices, _, _): if choices.count == 1 { diff --git a/CodeGeneration/Sources/SyntaxSupport/Node.swift b/CodeGeneration/Sources/SyntaxSupport/Node.swift index f1341f7e355..7a4eb9631b3 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Node.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Node.swift @@ -284,7 +284,7 @@ public struct LayoutNode { /// This includes unexpected children public var children: [Child] { switch node.data { - case .layout(children: let children, childHistory: _, traits: _): + case .layout(let children, childHistory: _, traits: _): return children case .collection: preconditionFailure("NodeLayoutView must wrap a Node with data `.layout`") @@ -299,7 +299,7 @@ public struct LayoutNode { /// The history of the layout node's children. public var childHistory: Child.History { switch node.data { - case .layout(children: _, childHistory: let childHistory, traits: _): + case .layout(children: _, let childHistory, traits: _): return childHistory case .collection: preconditionFailure("NodeLayoutView must wrap a Node with data `.layout`") @@ -309,7 +309,7 @@ public struct LayoutNode { /// Traits that the node conforms to. public var traits: [String] { switch node.data { - case .layout(children: _, childHistory: _, traits: let traits): + case .layout(children: _, childHistory: _, let traits): return traits case .collection: preconditionFailure("NodeLayoutView must wrap a Node with data `.layout`") @@ -361,7 +361,7 @@ public struct CollectionNode { switch node.data { case .layout: preconditionFailure("NodeLayoutView must wrap a Node with data `.collection`") - case .collection(choices: let choices): + case .collection(let choices): return choices } } @@ -391,7 +391,7 @@ fileprivate extension Child { return [kind] case .nodeChoices(let choices, _): return choices.flatMap(\.kinds) - case .collection(kind: let kind, _, _, _, _): + case .collection(let kind, _, _, _, _): return [kind] case .token: return [.token] @@ -399,7 +399,7 @@ fileprivate extension Child { } } -fileprivate func interleaveUnexpectedChildren(_ children: [Child]) -> [Child] { +private func interleaveUnexpectedChildren(_ children: [Child]) -> [Child] { let liftedChildren = children.lazy.map(Optional.some) let pairedChildren = zip([nil] + liftedChildren, liftedChildren + [nil]) diff --git a/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift b/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift index 6e4fb79941a..b01de637761 100644 --- a/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift +++ b/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift @@ -29,11 +29,11 @@ extension Child { public var buildableType: SyntaxBuildableType { let buildableKind: SyntaxOrTokenNodeKind switch kind { - case .node(kind: let kind): + case .node(let kind): buildableKind = .node(kind: kind) case .nodeChoices: buildableKind = .node(kind: .syntax) - case .collection(kind: let kind, _, _, _, _): + case .collection(let kind, _, _, _, _): buildableKind = .node(kind: kind) case .token: buildableKind = .token(self.tokenKind!) diff --git a/CodeGeneration/Sources/Utils/SyntaxBuildableType.swift b/CodeGeneration/Sources/Utils/SyntaxBuildableType.swift index a9b68bf05ce..a11131a6357 100644 --- a/CodeGeneration/Sources/Utils/SyntaxBuildableType.swift +++ b/CodeGeneration/Sources/Utils/SyntaxBuildableType.swift @@ -122,7 +122,7 @@ public struct SyntaxBuildableType: Hashable { /// without any question marks attached. public var syntaxBaseName: TypeSyntax { switch kind { - case .node(kind: let kind): + case .node(let kind): return kind.syntaxType case .token: return "TokenSyntax" @@ -150,7 +150,7 @@ public struct SyntaxBuildableType: Hashable { /// that can be used to build the collection. public var resultBuilderType: TypeSyntax { switch kind { - case .node(kind: let kind): + case .node(let kind): return TypeSyntax("\(raw: kind.uppercasedFirstWordRawValue)Builder") case .token: preconditionFailure("Tokens cannot be constructed using result builders") diff --git a/CodeGeneration/Sources/generate-swift-syntax/GenerateSwiftSyntax.swift b/CodeGeneration/Sources/generate-swift-syntax/GenerateSwiftSyntax.swift index 4889bf1d639..9ca90dcc3ed 100644 --- a/CodeGeneration/Sources/generate-swift-syntax/GenerateSwiftSyntax.swift +++ b/CodeGeneration/Sources/generate-swift-syntax/GenerateSwiftSyntax.swift @@ -226,7 +226,7 @@ struct GenerateSwiftSyntax: AsyncParsableCommand { } -fileprivate func generateFile( +private func generateFile( contents: @autoclosure () -> String, destination: URL, verbose: Bool diff --git a/CodeGeneration/Sources/generate-swift-syntax/InitSignature+Extensions.swift b/CodeGeneration/Sources/generate-swift-syntax/InitSignature+Extensions.swift index 97a61847829..57a28de5a82 100644 --- a/CodeGeneration/Sources/generate-swift-syntax/InitSignature+Extensions.swift +++ b/CodeGeneration/Sources/generate-swift-syntax/InitSignature+Extensions.swift @@ -191,7 +191,7 @@ extension InitSignature { } } -fileprivate func convertFromSyntaxProtocolToSyntaxType( +private func convertFromSyntaxProtocolToSyntaxType( child: Child ) -> ExprSyntax { let childName = child.identifier @@ -350,7 +350,7 @@ extension InitParameterMapping { func makeArgumentExpr() -> LabeledExprSyntax { let argValue = switch argument { - case .decl(olderChild: let olderChild): + case .decl(let olderChild): ExprSyntax(DeclReferenceExprSyntax(baseName: olderChild.baseCallName)) case .nestedInit(let initArgs): diff --git a/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/RawSyntaxValidationFile.swift b/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/RawSyntaxValidationFile.swift index 15ea4eacba3..c4936f8d8df 100644 --- a/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/RawSyntaxValidationFile.swift +++ b/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/RawSyntaxValidationFile.swift @@ -209,7 +209,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead } ExprSyntax("assertAnyHasNoError(kind, \(raw: index), \(verifiedChoices))") - case .token(choices: let choices, requiresLeadingSpace: _, requiresTrailingSpace: _): + case .token(let choices, requiresLeadingSpace: _, requiresTrailingSpace: _): let choices = ArrayExprSyntax { for choice in choices { switch choice { diff --git a/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TriviaPiecesFile.swift b/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TriviaPiecesFile.swift index 937ca2639ce..24f31b9c2d2 100644 --- a/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TriviaPiecesFile.swift +++ b/CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TriviaPiecesFile.swift @@ -268,7 +268,7 @@ let triviaPiecesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { try! generateIsHelpers(for: "RawTriviaPiece") } -fileprivate func generateIsHelpers(for pieceName: TokenSyntax) throws -> ExtensionDeclSyntax { +private func generateIsHelpers(for pieceName: TokenSyntax) throws -> ExtensionDeclSyntax { func generateHelper(_ header: SyntaxNodeString, trait: TriviaTraits) throws -> VariableDeclSyntax { try VariableDeclSyntax(header) { try SwitchExprSyntax("switch self") { diff --git a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift index e1b9a73df15..69a489c0f01 100644 --- a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift +++ b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift @@ -13,7 +13,7 @@ import SyntaxSupport import XCTest -fileprivate func assertNoFailures( +private func assertNoFailures( _ failures: [ValidationFailure], message: String, file: StaticString = #filePath, @@ -34,7 +34,7 @@ fileprivate func assertNoFailures( XCTFail(message, file: file, line: line) } -fileprivate func assertFailuresMatchXFails( +private func assertFailuresMatchXFails( _ failures: [ValidationFailure], expectedFailures: [ValidationFailure], file: StaticString = #filePath, diff --git a/Examples/Sources/MacroExamples/Implementation/ComplexMacros/OptionSetMacro.swift b/Examples/Sources/MacroExamples/Implementation/ComplexMacros/OptionSetMacro.swift index 2d1706c9114..6a14a93213f 100644 --- a/Examples/Sources/MacroExamples/Implementation/ComplexMacros/OptionSetMacro.swift +++ b/Examples/Sources/MacroExamples/Implementation/ComplexMacros/OptionSetMacro.swift @@ -195,7 +195,7 @@ extension OptionSetMacro: MemberMacro { // Find all of the case elements. let caseElements: [EnumCaseElementSyntax] = optionsEnum.memberBlock.members.flatMap { member in guard let caseDecl = member.decl.as(EnumCaseDeclSyntax.self) else { - return Array() + return [EnumCaseElementSyntax]() } return Array(caseDecl.elements) diff --git a/Examples/Sources/MacroExamples/Implementation/Expression/URLMacro.swift b/Examples/Sources/MacroExamples/Implementation/Expression/URLMacro.swift index 5b5ccf88951..c811c054158 100644 --- a/Examples/Sources/MacroExamples/Implementation/Expression/URLMacro.swift +++ b/Examples/Sources/MacroExamples/Implementation/Expression/URLMacro.swift @@ -29,7 +29,7 @@ public enum URLMacro: ExpressionMacro { throw CustomError.message("#URL requires a static string literal") } - guard let _ = URL(string: literalSegment.content.text) else { + guard URL(string: literalSegment.content.text) != nil else { throw CustomError.message("malformed url: \(argument)") } diff --git a/Examples/Sources/MacroExamples/Implementation/Member/MetaEnumMacro.swift b/Examples/Sources/MacroExamples/Implementation/Member/MetaEnumMacro.swift index af65ab35148..03f66de7391 100644 --- a/Examples/Sources/MacroExamples/Implementation/Member/MetaEnumMacro.swift +++ b/Examples/Sources/MacroExamples/Implementation/Member/MetaEnumMacro.swift @@ -95,7 +95,7 @@ extension EnumDeclSyntax { var caseElements: [EnumCaseElementSyntax] { memberBlock.members.flatMap { member in guard let caseDecl = member.decl.as(EnumCaseDeclSyntax.self) else { - return Array() + return [EnumCaseElementSyntax]() } return Array(caseDecl.elements) diff --git a/Sources/SwiftBasicFormat/InferIndentation.swift b/Sources/SwiftBasicFormat/InferIndentation.swift index a0c601534dc..0c6d4868496 100644 --- a/Sources/SwiftBasicFormat/InferIndentation.swift +++ b/Sources/SwiftBasicFormat/InferIndentation.swift @@ -124,7 +124,7 @@ private class IndentationInferrer: SyntaxVisitor { } } -fileprivate extension Array { +fileprivate extension [Int] { var sum: Int { return self.reduce(0) { return $0 + $1 } } diff --git a/Sources/SwiftIDEUtils/DeclNameLocation.swift b/Sources/SwiftIDEUtils/DeclNameLocation.swift index c5176f42443..18df8864b1d 100644 --- a/Sources/SwiftIDEUtils/DeclNameLocation.swift +++ b/Sources/SwiftIDEUtils/DeclNameLocation.swift @@ -68,9 +68,9 @@ public struct DeclNameLocation: Equatable { case .labeled(let firstName, let secondName): let endPosition = secondName?.upperBound ?? firstName.upperBound return firstName.lowerBound.. DeclNameLocation.Argument { switch self { - case .labeled(firstName: let firstName, secondName: let secondName): + case .labeled(let firstName, let secondName): return .labeled(firstName: firstName.advanced(by: utf8Offset), secondName: secondName?.advanced(by: utf8Offset)) - case .labeledCall(label: let label, colon: let colon): + case .labeledCall(let label, let colon): return .labeledCall(label: label.advanced(by: utf8Offset), colon: colon.advanced(by: utf8Offset)) - case .unlabeled(argumentPosition: let argumentPosition): + case .unlabeled(let argumentPosition): return .unlabeled(argumentPosition: argumentPosition.advanced(by: utf8Offset)) } } @@ -122,7 +122,7 @@ public struct DeclNameLocation: Equatable { switch self { case .noArguments: return .noArguments - case .call(let arguments, firstTrailingClosureIndex: let firstTrailingClosureIndex): + case .call(let arguments, let firstTrailingClosureIndex): return .call( arguments.map { $0.advanced(by: utf8Offset) }, firstTrailingClosureIndex: firstTrailingClosureIndex diff --git a/Sources/SwiftIDEUtils/SyntaxClassifier.swift b/Sources/SwiftIDEUtils/SyntaxClassifier.swift index 586f0e060f8..b12d22df33c 100644 --- a/Sources/SwiftIDEUtils/SyntaxClassifier.swift +++ b/Sources/SwiftIDEUtils/SyntaxClassifier.swift @@ -55,7 +55,7 @@ extension RawTriviaPiece { } } -fileprivate struct TokenKindAndText { +private struct TokenKindAndText { let kind: RawTokenKind let text: SyntaxText diff --git a/Sources/SwiftIfConfig/ActiveSyntaxRewriter.swift b/Sources/SwiftIfConfig/ActiveSyntaxRewriter.swift index f4ac3b4c695..d1822c1f087 100644 --- a/Sources/SwiftIfConfig/ActiveSyntaxRewriter.swift +++ b/Sources/SwiftIfConfig/ActiveSyntaxRewriter.swift @@ -188,7 +188,7 @@ class ActiveSyntaxRewriter: SyntaxRewriter { // Find #ifs within the list. if let ifConfigDecl = elementAsIfConfig(element), - (!retainFeatureCheckIfConfigs || !ifConfigDecl.containsFeatureCheck) + !retainFeatureCheckIfConfigs || !ifConfigDecl.containsFeatureCheck { // Retrieve the active `#if` clause let activeClause = activeClauses.activeClause(for: ifConfigDecl, diagnostics: &diagnostics) @@ -392,7 +392,7 @@ class ActiveSyntaxRewriter: SyntaxRewriter { } /// Helper class to find a feature or compiler check. -fileprivate class FindFeatureCheckVisitor: SyntaxVisitor { +private class FindFeatureCheckVisitor: SyntaxVisitor { var foundFeatureCheck = false override func visit(_ node: DeclReferenceExprSyntax) -> SyntaxVisitorContinueKind { @@ -411,7 +411,7 @@ fileprivate class FindFeatureCheckVisitor: SyntaxVisitor { override func visit(_ node: FunctionCallExprSyntax) -> SyntaxVisitorContinueKind { if let calleeDeclRef = node.calledExpression.as(DeclReferenceExprSyntax.self), let calleeName = calleeDeclRef.simpleIdentifier?.name, - (calleeName == "compiler" || calleeName == "_compiler_version") + calleeName == "compiler" || calleeName == "_compiler_version" { foundFeatureCheck = true } diff --git a/Sources/SwiftIfConfig/ConfiguredRegions.swift b/Sources/SwiftIfConfig/ConfiguredRegions.swift index 67d1afb29c6..7329ba324c3 100644 --- a/Sources/SwiftIfConfig/ConfiguredRegions.swift +++ b/Sources/SwiftIfConfig/ConfiguredRegions.swift @@ -174,7 +174,7 @@ extension SyntaxProtocol { } /// Helper class that walks a syntax tree looking for configured regions. -fileprivate class ConfiguredRegionVisitor: SyntaxVisitor { +private class ConfiguredRegionVisitor: SyntaxVisitor { let configuration: Configuration /// The regions we've found so far. diff --git a/Sources/SwiftIfConfig/IfConfigDiagnostic.swift b/Sources/SwiftIfConfig/IfConfigDiagnostic.swift index b2ad7bd2f69..a8deec63227 100644 --- a/Sources/SwiftIfConfig/IfConfigDiagnostic.swift +++ b/Sources/SwiftIfConfig/IfConfigDiagnostic.swift @@ -47,22 +47,22 @@ enum IfConfigDiagnostic: Error, CustomStringConvertible { case .unknownExpression: return "invalid conditional compilation expression" - case .unhandledFunction(name: let name, syntax: _): + case .unhandledFunction(let name, syntax: _): return "build configuration cannot handle '\(name)'" - case .requiresUnlabeledArgument(name: let name, role: let role, syntax: _): + case .requiresUnlabeledArgument(let name, let role, syntax: _): return "'\(name)' requires a single unlabeled argument for the \(role)" - case .unsupportedVersionOperator(name: let name, operator: let op): + case .unsupportedVersionOperator(let name, operator: let op): return "'\(name)' version check does not support operator '\(op.trimmedDescription)'" - case .invalidVersionOperand(name: let name, syntax: let version): + case .invalidVersionOperand(let name, syntax: let version): return "'\(name)' version check has invalid version '\(version.trimmedDescription)'" case .emptyVersionComponent(syntax: _): return "found empty version component" - case .compilerVersionOutOfRange(value: let value, upperLimit: let upperLimit, syntax: _): + case .compilerVersionOutOfRange(let value, let upperLimit, syntax: _): return "compiler version component '\(value)' is not in the allowed range 0...\(upperLimit)" case .compilerVersionSecondComponentNotWildcard(syntax: _): @@ -80,10 +80,10 @@ enum IfConfigDiagnostic: Error, CustomStringConvertible { case .canImportTwoParameters(syntax: _): return "'canImport' can take only two parameters" - case .ignoredTrailingComponents(version: let version, syntax: _): + case .ignoredTrailingComponents(let version, syntax: _): return "trailing components of version '\(version.description)' are ignored" - case .integerLiteralCondition(syntax: let syntax, replacement: let replacement): + case .integerLiteralCondition(let syntax, let replacement): return "'\(syntax.trimmedDescription)' is not a valid conditional compilation expression, use '\(replacement)'" case .likelySimulatorPlatform: @@ -121,26 +121,26 @@ enum IfConfigDiagnostic: Error, CustomStringConvertible { var syntax: Syntax { switch self { case .unknownExpression(let syntax), - .unhandledFunction(name: _, syntax: let syntax), - .requiresUnlabeledArgument(name: _, role: _, syntax: let syntax), - .invalidVersionOperand(name: _, syntax: let syntax), - .emptyVersionComponent(syntax: let syntax), - .compilerVersionOutOfRange(value: _, upperLimit: _, syntax: let syntax), - .compilerVersionTooManyComponents(syntax: let syntax), - .compilerVersionSecondComponentNotWildcard(syntax: let syntax), - .canImportMissingModule(syntax: let syntax), - .canImportLabel(syntax: let syntax), - .canImportTwoParameters(syntax: let syntax), - .ignoredTrailingComponents(version: _, syntax: let syntax), - .integerLiteralCondition(syntax: let syntax, replacement: _), - .likelySimulatorPlatform(syntax: let syntax), - .likelyTargetOS(syntax: let syntax, replacement: _), - .endiannessDoesNotMatch(syntax: let syntax, argument: _), - .macabiIsMacCatalyst(syntax: let syntax), - .expectedModuleName(syntax: let syntax), - .badInfixOperator(syntax: let syntax), - .badPrefixOperator(syntax: let syntax), - .unexpectedDefined(syntax: let syntax, argument: _): + .unhandledFunction(name: _, let syntax), + .requiresUnlabeledArgument(name: _, role: _, let syntax), + .invalidVersionOperand(name: _, let syntax), + .emptyVersionComponent(let syntax), + .compilerVersionOutOfRange(value: _, upperLimit: _, let syntax), + .compilerVersionTooManyComponents(let syntax), + .compilerVersionSecondComponentNotWildcard(let syntax), + .canImportMissingModule(let syntax), + .canImportLabel(let syntax), + .canImportTwoParameters(let syntax), + .ignoredTrailingComponents(version: _, let syntax), + .integerLiteralCondition(let syntax, replacement: _), + .likelySimulatorPlatform(let syntax), + .likelyTargetOS(let syntax, replacement: _), + .endiannessDoesNotMatch(let syntax, argument: _), + .macabiIsMacCatalyst(let syntax), + .expectedModuleName(let syntax), + .badInfixOperator(let syntax), + .badPrefixOperator(let syntax), + .unexpectedDefined(let syntax, argument: _): return Syntax(syntax) case .unsupportedVersionOperator(name: _, operator: let op): diff --git a/Sources/SwiftIfConfig/IfConfigEvaluation.swift b/Sources/SwiftIfConfig/IfConfigEvaluation.swift index 67141335684..3abb915f3bc 100644 --- a/Sources/SwiftIfConfig/IfConfigEvaluation.swift +++ b/Sources/SwiftIfConfig/IfConfigEvaluation.swift @@ -79,7 +79,7 @@ func evaluateIfConfig( // Integer literals aren't allowed, but we recognize them. if let intLiteral = condition.as(IntegerLiteralExprSyntax.self), - (intLiteral.literal.text == "0" || intLiteral.literal.text == "1") + intLiteral.literal.text == "0" || intLiteral.literal.text == "1" { let result = intLiteral.literal.text == "1" diff --git a/Sources/SwiftIfConfig/VersionTuple+Parsing.swift b/Sources/SwiftIfConfig/VersionTuple+Parsing.swift index d72100864c7..804f5185db8 100644 --- a/Sources/SwiftIfConfig/VersionTuple+Parsing.swift +++ b/Sources/SwiftIfConfig/VersionTuple+Parsing.swift @@ -56,7 +56,7 @@ extension VersionTuple { /// Record a component after checking its value. func recordComponent(_ value: Int) throws { - let limit = components.isEmpty ? 9223371 : 999 + let limit = components.isEmpty ? 9_223_371 : 999 if value < 0 || value > limit { throw IfConfigDiagnostic.compilerVersionOutOfRange(value: value, upperLimit: limit, syntax: versionSyntax) } diff --git a/Sources/SwiftParser/Expressions.swift b/Sources/SwiftParser/Expressions.swift index 70e2a433f56..eafa624b1e4 100644 --- a/Sources/SwiftParser/Expressions.swift +++ b/Sources/SwiftParser/Expressions.swift @@ -53,7 +53,7 @@ extension TokenConsumer { } // 'repeat' is the start of a pack expansion expression. - if (self.at(.keyword(.repeat))) { + if self.at(.keyword(.repeat)) { // FIXME: 'repeat' followed by '{' could still be a pack // expansion, but we need to do more lookahead to figure out // whether the '{' is the start of a closure expression or a @@ -2551,7 +2551,7 @@ extension Parser.Lookahead { // Consume attributes. var lookahead = self.lookahead() var attributesProgress = LoopProgressCondition() - while let _ = lookahead.consume(if: .atSign), lookahead.hasProgressed(&attributesProgress) { + while lookahead.consume(if: .atSign) != nil, lookahead.hasProgressed(&attributesProgress) { guard lookahead.at(.identifier) else { break } diff --git a/Sources/SwiftParser/IncrementalParseTransition.swift b/Sources/SwiftParser/IncrementalParseTransition.swift index 730f5112da0..3d5d6debceb 100644 --- a/Sources/SwiftParser/IncrementalParseTransition.swift +++ b/Sources/SwiftParser/IncrementalParseTransition.swift @@ -208,7 +208,7 @@ struct IncrementalParseLookup { /// Functions as an iterator that walks the tree looking for nodes with a /// certain position. -fileprivate struct SyntaxCursor { +private struct SyntaxCursor { var node: Syntax var finished: Bool let viewMode = SyntaxTreeViewMode.sourceAccurate diff --git a/Sources/SwiftParser/Lexer/Cursor.swift b/Sources/SwiftParser/Lexer/Cursor.swift index 13d2af8c289..843dbf409d7 100644 --- a/Sources/SwiftParser/Lexer/Cursor.swift +++ b/Sources/SwiftParser/Lexer/Cursor.swift @@ -176,7 +176,7 @@ extension Lexer.Cursor { mutating func perform(stateTransition: Lexer.StateTransition, stateAllocator: BumpPtrAllocator) { switch stateTransition { - case .push(newState: let newState): + case .push(let newState): if let topState { if let stateStack = stateStack { let newStateStack = stateAllocator.allocate(State.self, count: stateStack.count + 1) @@ -197,7 +197,7 @@ extension Lexer.Cursor { ), stateAllocator: stateAllocator ) - case .replace(newState: let newState): + case .replace(let newState): topState = newState case .pop: if let stateStack { @@ -449,17 +449,17 @@ extension Lexer.Cursor { // In this state we lex a single token with the flag set, and then pop the state. result = lexNormal(sourceBufferStart: sourceBufferStart, preferRegexOverBinaryOperator: true) self.stateStack.perform(stateTransition: .pop, stateAllocator: stateAllocator) - case .afterRawStringDelimiter(delimiterLength: let delimiterLength): + case .afterRawStringDelimiter(let delimiterLength): result = lexAfterRawStringDelimiter(delimiterLength: delimiterLength) - case .inStringLiteral(kind: let stringLiteralKind, delimiterLength: let delimiterLength): + case .inStringLiteral(kind: let stringLiteralKind, let delimiterLength): result = lexInStringLiteral(stringLiteralKind: stringLiteralKind, delimiterLength: delimiterLength) case .afterStringLiteral(isRawString: _): result = lexAfterStringLiteral() case .afterClosingStringQuote: result = lexAfterClosingStringQuote() - case .inStringInterpolationStart(stringLiteralKind: let stringLiteralKind): + case .inStringInterpolationStart(let stringLiteralKind): result = lexInStringInterpolationStart(stringLiteralKind: stringLiteralKind) - case .inStringInterpolation(stringLiteralKind: let stringLiteralKind, parenCount: let parenCount): + case .inStringInterpolation(let stringLiteralKind, let parenCount): result = lexInStringInterpolation( stringLiteralKind: stringLiteralKind, parenCount: parenCount, @@ -903,7 +903,7 @@ extension Lexer.Cursor { case "/": // A following comment counts as whitespace, so this token is not right bound. - if (self.is(offset: 1, at: "/", "*")) { + if self.is(offset: 1, at: "/", "*") { return false } else { return true @@ -1800,7 +1800,7 @@ extension Lexer.Cursor { return .replace(newState: .afterClosingStringQuote) case .afterStringLiteral(isRawString: false): return .pop - case .afterRawStringDelimiter(delimiterLength: let delimiterLength): + case .afterRawStringDelimiter(let delimiterLength): return .replace(newState: .inStringLiteral(kind: kind, delimiterLength: delimiterLength)) case .normal, .preferRegexOverBinaryOperator, .inStringInterpolation: return .push(newState: .inStringLiteral(kind: kind, delimiterLength: 0)) @@ -2161,14 +2161,14 @@ extension Lexer.Cursor { case ".": return (.period, error: nil) case "?": - if (leftBound) { + if leftBound { return (.postfixQuestionMark, error: nil) } return (.infixQuestionMark, error: nil) default: break } - } else if (operEnd.input.baseAddress! - operStart.input.baseAddress! == 2) { + } else if operEnd.input.baseAddress! - operStart.input.baseAddress! == 2 { switch (operStart.peek(), operStart.peek(at: 1)) { case ("-", ">"): // -> return (.arrow, error: nil) diff --git a/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift b/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift index c5c565405cd..9048ae84444 100644 --- a/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift +++ b/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift @@ -17,7 +17,7 @@ #endif /// A separate lexer specifically for regex literals. -fileprivate struct RegexLiteralLexer { +private struct RegexLiteralLexer { enum LexResult { /// Continue the lex, this is returned from `lexPatternCharacter` when /// it successfully lexed a character. diff --git a/Sources/SwiftParser/Lexer/UnicodeScalarExtensions.swift b/Sources/SwiftParser/Lexer/UnicodeScalarExtensions.swift index acb2eb7d8f2..4ec46c3ddbf 100644 --- a/Sources/SwiftParser/Lexer/UnicodeScalarExtensions.swift +++ b/Sources/SwiftParser/Lexer/UnicodeScalarExtensions.swift @@ -74,7 +74,7 @@ extension Unicode.Scalar { } var isValidIdentifierStartCodePoint: Bool { - if (self.isASCII) { + if self.isASCII { return self.isAsciiIdentifierStart } guard self.isValidIdentifierContinuationCodePoint else { @@ -84,8 +84,8 @@ extension Unicode.Scalar { // N1518: Recommendations for extended identifier characters for C and C++ // Proposed Annex X.2: Ranges of characters disallowed initially let c = self.value - if ((c >= 0x0300 && c <= 0x036F) || (c >= 0x1DC0 && c <= 0x1DFF) || (c >= 0x20D0 && c <= 0x20FF) - || (c >= 0xFE20 && c <= 0xFE2F)) + if (c >= 0x0300 && c <= 0x036F) || (c >= 0x1DC0 && c <= 0x1DFF) || (c >= 0x20D0 && c <= 0x20FF) + || (c >= 0xFE20 && c <= 0xFE2F) { return false } @@ -183,7 +183,7 @@ extension Unicode.Scalar { return nil } - if (curByte < 0x80) { + if curByte < 0x80 { return Unicode.Scalar(curByte) } @@ -216,7 +216,7 @@ extension Unicode.Scalar { } // If the high bit isn't set or the second bit isn't clear, then this is not // a continuation byte! - if (curByte < 0x80 || curByte >= 0xC0) { + if curByte < 0x80 || curByte >= 0xC0 { return nil } diff --git a/Sources/SwiftParser/Lookahead.swift b/Sources/SwiftParser/Lookahead.swift index 9aa7afe8c4b..600f6f18fd9 100644 --- a/Sources/SwiftParser/Lookahead.swift +++ b/Sources/SwiftParser/Lookahead.swift @@ -212,7 +212,7 @@ extension Parser.Lookahead { return false } - while let _ = self.consume(if: .atSign) { + while self.consume(if: .atSign) != nil { // Consume qualified names that may or may not involve generic arguments. repeat { self.consume(if: .identifier, .keyword(.rethrows)) @@ -402,7 +402,7 @@ extension Parser.Lookahead { case nil: self.consumeAnyToken() } - case .skipSinglePost(start: let start): + case .skipSinglePost(let start): switch start { case .leftParen: self.consume(if: .rightParen) diff --git a/Sources/SwiftParser/Parser.swift b/Sources/SwiftParser/Parser.swift index 6d6e8b37cb3..dfe5ec65779 100644 --- a/Sources/SwiftParser/Parser.swift +++ b/Sources/SwiftParser/Parser.swift @@ -699,7 +699,7 @@ extension Parser { self.missingToken(.identifier) ) } else if keywordRecovery, - (self.currentToken.isLexerClassifiedKeyword || self.at(.wildcard)), + self.currentToken.isLexerClassifiedKeyword || self.at(.wildcard), !self.atStartOfLine { let keyword = self.consumeAnyToken() diff --git a/Sources/SwiftParser/StringLiterals.swift b/Sources/SwiftParser/StringLiterals.swift index d3b9c8adc4d..40c6a7875ba 100644 --- a/Sources/SwiftParser/StringLiterals.swift +++ b/Sources/SwiftParser/StringLiterals.swift @@ -18,7 +18,7 @@ // MARK: - Check multiline string literal indentation -fileprivate class StringLiteralExpressionIndentationChecker { +private class StringLiteralExpressionIndentationChecker { // MARK: Entry init(expectedIndentation: SyntaxText, arena: RawSyntaxArena) { diff --git a/Sources/SwiftParser/TokenPrecedence.swift b/Sources/SwiftParser/TokenPrecedence.swift index ca5da85838d..6fe15a0388a 100644 --- a/Sources/SwiftParser/TokenPrecedence.swift +++ b/Sources/SwiftParser/TokenPrecedence.swift @@ -55,9 +55,9 @@ enum TokenPrecedence: Comparable { /// If the precedence is `weakBracketed` or `strongBracketed`, the closing delimiter of the bracketed group. var closingTokenKind: RawTokenKind? { switch self { - case .weakBracketed(closingDelimiter: let closingDelimiter): + case .weakBracketed(let closingDelimiter): return closingDelimiter - case .openingBrace(closingDelimiter: let closingDelimiter): + case .openingBrace(let closingDelimiter): return closingDelimiter case .openingPoundIf: return .poundEndif diff --git a/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift b/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift index 73cd7a3c9e7..c39030b1c29 100644 --- a/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift +++ b/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift @@ -20,7 +20,7 @@ import SwiftDiagnostics @_spi(RawSyntax) import SwiftSyntax #endif -fileprivate let diagnosticDomain: String = "SwiftLexer" +private let diagnosticDomain: String = "SwiftLexer" /// An error diagnostic whose ID is determined by the diagnostic's type. public protocol TokenError: DiagnosticMessage { diff --git a/Sources/SwiftParserDiagnostics/MissingNodesError.swift b/Sources/SwiftParserDiagnostics/MissingNodesError.swift index 5a410d2b636..82009342a6a 100644 --- a/Sources/SwiftParserDiagnostics/MissingNodesError.swift +++ b/Sources/SwiftParserDiagnostics/MissingNodesError.swift @@ -23,7 +23,7 @@ import SwiftDiagnostics // MARK: - Shared code /// Returns the bottommost node that is an ancestor of all nodes in `nodes`. -fileprivate func findCommonAncestor(_ nodes: [Syntax]) -> Syntax? { +private func findCommonAncestor(_ nodes: [Syntax]) -> Syntax? { return findCommonAncestorOrSelf(nodes.compactMap({ $0.parent })) } @@ -35,7 +35,7 @@ class NoNewlinesFormat: BasicFormat { } } -fileprivate enum NodesDescriptionPart { +private enum NodesDescriptionPart { case tokensWithDefaultText([TokenSyntax]) case tokenWithoutDefaultText(TokenSyntax) case node(Syntax) @@ -232,7 +232,7 @@ fileprivate extension TokenKind { } /// Checks whether a node contains any tokens (missing or present) -fileprivate class HasTokenChecker: SyntaxAnyVisitor { +private class HasTokenChecker: SyntaxAnyVisitor { var hasToken: Bool = false override func visitAny(_ node: Syntax) -> SyntaxVisitorContinueKind { diff --git a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift index 20b7c7702fd..97a4705e431 100644 --- a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift @@ -20,7 +20,7 @@ import SwiftDiagnostics @_spi(ExperimentalLanguageFeatures) import SwiftSyntax #endif -fileprivate func getTokens(between first: TokenSyntax, and second: TokenSyntax) -> [TokenSyntax] { +private func getTokens(between first: TokenSyntax, and second: TokenSyntax) -> [TokenSyntax] { var first = first if first.presence == .missing { let nextPresentToken = first.nextToken(viewMode: .sourceAccurate) diff --git a/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift b/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift index f8d7aac2805..07ff8b8d49e 100644 --- a/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift +++ b/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift @@ -20,7 +20,7 @@ import SwiftDiagnostics @_spi(RawSyntax) import SwiftSyntax #endif -fileprivate let diagnosticDomain: String = "SwiftParser" +private let diagnosticDomain: String = "SwiftParser" /// An error diagnostic whose ID is determined by the diagnostic's type. public protocol ParserError: DiagnosticMessage { diff --git a/Sources/SwiftRefactor/ExpandEditorPlaceholder.swift b/Sources/SwiftRefactor/ExpandEditorPlaceholder.swift index 50854f65e37..ab416e83bdc 100644 --- a/Sources/SwiftRefactor/ExpandEditorPlaceholder.swift +++ b/Sources/SwiftRefactor/ExpandEditorPlaceholder.swift @@ -496,5 +496,5 @@ public func wrapInTypePlaceholder(_ str: String, type: String) -> String { return wrapInPlaceholder("T##" + str + "##" + type) } -fileprivate let placeholderStart: String = "<#" -fileprivate let placeholderEnd: String = "#>" +private let placeholderStart: String = "<#" +private let placeholderEnd: String = "#>" diff --git a/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift b/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift index f79382d51ab..a98a9bb7cc3 100644 --- a/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift +++ b/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift @@ -18,7 +18,7 @@ import SwiftSyntax /// Describes a "some" parameter that has been rewritten into a generic /// parameter. -fileprivate struct RewrittenSome { +private struct RewrittenSome { let original: SomeOrAnyTypeSyntax let genericParam: GenericParameterSyntax let genericParamRef: IdentifierTypeSyntax @@ -37,7 +37,7 @@ fileprivate struct RewrittenSome { /// ```swift /// func someFunction(_ input: T1) {} /// ``` -fileprivate class SomeParameterRewriter: SyntaxRewriter { +private class SomeParameterRewriter: SyntaxRewriter { var rewrittenSomeParameters: [RewrittenSome] = [] override func visit(_ node: SomeOrAnyTypeSyntax) -> TypeSyntax { diff --git a/Sources/SwiftSyntax/Raw/RawSyntax.swift b/Sources/SwiftSyntax/Raw/RawSyntax.swift index 4f8b106e6cb..519e73902d8 100644 --- a/Sources/SwiftSyntax/Raw/RawSyntax.swift +++ b/Sources/SwiftSyntax/Raw/RawSyntax.swift @@ -227,7 +227,7 @@ public struct RawSyntax: Sendable { } internal var payload: RawSyntaxData.Payload { - get { rawData.payload } + rawData.payload } } diff --git a/Sources/SwiftSyntax/Raw/RawSyntaxArena.swift b/Sources/SwiftSyntax/Raw/RawSyntaxArena.swift index 504ba38b1e8..cb6a163b812 100644 --- a/Sources/SwiftSyntax/Raw/RawSyntaxArena.swift +++ b/Sources/SwiftSyntax/Raw/RawSyntaxArena.swift @@ -271,7 +271,7 @@ struct RawSyntaxArenaRef: Hashable, @unchecked Sendable { /// Returns the ``RawSyntaxArena`` private var value: RawSyntaxArena { - get { self._value.takeUnretainedValue() } + self._value.takeUnretainedValue() } /// Assuming that this references a `ParsingRawSyntaxArena`, diff --git a/Sources/SwiftSyntax/SourceLocation.swift b/Sources/SwiftSyntax/SourceLocation.swift index 4cd64d612b9..fb9e63ebf78 100644 --- a/Sources/SwiftSyntax/SourceLocation.swift +++ b/Sources/SwiftSyntax/SourceLocation.swift @@ -103,7 +103,7 @@ public struct SourceRange: Hashable, Codable, Sendable { } } -fileprivate struct SourceLocationDirectiveArguments { +private struct SourceLocationDirectiveArguments { enum Error: Swift.Error, CustomStringConvertible { case nonDecimalLineNumber(TokenSyntax) case stringInterpolationInFileName(SimpleStringLiteralExprSyntax) @@ -685,7 +685,7 @@ private func computeLines(tree: Syntax) -> SourceLineTable { } /// Compute ``SourceLineTable`` from a ``SyntaxText``. -fileprivate func computeLines(text: SyntaxText) -> SourceLineTable { +private func computeLines(text: SyntaxText) -> SourceLineTable { var lineEnds: [AbsolutePosition] = [] let endPos = text.forEachEndOfLine(position: .startOfFile) { pos in lineEnds.append(pos) diff --git a/Sources/SwiftSyntaxBuilder/SyntaxParsable+ExpressibleByStringInterpolation.swift b/Sources/SwiftSyntaxBuilder/SyntaxParsable+ExpressibleByStringInterpolation.swift index 3c933396c06..662106b24b7 100644 --- a/Sources/SwiftSyntaxBuilder/SyntaxParsable+ExpressibleByStringInterpolation.swift +++ b/Sources/SwiftSyntaxBuilder/SyntaxParsable+ExpressibleByStringInterpolation.swift @@ -37,9 +37,9 @@ import os /// Only set from `withStringInterpolationParsingErrorsSuppressed`, which is only intended for testing purposes that are /// single-threaded. #if swift(>=6) -fileprivate nonisolated(unsafe) var suppressStringInterpolationParsingErrors = false +private nonisolated(unsafe) var suppressStringInterpolationParsingErrors = false #else -fileprivate var suppressStringInterpolationParsingErrors = false +private var suppressStringInterpolationParsingErrors = false #endif /// Run the body, disabling any runtime warnings about syntax error in string diff --git a/Sources/SwiftSyntaxMacroExpansion/IndentationUtils.swift b/Sources/SwiftSyntaxMacroExpansion/IndentationUtils.swift index 9cdbf16d2b7..b7ddfc6119b 100644 --- a/Sources/SwiftSyntaxMacroExpansion/IndentationUtils.swift +++ b/Sources/SwiftSyntaxMacroExpansion/IndentationUtils.swift @@ -61,7 +61,7 @@ extension String { // MARK: SyntaxProtocol.stripp -fileprivate class IndentationStripper: SyntaxRewriter { +private class IndentationStripper: SyntaxRewriter { override func visit(_ token: TokenSyntax) -> TokenSyntax { if token.leadingTrivia.contains(where: \.isNewline) || token.trailingTrivia.contains(where: \.isNewline) { return diff --git a/Sources/SwiftSyntaxMacroExpansion/MacroReplacement.swift b/Sources/SwiftSyntaxMacroExpansion/MacroReplacement.swift index 0f7a470118e..697b802972d 100644 --- a/Sources/SwiftSyntaxMacroExpansion/MacroReplacement.swift +++ b/Sources/SwiftSyntaxMacroExpansion/MacroReplacement.swift @@ -103,7 +103,7 @@ extension MacroDefinition { } } -fileprivate class ParameterReplacementVisitor: OnlyLiteralExprChecker { +private class ParameterReplacementVisitor: OnlyLiteralExprChecker { let macro: MacroDeclSyntax var replacements: [MacroDefinition.Replacement] = [] var genericReplacements: [MacroDefinition.GenericArgumentReplacement] = [] diff --git a/Sources/SwiftSyntaxMacros/MacroExpansionDiagnosticMessages.swift b/Sources/SwiftSyntaxMacros/MacroExpansionDiagnosticMessages.swift index eaa1d9526e7..0b13f8b6156 100644 --- a/Sources/SwiftSyntaxMacros/MacroExpansionDiagnosticMessages.swift +++ b/Sources/SwiftSyntaxMacros/MacroExpansionDiagnosticMessages.swift @@ -16,7 +16,7 @@ public import SwiftDiagnostics import SwiftDiagnostics #endif -fileprivate let diagnosticDomain: String = "SwiftSyntaxMacros" +private let diagnosticDomain: String = "SwiftSyntaxMacros" /// An error during macro expansion that is described by its message. /// diff --git a/Sources/SwiftSyntaxMacrosGenericTestSupport/Assertions.swift b/Sources/SwiftSyntaxMacrosGenericTestSupport/Assertions.swift index 7d7e490cbc0..64cd8e7aaa8 100644 --- a/Sources/SwiftSyntaxMacrosGenericTestSupport/Assertions.swift +++ b/Sources/SwiftSyntaxMacrosGenericTestSupport/Assertions.swift @@ -633,7 +633,7 @@ fileprivate extension FixIt.Change { replacement: replacingChildData.newChild.description ) - case .replaceText(range: let range, with: let newText, in: let syntax): + case .replaceText(let range, with: let newText, in: let syntax): let start = expansionContext.position(of: range.lowerBound, anchoredAt: syntax) let end = expansionContext.position(of: range.upperBound, anchoredAt: syntax) return SourceEdit(range: start.. [Marker] { +private func findMarkedRanges(text: String) -> [Marker] { var markers = [Marker]() while let marker = nextMarkedRange(text: text, from: markers.last?.range.upperBound ?? text.startIndex) { markers.append(marker) @@ -29,7 +29,7 @@ extension Character { } } -fileprivate func nextMarkedRange(text: String, from: String.Index) -> Marker? { +private func nextMarkedRange(text: String, from: String.Index) -> Marker? { guard let start = text[from...].firstIndex(where: { $0.isMarkerEmoji }) else { return nil } @@ -41,7 +41,7 @@ fileprivate func nextMarkedRange(text: String, from: String.Index) -> Marker? { return Marker(name: name, range: markerRange) } -fileprivate struct Marker { +private struct Marker { /// The name of the marker. let name: Substring /// The range of the marker. diff --git a/Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift b/Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift index b6d71b611f8..d3088107f8f 100644 --- a/Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift +++ b/Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift @@ -170,7 +170,7 @@ public enum SubtreeError: Error, CustomStringConvertible { } } -fileprivate class SyntaxTypeFinder: SyntaxAnyVisitor { +private class SyntaxTypeFinder: SyntaxAnyVisitor { private let offset: Int private let type: SyntaxProtocol.Type private var found: Syntax? diff --git a/SwiftParserCLI/Sources/swift-parser-cli/BasicFormat.swift b/SwiftParserCLI/Sources/swift-parser-cli/BasicFormat.swift index de4e41047c2..0ac916276c4 100644 --- a/SwiftParserCLI/Sources/swift-parser-cli/BasicFormat.swift +++ b/SwiftParserCLI/Sources/swift-parser-cli/BasicFormat.swift @@ -23,7 +23,7 @@ struct BasicFormat: ParsableCommand, ParseCommand { var description: String { switch self { - case .unknownSyntaxNodeType(nodeType: let nodeType, parsableTypes: let parsableTypes): + case .unknownSyntaxNodeType(let nodeType, let parsableTypes): return """ '\(nodeType)' is not a SwiftSyntax node type that conforms to SyntaxParsable. Possible options are: \(parsableTypes.map {" - \($0)" }.joined(separator: "\n")) diff --git a/SwiftParserCLI/Sources/swift-parser-cli/Commands/Reduce.swift b/SwiftParserCLI/Sources/swift-parser-cli/Commands/Reduce.swift index aeb7301a546..ce1d229e1cc 100644 --- a/SwiftParserCLI/Sources/swift-parser-cli/Commands/Reduce.swift +++ b/SwiftParserCLI/Sources/swift-parser-cli/Commands/Reduce.swift @@ -17,7 +17,7 @@ import Foundation import WinSDK #endif -fileprivate func withTemporaryFile(contents: [UInt8], body: (URL) throws -> T) throws -> T { +private func withTemporaryFile(contents: [UInt8], body: (URL) throws -> T) throws -> T { var tempFileURL = FileManager.default.temporaryDirectory tempFileURL.appendPathComponent("swift-parser-cli-\(UUID().uuidString).swift") try Data(contents).write(to: tempFileURL) diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifySourceCode.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifySourceCode.swift index 02c66d15e2f..3393061b7c2 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifySourceCode.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/VerifySourceCode.swift @@ -14,7 +14,7 @@ import ArgumentParser import Foundation import RegexBuilder -fileprivate let modules: [String] = [ +private let modules: [String] = [ "SwiftParser", "SwiftParserDiagnostics", "SwiftSyntax", diff --git a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/Paths.swift b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/Paths.swift index 36d6d198cc6..49bdfccad2c 100644 --- a/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/Paths.swift +++ b/SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/Paths.swift @@ -114,7 +114,7 @@ enum Paths { var description: String { switch self { - case .notFound(executableName: let executableName): + case .notFound(let executableName): return "Executable \(executableName) not found in PATH" } } diff --git a/Tests/PerformanceTest/InstructionsCountAssertion.swift b/Tests/PerformanceTest/InstructionsCountAssertion.swift index 250addfc71e..8c665a124e7 100644 --- a/Tests/PerformanceTest/InstructionsCountAssertion.swift +++ b/Tests/PerformanceTest/InstructionsCountAssertion.swift @@ -13,7 +13,7 @@ import XCTest import _InstructionCounter -fileprivate var baselineURL: URL { +private var baselineURL: URL { if let baselineFile = ProcessInfo.processInfo.environment["BASELINE_FILE"] { return URL(fileURLWithPath: baselineFile) } else { diff --git a/Tests/SwiftBasicFormatTest/BasicFormatTests.swift b/Tests/SwiftBasicFormatTest/BasicFormatTests.swift index 801c5e5e7ff..18dbd4a3392 100644 --- a/Tests/SwiftBasicFormatTest/BasicFormatTests.swift +++ b/Tests/SwiftBasicFormatTest/BasicFormatTests.swift @@ -17,7 +17,7 @@ import SwiftSyntax import XCTest import _SwiftSyntaxTestSupport -fileprivate func assertFormatted( +private func assertFormatted( tree: T, expected: String, using format: BasicFormat = BasicFormat(indentationWidth: .spaces(4)), @@ -27,7 +27,7 @@ fileprivate func assertFormatted( assertStringsEqualWithDiff(tree.formatted(using: format).description, expected, file: file, line: line) } -fileprivate func assertFormatted( +private func assertFormatted( source: String, expected: String, using format: BasicFormat = BasicFormat(indentationWidth: .spaces(4)), @@ -43,7 +43,7 @@ fileprivate func assertFormatted( ) } -fileprivate func assertFormattingRoundTrips( +private func assertFormattingRoundTrips( _ source: String, using format: BasicFormat = BasicFormat(indentationWidth: .spaces(4)), file: StaticString = #filePath, diff --git a/Tests/SwiftBasicFormatTest/IndentTests.swift b/Tests/SwiftBasicFormatTest/IndentTests.swift index a60f5215d18..075cfa2778b 100644 --- a/Tests/SwiftBasicFormatTest/IndentTests.swift +++ b/Tests/SwiftBasicFormatTest/IndentTests.swift @@ -17,7 +17,7 @@ import SwiftSyntax import XCTest import _SwiftSyntaxTestSupport -fileprivate func assertIndented( +private func assertIndented( by indentation: Trivia = .tab, indentFirstLine: Bool = true, source: String, diff --git a/Tests/SwiftBasicFormatTest/InferIndentationTests.swift b/Tests/SwiftBasicFormatTest/InferIndentationTests.swift index 915e6a9bd15..15c9e67f200 100644 --- a/Tests/SwiftBasicFormatTest/InferIndentationTests.swift +++ b/Tests/SwiftBasicFormatTest/InferIndentationTests.swift @@ -15,7 +15,7 @@ import SwiftSyntax import SwiftSyntaxBuilder import XCTest -fileprivate func assertIndentation( +private func assertIndentation( of sourceFile: SourceFileSyntax, _ expected: Trivia?, file: StaticString = #filePath, diff --git a/Tests/SwiftCompilerPluginTest/JSONTests.swift b/Tests/SwiftCompilerPluginTest/JSONTests.swift index 2018d831662..71f95538ea9 100644 --- a/Tests/SwiftCompilerPluginTest/JSONTests.swift +++ b/Tests/SwiftCompilerPluginTest/JSONTests.swift @@ -254,29 +254,29 @@ final class JSONTests: XCTestCase { // MARK: - Test Types -fileprivate struct EmptyStruct: Codable, Equatable { +private struct EmptyStruct: Codable, Equatable { static func == (_ lhs: EmptyStruct, _ rhs: EmptyStruct) -> Bool { return true } } -fileprivate class EmptyClass: Codable, Equatable { +private class EmptyClass: Codable, Equatable { static func == (_ lhs: EmptyClass, _ rhs: EmptyClass) -> Bool { return true } } -fileprivate enum Direction: Codable { +private enum Direction: Codable { case right case left } -fileprivate enum Animal: String, Codable { +private enum Animal: String, Codable { case dog case cat } -fileprivate enum Switch: Codable { +private enum Switch: Codable { case off case on @@ -297,14 +297,14 @@ fileprivate enum Switch: Codable { } } -fileprivate enum Tree: Codable, Equatable { - indirect case int(Int) - indirect case string(String) - indirect case array([Self]) - indirect case dictionary([String: Self]) +private indirect enum Tree: Codable, Equatable { + case int(Int) + case string(String) + case array([Self]) + case dictionary([String: Self]) } -fileprivate struct ComplexStruct: Codable, Equatable { +private struct ComplexStruct: Codable, Equatable { struct Diagnostic: Codable, Equatable { var message: String var animal: Animal diff --git a/Tests/SwiftIDEUtilsTest/Assertions.swift b/Tests/SwiftIDEUtilsTest/Assertions.swift index c29a3442fe7..ff21d8cde4b 100644 --- a/Tests/SwiftIDEUtilsTest/Assertions.swift +++ b/Tests/SwiftIDEUtilsTest/Assertions.swift @@ -32,7 +32,7 @@ func assertClassification( ) { let tree = Parser.parse(source: source) - var classifications: Array + var classifications: [SyntaxClassifiedRange] if let range { classifications = Array(tree.classifications(in: range)) } else { diff --git a/Tests/SwiftIfConfigTest/ActiveRegionTests.swift b/Tests/SwiftIfConfigTest/ActiveRegionTests.swift index 997b15b3735..0642823bc34 100644 --- a/Tests/SwiftIfConfigTest/ActiveRegionTests.swift +++ b/Tests/SwiftIfConfigTest/ActiveRegionTests.swift @@ -125,7 +125,7 @@ public class ActiveRegionTests: XCTestCase { /// Assert that the various marked positions in the source code have the /// expected active states. -fileprivate func assertActiveCode( +private func assertActiveCode( _ markedSource: String, configuration: some BuildConfiguration = TestingBuildConfiguration(), states: [String: IfConfigRegionState], diff --git a/Tests/SwiftIfConfigTest/EvaluateTests.swift b/Tests/SwiftIfConfigTest/EvaluateTests.swift index 8f383befea3..77a677977f4 100644 --- a/Tests/SwiftIfConfigTest/EvaluateTests.swift +++ b/Tests/SwiftIfConfigTest/EvaluateTests.swift @@ -592,7 +592,7 @@ public class EvaluateTests: XCTestCase { /// Assert the results of evaluating the condition within an `#if` against the /// given build configuration. -fileprivate func assertIfConfig( +private func assertIfConfig( _ condition: ExprSyntax, _ expectedState: IfConfigRegionState, configuration: some BuildConfiguration = TestingBuildConfiguration(), diff --git a/Tests/SwiftIfConfigTest/VisitorTests.swift b/Tests/SwiftIfConfigTest/VisitorTests.swift index 0a4ea2fbd3c..2c6960c7516 100644 --- a/Tests/SwiftIfConfigTest/VisitorTests.swift +++ b/Tests/SwiftIfConfigTest/VisitorTests.swift @@ -399,7 +399,7 @@ extension VisitorTests { /// Assert that removing any inactive code according to the given build /// configuration returns the expected source and diagnostics. -fileprivate func assertRemoveInactive( +private func assertRemoveInactive( _ source: String, configuration: some BuildConfiguration, retainFeatureCheckIfConfigs: Bool = false, diff --git a/Tests/SwiftParserTest/LexerTests.swift b/Tests/SwiftParserTest/LexerTests.swift index 910d61c4510..876958ea385 100644 --- a/Tests/SwiftParserTest/LexerTests.swift +++ b/Tests/SwiftParserTest/LexerTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftSyntax import XCTest -fileprivate func lex(_ sourceBytes: [UInt8], body: ([Lexer.Lexeme]) throws -> Void) rethrows { +private func lex(_ sourceBytes: [UInt8], body: ([Lexer.Lexeme]) throws -> Void) rethrows { let lookaheadTracker = UnsafeMutablePointer.allocate(capacity: 1) defer { lookaheadTracker.deallocate() @@ -37,7 +37,7 @@ fileprivate func lex(_ sourceBytes: [UInt8], body: ([Lexer.Lexeme]) throws -> Vo /// values for trivia and text. While this is good for most cases, string /// literals can't contain invalid UTF-8. Thus, we need a different assert /// function working on byte arrays to test source code containing invalid UTF-8. -fileprivate func assertRawBytesLexeme( +private func assertRawBytesLexeme( _ lexeme: Lexer.Lexeme, kind: RawTokenKind, leadingTrivia: [UInt8] = [], diff --git a/Tests/SwiftRefactorTest/CallToTrailingClosureTests.swift b/Tests/SwiftRefactorTest/CallToTrailingClosureTests.swift index 06cc7984da4..9f457e8edbc 100644 --- a/Tests/SwiftRefactorTest/CallToTrailingClosureTests.swift +++ b/Tests/SwiftRefactorTest/CallToTrailingClosureTests.swift @@ -249,7 +249,7 @@ final class CallToTrailingClosuresTest: XCTestCase { } } -fileprivate func assertRefactorCall( +private func assertRefactorCall( _ callExpr: ExprSyntax, startAtArgument: Int = 0, expected: ExprSyntax?, diff --git a/Tests/SwiftRefactorTest/ConvertComputedPropertyToStoredTest.swift b/Tests/SwiftRefactorTest/ConvertComputedPropertyToStoredTest.swift index 328675ec7be..e87913a565c 100644 --- a/Tests/SwiftRefactorTest/ConvertComputedPropertyToStoredTest.swift +++ b/Tests/SwiftRefactorTest/ConvertComputedPropertyToStoredTest.swift @@ -146,7 +146,7 @@ final class ConvertComputedPropertyToStoredTest: XCTestCase { } } -fileprivate func assertRefactorConvert( +private func assertRefactorConvert( _ callDecl: DeclSyntax, expected: DeclSyntax?, file: StaticString = #filePath, diff --git a/Tests/SwiftRefactorTest/ConvertComputedPropertyToZeroParameterFunctionTests.swift b/Tests/SwiftRefactorTest/ConvertComputedPropertyToZeroParameterFunctionTests.swift index c75c4784b87..20a823c0b65 100644 --- a/Tests/SwiftRefactorTest/ConvertComputedPropertyToZeroParameterFunctionTests.swift +++ b/Tests/SwiftRefactorTest/ConvertComputedPropertyToZeroParameterFunctionTests.swift @@ -301,7 +301,7 @@ final class ConvertComputedPropertyToZeroParameterFunctionTests: XCTestCase { } } -fileprivate func assertRefactorConvert( +private func assertRefactorConvert( _ callDecl: DeclSyntax, expected: DeclSyntax?, file: StaticString = #filePath, diff --git a/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift b/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift index 1127b037b33..c948dbbc3c7 100644 --- a/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift +++ b/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift @@ -172,7 +172,7 @@ final class ConvertStoredPropertyToComputedTest: XCTestCase { } } -fileprivate func assertRefactorConvert( +private func assertRefactorConvert( _ callDecl: DeclSyntax, expected: DeclSyntax?, file: StaticString = #filePath, diff --git a/Tests/SwiftRefactorTest/ConvertZeroParameterFunctionToComputedPropertyTests.swift b/Tests/SwiftRefactorTest/ConvertZeroParameterFunctionToComputedPropertyTests.swift index a55e8610849..997236c6d9c 100644 --- a/Tests/SwiftRefactorTest/ConvertZeroParameterFunctionToComputedPropertyTests.swift +++ b/Tests/SwiftRefactorTest/ConvertZeroParameterFunctionToComputedPropertyTests.swift @@ -140,7 +140,7 @@ final class ConvertZeroParameterFunctionToComputedPropertyTests: XCTestCase { } } -fileprivate func assertRefactorConvert( +private func assertRefactorConvert( _ callDecl: DeclSyntax, expected: DeclSyntax?, file: StaticString = #filePath, diff --git a/Tests/SwiftRefactorTest/ExpandEditorPlaceholderTests.swift b/Tests/SwiftRefactorTest/ExpandEditorPlaceholderTests.swift index 97d5d1660b2..33fe96cd399 100644 --- a/Tests/SwiftRefactorTest/ExpandEditorPlaceholderTests.swift +++ b/Tests/SwiftRefactorTest/ExpandEditorPlaceholderTests.swift @@ -18,16 +18,16 @@ import SwiftSyntaxBuilder import XCTest import _SwiftSyntaxTestSupport -fileprivate let closurePlaceholder = wrapInPlaceholder("T##closure##() -> Void") -fileprivate let closureWithArgPlaceholder = wrapInPlaceholder( +private let closurePlaceholder = wrapInPlaceholder("T##closure##() -> Void") +private let closureWithArgPlaceholder = wrapInPlaceholder( "T##(Int) -> String##(Int) -> String##(_ someInt: Int) -> String" ) -fileprivate let closureCombinedTypeDisplayPlaceholder = wrapInPlaceholder( +private let closureCombinedTypeDisplayPlaceholder = wrapInPlaceholder( "T##(Int) -> String" ) -fileprivate let voidPlaceholder = wrapInPlaceholder("T##code##Void") -fileprivate let intPlaceholder = wrapInPlaceholder("T##Int##Int") -fileprivate let stringPlaceholder = wrapInPlaceholder("T##String##String") +private let voidPlaceholder = wrapInPlaceholder("T##code##Void") +private let intPlaceholder = wrapInPlaceholder("T##Int##Int") +private let stringPlaceholder = wrapInPlaceholder("T##String##String") final class ExpandEditorPlaceholderTests: XCTestCase { func testSimple() throws { @@ -505,7 +505,7 @@ final class ExpandEditorPlaceholderTests: XCTestCase { } } -fileprivate func assertRefactorPlaceholder( +private func assertRefactorPlaceholder( _ placeholder: String, wrap: Bool = true, expected: String, @@ -532,7 +532,7 @@ fileprivate func assertRefactorPlaceholder( ) } -fileprivate func assertRefactorPlaceholderCall( +private func assertRefactorPlaceholderCall( _ expr: String, placeholder: Int = 0, expected: String, @@ -556,7 +556,7 @@ fileprivate func assertRefactorPlaceholderCall( ) } -fileprivate func assertRefactorPlaceholderToken( +private func assertRefactorPlaceholderToken( _ expr: String, placeholder: Int = 0, expected: String, @@ -580,7 +580,7 @@ fileprivate func assertRefactorPlaceholderToken( ) } -fileprivate func assertExpandEditorPlaceholdersToClosures( +private func assertExpandEditorPlaceholdersToClosures( _ call: some CallLikeSyntax, expected: String, format: ExpandEditorPlaceholdersToLiteralClosures.Context.Format = .trailing(indentationWidth: nil), @@ -597,7 +597,7 @@ fileprivate func assertExpandEditorPlaceholdersToClosures( ) } -fileprivate func assertExpandEditorPlaceholdersToClosures( +private func assertExpandEditorPlaceholdersToClosures( _ expr: String, expected: String, format: ExpandEditorPlaceholdersToLiteralClosures.Context.Format = .trailing(indentationWidth: nil), @@ -615,7 +615,7 @@ fileprivate func assertExpandEditorPlaceholdersToClosures( ) } -fileprivate func assertExpandEditorPlaceholdersToClosures( +private func assertExpandEditorPlaceholdersToClosures( decl: String, expected: String, format: ExpandEditorPlaceholdersToLiteralClosures.Context.Format = .trailing(indentationWidth: nil), @@ -639,7 +639,7 @@ fileprivate extension ExpandEditorPlaceholdersToLiteralClosures.Context.Format { } } -fileprivate class CustomClosureFormat: BasicFormat { +private class CustomClosureFormat: BasicFormat { override func requiresNewline(between _: TokenSyntax?, and _: TokenSyntax?) -> Bool { return false } diff --git a/Tests/SwiftSyntaxBuilderTest/StringInterpolationTests.swift b/Tests/SwiftSyntaxBuilderTest/StringInterpolationTests.swift index 4194894c0e8..cbf1f3ac9c2 100644 --- a/Tests/SwiftSyntaxBuilderTest/StringInterpolationTests.swift +++ b/Tests/SwiftSyntaxBuilderTest/StringInterpolationTests.swift @@ -214,8 +214,8 @@ final class StringInterpolationTests: XCTestCase { } func testInterpolationLiteralOptional() { - let some: Optional = 42 - let none: Optional = nil + let some: Int? = 42 + let none: Int? = nil let a: ExprSyntax = "print(\(literal: some))" assertStringsEqualWithDiff(a.description, #"print(42)"#) diff --git a/Tests/SwiftSyntaxMacroExpansionTest/AccessorMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/AccessorMacroTests.swift index cf1c0b6267a..3560cca6174 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/AccessorMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/AccessorMacroTests.swift @@ -25,7 +25,7 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest -fileprivate struct ConstantOneGetter: AccessorMacro { +private struct ConstantOneGetter: AccessorMacro { static func expansion( of node: AttributeSyntax, providingAccessorsOf declaration: some DeclSyntaxProtocol, diff --git a/Tests/SwiftSyntaxMacroExpansionTest/AttributeRemoverTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/AttributeRemoverTests.swift index fe8a41e6fbe..a3ab09c2d18 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/AttributeRemoverTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/AttributeRemoverTests.swift @@ -16,7 +16,7 @@ import SwiftSyntax import XCTest import _SwiftSyntaxTestSupport -fileprivate func assertSyntaxRemovingTestAttributes( +private func assertSyntaxRemovingTestAttributes( _ originalSource: String, reduction expectedReducedSource: String, file: StaticString = #filePath, diff --git a/Tests/SwiftSyntaxMacroExpansionTest/CodeItemMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/CodeItemMacroTests.swift index 1df8d0fda63..9f3f69936be 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/CodeItemMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/CodeItemMacroTests.swift @@ -25,7 +25,7 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest -fileprivate struct DeclsFromStringsMacro: DeclarationMacro { +private struct DeclsFromStringsMacro: DeclarationMacro { static func expansion( of node: some FreestandingMacroExpansionSyntax, in context: some MacroExpansionContext diff --git a/Tests/SwiftSyntaxMacroExpansionTest/DeclarationMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/DeclarationMacroTests.swift index 20ac099d3c6..e397b669e55 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/DeclarationMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/DeclarationMacroTests.swift @@ -25,7 +25,7 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest -fileprivate struct DeclsFromStringsMacro: DeclarationMacro { +private struct DeclsFromStringsMacro: DeclarationMacro { static func expansion( of node: some FreestandingMacroExpansionSyntax, in context: some MacroExpansionContext diff --git a/Tests/SwiftSyntaxMacroExpansionTest/ExpressionMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/ExpressionMacroTests.swift index b79397f2649..609128b2475 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/ExpressionMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/ExpressionMacroTests.swift @@ -24,7 +24,7 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest -fileprivate struct StringifyMacro: ExpressionMacro { +private struct StringifyMacro: ExpressionMacro { static func expansion( of macro: some FreestandingMacroExpansionSyntax, in context: some MacroExpansionContext diff --git a/Tests/SwiftSyntaxMacroExpansionTest/ExtensionMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/ExtensionMacroTests.swift index eb6dae3773f..28373c7fe54 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/ExtensionMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/ExtensionMacroTests.swift @@ -253,7 +253,7 @@ final class ExtensionMacroTests: XCTestCase { } } -fileprivate struct SendableExtensionMacro: ExtensionMacro { +private struct SendableExtensionMacro: ExtensionMacro { static func expansion( of node: AttributeSyntax, attachedTo: some DeclGroupSyntax, diff --git a/Tests/SwiftSyntaxMacroExpansionTest/MemberAttributeMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/MemberAttributeMacroTests.swift index 32a48cabd88..6f8c05a2c04 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/MemberAttributeMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/MemberAttributeMacroTests.swift @@ -25,7 +25,7 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest -fileprivate struct WrapAllProperties: MemberAttributeMacro { +private struct WrapAllProperties: MemberAttributeMacro { static func expansion( of node: AttributeSyntax, attachedTo decl: some DeclGroupSyntax, diff --git a/Tests/SwiftSyntaxMacroExpansionTest/MemberMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/MemberMacroTests.swift index 48f1fcc7aaf..4a191c69079 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/MemberMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/MemberMacroTests.swift @@ -25,7 +25,7 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest -fileprivate struct NoOpMemberMacro: MemberMacro { +private struct NoOpMemberMacro: MemberMacro { static func expansion( of node: AttributeSyntax, providingMembersOf declaration: some DeclGroupSyntax, diff --git a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift index 4a6eaf2130e..925b6842837 100644 --- a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift +++ b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift @@ -13,7 +13,7 @@ @_spi(RawSyntax) import SwiftSyntax import XCTest -fileprivate func cannedStructDecl(arena: ParsingRawSyntaxArena) -> RawStructDeclSyntax { +private func cannedStructDecl(arena: ParsingRawSyntaxArena) -> RawStructDeclSyntax { let structKW = RawTokenSyntax( kind: .keyword, text: arena.intern("struct"), diff --git a/Tests/SwiftSyntaxTest/SourceLocationConverterTests.swift b/Tests/SwiftSyntaxTest/SourceLocationConverterTests.swift index 7db28ec5390..dd2095e628b 100644 --- a/Tests/SwiftSyntaxTest/SourceLocationConverterTests.swift +++ b/Tests/SwiftSyntaxTest/SourceLocationConverterTests.swift @@ -15,7 +15,7 @@ import SwiftSyntaxBuilder import XCTest import _SwiftSyntaxTestSupport -fileprivate func assertPresumedSourceLocation( +private func assertPresumedSourceLocation( _ source: SourceFileSyntax, inspectionItemFilter: (CodeBlockItemSyntax.Item) -> (some SyntaxProtocol)? = { $0.as(VariableDeclSyntax.self) }, presumedFile: String, diff --git a/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift index 24e390117f3..d031b592e2a 100644 --- a/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift @@ -14,7 +14,7 @@ import SwiftSyntax import XCTest import _SwiftSyntaxTestSupport -fileprivate func intElement(_ int: Int) -> ArrayElementSyntax { +private func intElement(_ int: Int) -> ArrayElementSyntax { let literal = TokenSyntax.integerLiteral("\(int)") return ArrayElementSyntax( expression: IntegerLiteralExprSyntax(literal: literal), @@ -22,7 +22,7 @@ fileprivate func intElement(_ int: Int) -> ArrayElementSyntax { ) } -fileprivate func assertSyntaxCollectionManipulation( +private func assertSyntaxCollectionManipulation( initialElements: [Int], transformation: (_ array: inout ArrayExprSyntax) -> Void, expectedElements: [Int], diff --git a/Tests/SwiftSyntaxTest/SyntaxCreationTests.swift b/Tests/SwiftSyntaxTest/SyntaxCreationTests.swift index a355341c245..fa83de8428d 100644 --- a/Tests/SwiftSyntaxTest/SyntaxCreationTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxCreationTests.swift @@ -13,7 +13,7 @@ import SwiftSyntax import XCTest -fileprivate func cannedStructDecl() -> StructDeclSyntax { +private func cannedStructDecl() -> StructDeclSyntax { let structKW = TokenSyntax.keyword(.struct, trailingTrivia: .space) let fooID = TokenSyntax.identifier("Foo", trailingTrivia: .space) let rBrace = TokenSyntax.rightBraceToken(leadingTrivia: .newline) diff --git a/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift b/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift index f8838043912..0c6974a1f25 100644 --- a/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift @@ -13,7 +13,7 @@ import SwiftSyntax import XCTest -fileprivate func cannedVarDecl() -> VariableDeclSyntax { +private func cannedVarDecl() -> VariableDeclSyntax { let identifierPattern = IdentifierPatternSyntax( identifier: .identifier("a") )