diff --git a/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift b/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift index cfe38ee1964..23bcac8595b 100644 --- a/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift +++ b/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift @@ -10,8 +10,15 @@ // //===----------------------------------------------------------------------===// +import SwiftSyntax + public struct KeywordSpec { public var name: String + + /// If `true`, this is for an experimental language feature, and any public + /// API generated should be SPI. + public var isExperimental: Bool + public var isLexerClassified: Bool public var requiresLeadingSpace: Bool public var requiresTrailingSpace: Bool @@ -24,10 +31,18 @@ public struct KeywordSpec { } } + /// Retrieve the attributes that should be printed on any API for the + /// generated keyword. + public var apiAttributes: AttributeListSyntax { + guard isExperimental else { return "" } + return AttributeListSyntax("@_spi(ExperimentalLanguageFeatures)").with(\.trailingTrivia, .newline) + } + /// `isLexerClassified` determines whether the token kind is switched from being an identifier to a keyword in the lexer. /// This is true for keywords that used to be considered non-contextual. - init(_ name: String, isLexerClassified: Bool = false, requiresLeadingSpace: Bool = false, requiresTrailingSpace: Bool = false) { + init(_ name: String, isExperimental: Bool = false, isLexerClassified: Bool = false, requiresLeadingSpace: Bool = false, requiresTrailingSpace: Bool = false) { self.name = name + self.isExperimental = isExperimental self.isLexerClassified = isLexerClassified self.requiresLeadingSpace = requiresLeadingSpace self.requiresTrailingSpace = requiresTrailingSpace diff --git a/CodeGeneration/Sources/SyntaxSupport/Node.swift b/CodeGeneration/Sources/SyntaxSupport/Node.swift index b32b019fa63..4bd81cc6f33 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Node.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Node.swift @@ -40,6 +40,10 @@ public class Node { /// The kind of node’s supertype. This kind must have `isBase == true` public let base: SyntaxNodeKind + /// If `true`, this is for an experimental language feature, and any public + /// API generated should be SPI. + public let isExperimental: Bool + /// When the node name is printed for diagnostics, this name is used. /// If `nil`, `nameForDiagnostics` will print the parent node’s name. public let nameForDiagnostics: String? @@ -85,10 +89,25 @@ public class Node { } } + /// Retrieve the attributes that should be printed on any API for the + /// generated node. If `forRaw` is true, this is for the raw syntax node. + public func apiAttributes(forRaw: Bool = false) -> AttributeListSyntax { + let attrList = AttributeListSyntax { + if isExperimental { + "@_spi(ExperimentalLanguageFeatures)" + } + if forRaw { + "@_spi(RawSyntax)" + } + } + return attrList.with(\.trailingTrivia, attrList.isEmpty ? [] : .newline) + } + /// Construct the specification for a layout syntax node. init( kind: SyntaxNodeKind, base: SyntaxNodeKind, + isExperimental: Bool = false, nameForDiagnostics: String?, documentation: String? = nil, parserFunction: String? = nil, @@ -100,6 +119,7 @@ public class Node { self.kind = kind self.base = base + self.isExperimental = isExperimental self.nameForDiagnostics = nameForDiagnostics self.documentation = docCommentTrivia(from: documentation) self.parserFunction = parserFunction @@ -204,6 +224,7 @@ public class Node { init( kind: SyntaxNodeKind, base: SyntaxNodeKind, + isExperimental: Bool = false, nameForDiagnostics: String?, documentation: String? = nil, parserFunction: String? = nil, @@ -212,6 +233,7 @@ public class Node { self.kind = kind precondition(base == .syntaxCollection) self.base = base + self.isExperimental = isExperimental self.nameForDiagnostics = nameForDiagnostics self.documentation = docCommentTrivia(from: documentation) self.parserFunction = parserFunction diff --git a/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift b/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift index fe59d084c42..fae733d3428 100644 --- a/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift +++ b/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift @@ -22,22 +22,36 @@ public struct TokenSpec { } public let varOrCaseName: TokenSyntax + + /// If `true`, this is for an experimental language feature, and any public + /// API generated should be SPI. + public let isExperimental: Bool + public let nameForDiagnostics: String public let text: String? public let kind: Kind fileprivate init( name: String, + isExperimental: Bool = false, nameForDiagnostics: String, text: String? = nil, kind: Kind ) { self.varOrCaseName = .identifier(name) + self.isExperimental = isExperimental self.nameForDiagnostics = nameForDiagnostics self.text = text self.kind = kind } + /// Retrieve the attributes that should be printed on any API for the + /// generated token. + public var apiAttributes: AttributeListSyntax { + guard isExperimental else { return "" } + return AttributeListSyntax("@_spi(ExperimentalLanguageFeatures)").with(\.trailingTrivia, .newline) + } + static func punctuator(name: String, text: String) -> TokenSpec { return TokenSpec( name: name, diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift index c46e74de41d..53a6b67bdf1 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift @@ -16,7 +16,7 @@ import SyntaxSupport import Utils let syntaxKindNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { - DeclSyntax("import SwiftSyntax") + DeclSyntax("@_spi(ExperimentalLanguageFeatures) import SwiftSyntax") try! ExtensionDeclSyntax("extension SyntaxKind") { try VariableDeclSyntax("var nameForDiagnostics: String?") { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift index 22e7317bde8..f22fb1d2c45 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift @@ -28,7 +28,12 @@ let keywordFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { """ ) { for (index, keyword) in KEYWORDS.enumerated() { - DeclSyntax("case \(raw: keyword.escapedName)") + DeclSyntax( + """ + \(keyword.apiAttributes)\ + case \(raw: keyword.escapedName) + """ + ) } try! InitializerDeclSyntax("@_spi(RawSyntax) public init?(_ text: SyntaxText)") { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift index 1adf95123e6..6b6ea7e7ab7 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift @@ -42,7 +42,7 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { for node in SYNTAX_NODES where node.kind.isBase { DeclSyntax( """ - @_spi(RawSyntax) + \(node.apiAttributes(forRaw: true))\ public protocol \(node.kind.rawType)NodeProtocol: \(raw: node.base.rawProtocolType) {} """ ) @@ -51,7 +51,7 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { for node in SYNTAX_NODES { try! StructDeclSyntax( """ - @_spi(RawSyntax) + \(node.apiAttributes(forRaw: true))\ public struct \(node.kind.rawType): \(node.kind.isBase ? node.kind.rawProtocolType : node.base.rawProtocolType) """ ) { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SwiftSyntaxDoccIndex.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SwiftSyntaxDoccIndex.swift index 3ebf49e2f20..a605d75c92c 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SwiftSyntaxDoccIndex.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SwiftSyntaxDoccIndex.swift @@ -37,7 +37,7 @@ let nodesSections: String = { for (baseKind, heading) in nodeKinds { let baseTypes = ["\(baseKind.syntaxType)", "\(baseKind.syntaxType)Protocol", "Missing\(baseKind.syntaxType)"] - let leafTypes = SYNTAX_NODES.filter({ $0.base == baseKind && !$0.kind.isMissing }).map(\.kind.syntaxType.description) + let leafTypes = SYNTAX_NODES.filter({ $0.base == baseKind && !$0.kind.isMissing && !$0.isExperimental }).map(\.kind.syntaxType.description) addSection(heading: heading, types: baseTypes + leafTypes) } @@ -48,7 +48,7 @@ let nodesSections: String = { "SyntaxChildrenIndex", ] + SYNTAX_NODES.flatMap({ (node: Node) -> [String] in - guard let node = node.collectionNode else { + guard let node = node.collectionNode, !node.isExperimental else { return [] } return [node.kind.syntaxType.description] @@ -59,9 +59,12 @@ let nodesSections: String = { }) ) - addSection(heading: "Attributes", types: ATTRIBUTE_NODES.map(\.kind.syntaxType.description).sorted()) + addSection(heading: "Attributes", types: ATTRIBUTE_NODES.filter({ !$0.isExperimental }).map(\.kind.syntaxType.description).sorted()) - addSection(heading: "Miscellaneous Syntax", types: SYNTAX_NODES.map(\.kind.syntaxType.description).filter({ !handledSyntaxTypes.contains($0) })) + addSection( + heading: "Miscellaneous Syntax", + types: SYNTAX_NODES.filter({ !$0.isExperimental }).map(\.kind.syntaxType.description).filter({ !handledSyntaxTypes.contains($0) }) + ) addSection(heading: "Traits", types: TRAITS.map { "\($0.protocolName)" }) diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxAnyVisitorFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxAnyVisitorFile.swift index 34cb73122c9..ac7252562e1 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxAnyVisitorFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxAnyVisitorFile.swift @@ -79,6 +79,7 @@ let syntaxAnyVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { for node in SYNTAX_NODES where !node.kind.isBase { DeclSyntax( """ + \(node.apiAttributes())\ override open func visit(_ node: \(node.kind.syntaxType)) -> SyntaxVisitorContinueKind { return visitAny(node._syntaxNode) } @@ -87,6 +88,7 @@ let syntaxAnyVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { DeclSyntax( """ + \(node.apiAttributes())\ override open func visitPost(_ node: \(node.kind.syntaxType)) { visitAnyPost(node._syntaxNode) } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift index 7ddf4a81acc..de7eef8dfb1 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift @@ -26,6 +26,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { /// Extension point to add common methods to all ``\(node.kind.syntaxType)`` nodes. /// /// - Warning: Do not conform to this protocol yourself. + \(node.apiAttributes())\ public protocol \(node.kind.protocolType): \(raw: node.base.protocolType) {} """ ) @@ -59,6 +60,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { try! StructDeclSyntax( """ \(node.documentation) + \(node.apiAttributes())\ public struct \(node.kind.syntaxType): \(node.kind.protocolType), SyntaxHashable """ ) { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift index d1e0c35a5e8..f0531ad4e5d 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift @@ -33,6 +33,7 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { try! StructDeclSyntax( """ \(documentation) + \(node.node.apiAttributes())\ public struct \(node.kind.syntaxType): SyntaxCollection, SyntaxHashable """ ) { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxEnumFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxEnumFile.swift index 517c2bdaf90..fe720b45d2e 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxEnumFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxEnumFile.swift @@ -24,7 +24,12 @@ let syntaxEnumFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { ) { DeclSyntax("case token(TokenSyntax)") for node in NON_BASE_SYNTAX_NODES { - DeclSyntax("case \(node.varOrCaseName)(\(node.kind.syntaxType))") + DeclSyntax( + """ + \(node.apiAttributes())\ + case \(node.varOrCaseName)(\(node.kind.syntaxType)) + """ + ) } } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift index a3451575fdf..151950547ad 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift @@ -24,7 +24,12 @@ let syntaxKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { ) { DeclSyntax("case token") for node in NON_BASE_SYNTAX_NODES { - DeclSyntax("case \(node.varOrCaseName)") + DeclSyntax( + """ + \(node.apiAttributes())\ + case \(node.varOrCaseName) + """ + ) } try VariableDeclSyntax("public var isSyntaxCollection: Bool") { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift index a79fa7da8ff..666136cc9f3 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift @@ -40,6 +40,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { // MARK: - \(raw: node.kind.syntaxType) \(documentation) + \(node.node.apiAttributes())\ public struct \(raw: node.kind.syntaxType): \(raw: node.baseType.syntaxBaseName)Protocol, SyntaxHashable """ ) { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxRewriterFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxRewriterFile.swift index a9a4a1e0a29..f2589ace3a4 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxRewriterFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxRewriterFile.swift @@ -125,6 +125,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { /// Visit a ``\(node.kind.syntaxType)``. /// - Parameter node: the node that is being visited /// - Returns: the rewritten node + \(node.apiAttributes())\ open func visit(_ node: \(node.kind.syntaxType)) -> \(node.kind.syntaxType) { return Syntax(visitChildren(node)).cast(\(node.kind.syntaxType).self) } @@ -136,6 +137,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { /// Visit a ``\(node.kind.syntaxType)``. /// - Parameter node: the node that is being visited /// - Returns: the rewritten node + \(node.apiAttributes())\ open func visit(_ node: \(node.kind.syntaxType)) -> \(raw: node.baseType.syntaxBaseName) { return \(raw: node.baseType.syntaxBaseName)(visitChildren(node)) } @@ -144,12 +146,14 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } } - for baseKind in SyntaxNodeKind.allCases where baseKind.isBase && baseKind != .syntax && baseKind != .syntaxCollection { + for baseNode in SYNTAX_NODES where baseNode.kind.isBase && baseNode.kind != .syntax && baseNode.kind != .syntaxCollection { + let baseKind = baseNode.kind DeclSyntax( """ /// Visit any \(raw: baseKind.syntaxType) node. /// - Parameter node: the node that is being visited /// - Returns: the rewritten node + \(baseNode.apiAttributes())\ public func visit(_ node: \(raw: baseKind.syntaxType)) -> \(raw: baseKind.syntaxType) { return visit(node.data).cast(\(raw: baseKind.syntaxType).self) } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTransformFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTransformFile.swift index ca4fd296a03..ac87f974353 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTransformFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTransformFile.swift @@ -16,14 +16,21 @@ import SyntaxSupport import Utils let syntaxTransformFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { - try! ProtocolDeclSyntax("public protocol SyntaxTransformVisitor") { + try! ProtocolDeclSyntax( + """ + @_spi(SyntaxTransformVisitor) + public protocol SyntaxTransformVisitor + """ + ) { DeclSyntax("associatedtype ResultType = Void") DeclSyntax("func visitAny(_ node: Syntax) -> ResultType") DeclSyntax("func visit(_ token: TokenSyntax) -> ResultType") - for node in SYNTAX_NODES where !node.kind.isBase { + // Don't bother including experimental nodes here since we want to remove + // SyntaxTransformVisitor anyway. + for node in SYNTAX_NODES where !node.kind.isBase && !node.isExperimental { DeclSyntax( """ /// Visiting ``\(node.kind.syntaxType)`` specifically. @@ -50,6 +57,7 @@ let syntaxTransformFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { /// Visiting ``\(node.kind.syntaxType)`` specifically. /// - Parameter node: the node we are visiting. /// - Returns: nil by default. + \(node.apiAttributes())\ public func visit(_ node: \(node.kind.syntaxType)) -> ResultType { visitAny(Syntax(node)) } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxVisitorFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxVisitorFile.swift index 3fc60cdb8e4..a24e4f94cc1 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxVisitorFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxVisitorFile.swift @@ -56,6 +56,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { /// Visiting ``\(node.kind.syntaxType)`` specifically. /// - Parameter node: the node we are visiting. /// - Returns: how should we continue visiting. + \(node.apiAttributes())\ open func visit(_ node: \(node.kind.syntaxType)) -> SyntaxVisitorContinueKind { return .visitChildren } @@ -66,6 +67,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { """ /// The function called after visiting ``\(node.kind.syntaxType)`` and its descendants. /// - node: the node we just finished visiting. + \(node.apiAttributes())\ open func visitPost(_ node: \(node.kind.syntaxType)) {} """ ) diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift index 210a67bf100..b2c5db131ab 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift @@ -26,11 +26,26 @@ let tokenKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { // Tokens that don't have a set text have an associated value that // contains their text. if tokenSpec.kind == .keyword { - DeclSyntax("case \(tokenSpec.varOrCaseName)(Keyword)") + DeclSyntax( + """ + \(tokenSpec.apiAttributes)\ + case \(tokenSpec.varOrCaseName)(Keyword) + """ + ) } else if tokenSpec.text == nil { - DeclSyntax("case \(tokenSpec.varOrCaseName)(String)") + DeclSyntax( + """ + \(tokenSpec.apiAttributes)\ + case \(tokenSpec.varOrCaseName)(String) + """ + ) } else { - DeclSyntax("case \(tokenSpec.varOrCaseName)") + DeclSyntax( + """ + \(tokenSpec.apiAttributes)\ + case \(tokenSpec.varOrCaseName) + """ + ) } } @@ -140,7 +155,12 @@ let tokenKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { """ ) { for tokenSpec in Token.allCases.map(\.spec) { - DeclSyntax("case \(tokenSpec.varOrCaseName)") + DeclSyntax( + """ + \(tokenSpec.apiAttributes)\ + case \(tokenSpec.varOrCaseName) + """ + ) } try VariableDeclSyntax( diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/ResultBuildersFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/ResultBuildersFile.swift index ce207805834..7d6eadd69e0 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/ResultBuildersFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/ResultBuildersFile.swift @@ -26,6 +26,7 @@ let resultBuildersFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { try! StructDeclSyntax( """ @resultBuilder + \(node.node.apiAttributes())\ public struct \(type.resultBuilderType) """ ) { diff --git a/Sources/SwiftParser/CMakeLists.txt b/Sources/SwiftParser/CMakeLists.txt index dc5815c110a..ae849ac9deb 100644 --- a/Sources/SwiftParser/CMakeLists.txt +++ b/Sources/SwiftParser/CMakeLists.txt @@ -13,6 +13,7 @@ add_swift_host_library(SwiftParser CollectionNodes+Parsable.swift Declarations.swift Directives.swift + ExperimentalFeatures.swift Expressions.swift IncrementalParseTransition.swift Lookahead.swift diff --git a/Sources/SwiftParser/ExperimentalFeatures.swift b/Sources/SwiftParser/ExperimentalFeatures.swift new file mode 100644 index 00000000000..ce80c1e689e --- /dev/null +++ b/Sources/SwiftParser/ExperimentalFeatures.swift @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 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 +// +//===----------------------------------------------------------------------===// + +extension Parser { + @_spi(ExperimentalLanguageFeatures) + public struct ExperimentalFeatures: OptionSet { + public let rawValue: UInt + public init(rawValue: UInt) { + self.rawValue = rawValue + } + } +} diff --git a/Sources/SwiftParser/Lookahead.swift b/Sources/SwiftParser/Lookahead.swift index deb8211518d..be0dd795735 100644 --- a/Sources/SwiftParser/Lookahead.swift +++ b/Sources/SwiftParser/Lookahead.swift @@ -27,22 +27,36 @@ extension Parser { /// i.e. how far it looked ahead. var tokensConsumed: Int = 0 + /// The experimental features that have been enabled in the underlying + /// parser. + let experimentalFeatures: ExperimentalFeatures + private init( lexemes: Lexer.LexemeSequence, - currentToken: Lexer.Lexeme + currentToken: Lexer.Lexeme, + experimentalFeatures: ExperimentalFeatures ) { self.lexemes = lexemes self.currentToken = currentToken + self.experimentalFeatures = experimentalFeatures } fileprivate init(cloning other: Parser) { - self.init(lexemes: other.lexemes, currentToken: other.currentToken) + self.init( + lexemes: other.lexemes, + currentToken: other.currentToken, + experimentalFeatures: other.experimentalFeatures + ) } /// Initiates a lookahead session from the current point in this /// lookahead session. func lookahead() -> Lookahead { - return Lookahead(lexemes: self.lexemes, currentToken: self.currentToken) + return Lookahead( + lexemes: self.lexemes, + currentToken: self.currentToken, + experimentalFeatures: self.experimentalFeatures + ) } } diff --git a/Sources/SwiftParser/ParseSourceFile.swift b/Sources/SwiftParser/ParseSourceFile.swift index 58bc41d191a..a19e9c0c651 100644 --- a/Sources/SwiftParser/ParseSourceFile.swift +++ b/Sources/SwiftParser/ParseSourceFile.swift @@ -22,6 +22,16 @@ extension Parser { return SourceFileSyntax.parse(from: &parser) } + /// A compiler interface that allows the enabling of experimental features. + @_spi(ExperimentalLanguageFeatures) + public static func parse( + source: UnsafeBufferPointer, + experimentalFeatures: ExperimentalFeatures + ) -> SourceFileSyntax { + var parser = Parser(source, experimentalFeatures: experimentalFeatures) + return SourceFileSyntax.parse(from: &parser) + } + /// Parse the source code in the given buffer as Swift source file. See /// `Parser.init` for more details. public static func parse( diff --git a/Sources/SwiftParser/Parser.swift b/Sources/SwiftParser/Parser.swift index 3005db8c30a..876b7d614cb 100644 --- a/Sources/SwiftParser/Parser.swift +++ b/Sources/SwiftParser/Parser.swift @@ -115,7 +115,10 @@ public struct Parser { public internal(set) var lookaheadRanges = LookaheadRanges() /// Parser should own a ``LookaheadTracker`` so that we can share one `furthestOffset` in a parse. - let lookaheadTrackerOwner = LookaheadTrackerOwner() + let lookaheadTrackerOwner: LookaheadTrackerOwner + + /// The experimental features that have been enabled. + let experimentalFeatures: ExperimentalFeatures /// A default maximum nesting level that is used if the client didn't /// explicitly specify one. Debug builds of the parser consume a lot more stack @@ -126,25 +129,49 @@ public struct Parser { static let defaultMaximumNestingLevel = 256 #endif - /// Initializes a ``Parser`` from the given string. - public init( - _ input: String, - maximumNestingLevel: Int? = nil, - parseTransition: IncrementalParseTransition? = nil + /// The delegated initializer for the parser. + /// + /// - Parameters + /// - input: An input buffer containing Swift source text. If a non-`nil` + /// arena is provided, the buffer must be present in it. Otherwise + /// the buffer is copied into a new arena and can thus be freed + /// after the initializer has been called. + /// - maximumNestingLevel: To avoid overflowing the stack, the parser will + /// stop if a nesting level greater than this value + /// is reached. The nesting level is increased + /// whenever a bracketed expression like `(` or `{` + /// is started. `defaultMaximumNestingLevel` is used + /// if this is `nil`. + /// - parseTransition: The previously recorded state for an incremental + /// parse, or `nil`. + /// - arena: Arena the parsing syntax are made into. If it's `nil`, a new + /// arena is created automatically, and `input` copied into the + /// arena. If non-`nil`, `input` must be within its registered + /// source buffer or allocator. + /// - experimentalFeatures: The experimental features enabled for the parser. + private init( + buffer input: UnsafeBufferPointer, + maximumNestingLevel: Int?, + parseTransition: IncrementalParseTransition?, + arena: ParsingSyntaxArena?, + experimentalFeatures: ExperimentalFeatures ) { - self.maximumNestingLevel = maximumNestingLevel ?? Self.defaultMaximumNestingLevel - - self.arena = ParsingSyntaxArena( - parseTriviaFunction: TriviaParser.parseTrivia(_:position:) - ) - var input = input - input.makeContiguousUTF8() - let interned = input.withUTF8 { [arena] buffer in - return arena.internSourceBuffer(buffer) + if let arena { + self.arena = arena + precondition(arena.contains(text: SyntaxText(baseAddress: input.baseAddress, count: input.count))) + } else { + self.arena = ParsingSyntaxArena( + parseTriviaFunction: TriviaParser.parseTrivia(_:position:) + ) + input = self.arena.internSourceBuffer(input) } - self.lexemes = Lexer.tokenize(interned, lookaheadTracker: lookaheadTrackerOwner.lookaheadTracker) + self.maximumNestingLevel = maximumNestingLevel ?? Self.defaultMaximumNestingLevel + self.experimentalFeatures = experimentalFeatures + self.lookaheadTrackerOwner = LookaheadTrackerOwner() + + self.lexemes = Lexer.tokenize(input, lookaheadTracker: lookaheadTrackerOwner.lookaheadTracker) self.currentToken = self.lexemes.advance() if let parseTransition { self.parseLookup = IncrementalParseLookup(transition: parseTransition) @@ -153,16 +180,56 @@ public struct Parser { } } + /// Private initializer for creating a ``Parser`` from the given string. + private init( + string input: String, + maximumNestingLevel: Int?, + parseTransition: IncrementalParseTransition?, + experimentalFeatures: ExperimentalFeatures + ) { + var input = input + input.makeContiguousUTF8() + self = input.withUTF8 { buffer in + Parser( + buffer: buffer, + maximumNestingLevel: maximumNestingLevel, + parseTransition: parseTransition, + arena: nil, + experimentalFeatures: experimentalFeatures + ) + } + } + + /// Initializes a ``Parser`` from the given string. + public init( + _ input: String, + maximumNestingLevel: Int? = nil, + parseTransition: IncrementalParseTransition? = nil + ) { + // Chain to the private String initializer. + self.init( + string: input, + maximumNestingLevel: maximumNestingLevel, + parseTransition: parseTransition, + experimentalFeatures: [] + ) + } + /// Initializes a ``Parser`` from the given input buffer. /// /// - Parameters - /// - input: An input buffer containing Swift source text. + /// - input: An input buffer containing Swift source text. If a non-`nil` + /// arena is provided, the buffer must be present in it. Otherwise + /// the buffer is copied into a new arena and can thus be freed + /// after the initializer has been called. /// - maximumNestingLevel: To avoid overflowing the stack, the parser will /// stop if a nesting level greater than this value /// is reached. The nesting level is increased /// whenever a bracketed expression like `(` or `{` /// is started. `defaultMaximumNestingLevel` is used /// if this is `nil`. + /// - parseTransition: The previously recorded state for an incremental + /// parse, or `nil`. /// - arena: Arena the parsing syntax are made into. If it's `nil`, a new /// arena is created automatically, and `input` copied into the /// arena. If non-`nil`, `input` must be within its registered @@ -173,27 +240,52 @@ public struct Parser { parseTransition: IncrementalParseTransition? = nil, arena: ParsingSyntaxArena? = nil ) { - self.maximumNestingLevel = maximumNestingLevel ?? Self.defaultMaximumNestingLevel + // Chain to the private buffer initializer. + self.init( + buffer: input, + maximumNestingLevel: maximumNestingLevel, + parseTransition: parseTransition, + arena: arena, + experimentalFeatures: [] + ) + } - var sourceBuffer: UnsafeBufferPointer - if let arena { - self.arena = arena - sourceBuffer = input - precondition(arena.contains(text: SyntaxText(baseAddress: input.baseAddress, count: input.count))) - } else { - self.arena = ParsingSyntaxArena( - parseTriviaFunction: TriviaParser.parseTrivia(_:position:) - ) - sourceBuffer = self.arena.internSourceBuffer(input) - } + /// Initializes a ``Parser`` from the given input string, with a given set + /// of experimental language features. + @_spi(ExperimentalLanguageFeatures) + public init( + _ input: String, + maximumNestingLevel: Int? = nil, + parseTransition: IncrementalParseTransition? = nil, + experimentalFeatures: ExperimentalFeatures + ) { + // Chain to the private String initializer. + self.init( + string: input, + maximumNestingLevel: maximumNestingLevel, + parseTransition: parseTransition, + experimentalFeatures: experimentalFeatures + ) + } - self.lexemes = Lexer.tokenize(sourceBuffer, lookaheadTracker: lookaheadTrackerOwner.lookaheadTracker) - self.currentToken = self.lexemes.advance() - if let parseTransition { - self.parseLookup = IncrementalParseLookup(transition: parseTransition) - } else { - self.parseLookup = nil - } + /// Initializes a ``Parser`` from the given input buffer, with a given set + /// of experimental language features. + @_spi(ExperimentalLanguageFeatures) + public init( + _ input: UnsafeBufferPointer, + maximumNestingLevel: Int? = nil, + parseTransition: IncrementalParseTransition? = nil, + arena: ParsingSyntaxArena? = nil, + experimentalFeatures: ExperimentalFeatures + ) { + // Chain to the private buffer initializer. + self.init( + buffer: input, + maximumNestingLevel: maximumNestingLevel, + parseTransition: parseTransition, + arena: arena, + experimentalFeatures: experimentalFeatures + ) } mutating func missingToken(_ kind: RawTokenKind, text: SyntaxText? = nil) -> RawTokenSyntax { diff --git a/Sources/SwiftParser/Statements.swift b/Sources/SwiftParser/Statements.swift index 3675e9d71f4..7288500d37f 100644 --- a/Sources/SwiftParser/Statements.swift +++ b/Sources/SwiftParser/Statements.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -@_spi(RawSyntax) import SwiftSyntax +@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax extension TokenConsumer { /// Returns `true` if the current token represents the start of a statement diff --git a/Sources/SwiftParser/TokenPrecedence.swift b/Sources/SwiftParser/TokenPrecedence.swift index 3eb38c2802f..276eda2733b 100644 --- a/Sources/SwiftParser/TokenPrecedence.swift +++ b/Sources/SwiftParser/TokenPrecedence.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -@_spi(RawSyntax) import SwiftSyntax +@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax /// Describes how distinctive a token is for parser recovery. When expecting a /// token, tokens with a lower token precedence may be skipped and considered diff --git a/Sources/SwiftParser/TokenSpecSet.swift b/Sources/SwiftParser/TokenSpecSet.swift index fa94daba197..585274660f6 100644 --- a/Sources/SwiftParser/TokenSpecSet.swift +++ b/Sources/SwiftParser/TokenSpecSet.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -@_spi(RawSyntax) import SwiftSyntax +@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax /// A set of `TokenSpecs`. We expect to consume one of the sets specs in the /// parser. diff --git a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift index e4b93764270..a8439b74148 100644 --- a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift @@ -12,7 +12,7 @@ import SwiftDiagnostics @_spi(Diagnostics) import SwiftParser -@_spi(RawSyntax) import SwiftSyntax +@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax fileprivate func getTokens(between first: TokenSyntax, and second: TokenSyntax) -> [TokenSyntax] { var first = first diff --git a/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift index caf00deb6a2..3bf1e804c01 100644 --- a/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift +++ b/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -import SwiftSyntax +@_spi(ExperimentalLanguageFeatures) import SwiftSyntax extension SyntaxKind { var nameForDiagnostics: String? { diff --git a/Sources/SwiftSyntax/generated/SyntaxTransform.swift b/Sources/SwiftSyntax/generated/SyntaxTransform.swift index 2655fe4b83f..c74e7f8e855 100644 --- a/Sources/SwiftSyntax/generated/SyntaxTransform.swift +++ b/Sources/SwiftSyntax/generated/SyntaxTransform.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +@_spi(SyntaxTransformVisitor) public protocol SyntaxTransformVisitor { associatedtype ResultType = Void diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift index 2bc227deab8..1cd01393618 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift @@ -5731,9 +5731,10 @@ public struct SimpleStringLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable self._syntaxNode = node._syntaxNode } - /// Creates a ``SimpleStringLiteralExprSyntax`` node from the given ``SyntaxData``. This assumes - /// that the `SyntaxData` is of the correct kind. If it is not, the behaviour - /// is undefined. + /// Creates a ``SimpleStringLiteralExprSyntax`` node from the given ``SyntaxData``. + /// + /// - Warning: This assumes that the `SyntaxData` is of the correct kind. + /// If it is not, the behaviour is undefined. internal init(_ data: SyntaxData) { precondition(data.raw.kind == .simpleStringLiteralExpr) self._syntaxNode = Syntax(data) @@ -5830,6 +5831,7 @@ public struct SimpleStringLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable /// Adds the provided `element` to the node's `segments` /// collection. + /// /// - param element: The new `Segment` to add to the node's /// `segments` collection. /// - returns: A copy of the receiver with the provided `Segment` diff --git a/Tests/SwiftParserTest/AbsolutePositionTests.swift b/Tests/SwiftParserTest/AbsolutePositionTests.swift index 1a28c140ce2..7181fd88f5d 100644 --- a/Tests/SwiftParserTest/AbsolutePositionTests.swift +++ b/Tests/SwiftParserTest/AbsolutePositionTests.swift @@ -15,7 +15,7 @@ import SwiftSyntax import SwiftParser import _SwiftSyntaxTestSupport -public class AbsolutePositionTests: XCTestCase { +public class AbsolutePositionTests: ParserTestCase { public func testTokenAt() { let source = """ diff --git a/Tests/SwiftParserTest/Assertions.swift b/Tests/SwiftParserTest/Assertions.swift index 6a3df1e8b62..e75ed7740fe 100644 --- a/Tests/SwiftParserTest/Assertions.swift +++ b/Tests/SwiftParserTest/Assertions.swift @@ -12,7 +12,7 @@ import XCTest @_spi(RawSyntax) import SwiftSyntax -@_spi(Testing) @_spi(RawSyntax) @_spi(AlternateTokenIntrospection) import SwiftParser +@_spi(Testing) @_spi(RawSyntax) @_spi(AlternateTokenIntrospection) @_spi(ExperimentalLanguageFeatures) import SwiftParser @_spi(RawSyntax) import SwiftParserDiagnostics import SwiftDiagnostics import _SwiftSyntaxTestSupport @@ -527,203 +527,209 @@ public struct AssertParseOptions: OptionSet { public static let normalizeNewlinesInFixedSource = AssertParseOptions(rawValue: 1 << 1) } -/// Same as `assertParse` overload with a `(String) -> S` `parse`, -/// parsing the resulting `String` as a ``SourceFileSyntax``. -func assertParse( - _ markedSource: String, - substructure expectedSubstructure: (some SyntaxProtocol)? = Optional.none, - substructureAfterMarker: String = "START", - diagnostics expectedDiagnostics: [DiagnosticSpec] = [], - applyFixIts: [String]? = nil, - fixedSource expectedFixedSource: String? = nil, - options: AssertParseOptions = [], - file: StaticString = #file, - line: UInt = #line -) { - assertParse( - markedSource, - { SourceFileSyntax.parse(from: &$0) }, - substructure: expectedSubstructure, - substructureAfterMarker: substructureAfterMarker, - diagnostics: expectedDiagnostics, - applyFixIts: applyFixIts, - fixedSource: expectedFixedSource, - options: options, - file: file, - line: line - ) -} - -/// After a test case has been mutated, assert that the mutated source -/// round-trips and doesn’t hit any assertion failures in the parser. -fileprivate func assertRoundTrip( - source: [UInt8], - _ parse: (inout Parser) -> S, - file: StaticString, - line: UInt -) { - source.withUnsafeBufferPointer { buf in - let mutatedSource = String(decoding: buf, as: UTF8.self) - // Check that we don't hit any assertions in the parser while parsing - // the mutated source and that it round-trips - var mutatedParser = Parser(buf) - let mutatedTree = parse(&mutatedParser) - // Run the diagnostic generator to make sure it doesn’t crash - _ = ParseDiagnosticsGenerator.diagnostics(for: mutatedTree) - assertStringsEqualWithDiff( - "\(mutatedTree)", - mutatedSource, - additionalInfo: """ - Mutated source failed to round-trip. - - Mutated source: - \(mutatedSource) - - Actual syntax tree: - \(mutatedTree.debugDescription) - """, +extension ParserTestCase { + /// Same as `assertParse` overload with a `(String) -> S` `parse`, + /// parsing the resulting `String` as a ``SourceFileSyntax``. + func assertParse( + _ markedSource: String, + substructure expectedSubstructure: (some SyntaxProtocol)? = Optional.none, + substructureAfterMarker: String = "START", + diagnostics expectedDiagnostics: [DiagnosticSpec] = [], + applyFixIts: [String]? = nil, + fixedSource expectedFixedSource: String? = nil, + options: AssertParseOptions = [], + experimentalFeatures: Parser.ExperimentalFeatures = [], + file: StaticString = #file, + line: UInt = #line + ) { + assertParse( + markedSource, + { SourceFileSyntax.parse(from: &$0) }, + substructure: expectedSubstructure, + substructureAfterMarker: substructureAfterMarker, + diagnostics: expectedDiagnostics, + applyFixIts: applyFixIts, + fixedSource: expectedFixedSource, + options: options, + experimentalFeatures: experimentalFeatures, file: file, line: line ) } -} - -/// Removes any test markers from `markedSource` (1) and parses the result -/// using `parse`. By default it only checks if the parsed syntax tree is -/// printable back to the origin source, ie. it round trips. -/// -/// (1) `markedSource` is source that can include markers of the form `1️⃣`, -/// to be used as locations in the following parameters when they exist. -/// -/// - Parameters: -/// - substructure: Asserts the parsed syntax tree contains this structure. -/// - substructureAfterMarker: Changes the position to start the structure -/// assertion from, ie. allows matching a particular substructure rather -/// than the whole source. -/// - diagnostics: Asserts the given diagnostics were output, by default it -/// asserts the parse was successful (ie. it has no diagnostics). Note -/// that `DiagnosticsSpec` uses the location marked by `1️⃣` by default. -/// - applyFixIts: Applies only the fix-its with these messages. -/// - fixedSource: Asserts that the source after applying fix-its matches -/// this string. -func assertParse( - _ markedSource: String, - _ parse: (inout Parser) -> S, - substructure expectedSubstructure: (some SyntaxProtocol)? = Optional.none, - substructureAfterMarker: String = "START", - diagnostics expectedDiagnostics: [DiagnosticSpec] = [], - applyFixIts: [String]? = nil, - fixedSource expectedFixedSource: String? = nil, - options: AssertParseOptions = [], - file: StaticString = #file, - line: UInt = #line -) { - // Verify the parser can round-trip the source - var (markerLocations, source) = extractMarkers(markedSource) - markerLocations["START"] = 0 - - let enableLongTests = ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] != "1" - - var parser = Parser(source) - #if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION - if enableLongTests { - parser.enableAlternativeTokenChoices() - } - #endif - let tree: S = parse(&parser) - // Round-trip - assertStringsEqualWithDiff( - "\(tree)", - source, - additionalInfo: """ - Source failed to round-trip. + /// After a test case has been mutated, assert that the mutated source + /// round-trips and doesn’t hit any assertion failures in the parser. + fileprivate func assertRoundTrip( + source: [UInt8], + _ parse: (inout Parser) -> S, + experimentalFeatures: Parser.ExperimentalFeatures, + file: StaticString, + line: UInt + ) { + source.withUnsafeBufferPointer { buf in + let mutatedSource = String(decoding: buf, as: UTF8.self) + // Check that we don't hit any assertions in the parser while parsing + // the mutated source and that it round-trips + var mutatedParser = Parser(buf, experimentalFeatures: experimentalFeatures) + let mutatedTree = parse(&mutatedParser) + // Run the diagnostic generator to make sure it doesn’t crash + _ = ParseDiagnosticsGenerator.diagnostics(for: mutatedTree) + assertStringsEqualWithDiff( + "\(mutatedTree)", + mutatedSource, + additionalInfo: """ + Mutated source failed to round-trip. - Actual syntax tree: - \(tree.debugDescription) - """, - file: file, - line: line - ) + Mutated source: + \(mutatedSource) - // Substructure - if let expectedSubstructure { - let subtreeMatcher = SubtreeMatcher(tree, markers: markerLocations) - do { - try subtreeMatcher.assertSameStructure( - afterMarker: substructureAfterMarker, - expectedSubstructure, - includeTrivia: options.contains(.substructureCheckTrivia), + Actual syntax tree: + \(mutatedTree.debugDescription) + """, file: file, line: line ) - } catch { - XCTFail("Matching for a subtree failed with error: \(error)", file: file, line: line) } } - // Diagnostics - let diags = ParseDiagnosticsGenerator.diagnostics(for: tree) - if diags.count != expectedDiagnostics.count { - XCTFail( - """ - Expected \(expectedDiagnostics.count) diagnostics but received \(diags.count): - \(diags.map(\.debugDescription).joined(separator: "\n")) - """, - file: file, - line: line - ) - } else { - for (diag, expectedDiag) in zip(diags, expectedDiagnostics) { - assertDiagnostic(diag, in: tree, markerLocations: markerLocations, expected: expectedDiag) - } - } + /// Removes any test markers from `markedSource` (1) and parses the result + /// using `parse`. By default it only checks if the parsed syntax tree is + /// printable back to the origin source, ie. it round trips. + /// + /// (1) `markedSource` is source that can include markers of the form `1️⃣`, + /// to be used as locations in the following parameters when they exist. + /// + /// - Parameters: + /// - substructure: Asserts the parsed syntax tree contains this structure. + /// - substructureAfterMarker: Changes the position to start the structure + /// assertion from, ie. allows matching a particular substructure rather + /// than the whole source. + /// - diagnostics: Asserts the given diagnostics were output, by default it + /// asserts the parse was successful (ie. it has no diagnostics). Note + /// that `DiagnosticsSpec` uses the location marked by `1️⃣` by default. + /// - applyFixIts: Applies only the fix-its with these messages. + /// - fixedSource: Asserts that the source after applying fix-its matches + /// this string. + func assertParse( + _ markedSource: String, + _ parse: (inout Parser) -> S, + substructure expectedSubstructure: (some SyntaxProtocol)? = Optional.none, + substructureAfterMarker: String = "START", + diagnostics expectedDiagnostics: [DiagnosticSpec] = [], + applyFixIts: [String]? = nil, + fixedSource expectedFixedSource: String? = nil, + options: AssertParseOptions = [], + experimentalFeatures: Parser.ExperimentalFeatures = [], + file: StaticString = #file, + line: UInt = #line + ) { + // Verify the parser can round-trip the source + var (markerLocations, source) = extractMarkers(markedSource) + markerLocations["START"] = 0 - // Applying Fix-Its - if expectedDiagnostics.contains(where: { !$0.fixIts.isEmpty }) && expectedFixedSource == nil { - XCTFail("Expected a fixed source if the test case produces diagnostics with Fix-Its", file: file, line: line) - } else if let expectedFixedSource = expectedFixedSource { - let fixedTree = FixItApplier.applyFixes(in: diags, withMessages: applyFixIts, to: tree) - var fixedTreeDescription = fixedTree.description - if options.contains(.normalizeNewlinesInFixedSource) { - fixedTreeDescription = - fixedTreeDescription - .replacingOccurrences(of: "\r\n", with: "\n") - .replacingOccurrences(of: "\r", with: "\n") + let enableLongTests = ProcessInfo.processInfo.environment["SKIP_LONG_TESTS"] != "1" + + var parser = Parser(source, experimentalFeatures: experimentalFeatures) + #if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION + if enableLongTests { + parser.enableAlternativeTokenChoices() } + #endif + let tree: S = parse(&parser) + + // Round-trip assertStringsEqualWithDiff( - fixedTreeDescription.trimmingTrailingWhitespace(), - expectedFixedSource.trimmingTrailingWhitespace(), + "\(tree)", + source, + additionalInfo: """ + Source failed to round-trip. + + Actual syntax tree: + \(tree.debugDescription) + """, file: file, line: line ) - } - if expectedDiagnostics.allSatisfy({ $0.fixIts.isEmpty }) && expectedFixedSource != nil { - XCTFail("A fixed source was provided but the test case produces no diagnostics with Fix-Its", file: file, line: line) - } + // Substructure + if let expectedSubstructure { + let subtreeMatcher = SubtreeMatcher(tree, markers: markerLocations) + do { + try subtreeMatcher.assertSameStructure( + afterMarker: substructureAfterMarker, + expectedSubstructure, + includeTrivia: options.contains(.substructureCheckTrivia), + file: file, + line: line + ) + } catch { + XCTFail("Matching for a subtree failed with error: \(error)", file: file, line: line) + } + } - if expectedDiagnostics.isEmpty { - assertBasicFormat(source: source, parse: parse, file: file, line: line) - } + // Diagnostics + let diags = ParseDiagnosticsGenerator.diagnostics(for: tree) + if diags.count != expectedDiagnostics.count { + XCTFail( + """ + Expected \(expectedDiagnostics.count) diagnostics but received \(diags.count): + \(diags.map(\.debugDescription).joined(separator: "\n")) + """, + file: file, + line: line + ) + } else { + for (diag, expectedDiag) in zip(diags, expectedDiagnostics) { + assertDiagnostic(diag, in: tree, markerLocations: markerLocations, expected: expectedDiag) + } + } - if enableLongTests { - DispatchQueue.concurrentPerform(iterations: Array(tree.tokens(viewMode: .all)).count) { tokenIndex in - let flippedTokenTree = TokenPresenceFlipper(flipTokenAtIndex: tokenIndex).rewrite(Syntax(tree)) - _ = ParseDiagnosticsGenerator.diagnostics(for: flippedTokenTree) - assertRoundTrip(source: flippedTokenTree.syntaxTextBytes, parse, file: file, line: line) + // Applying Fix-Its + if expectedDiagnostics.contains(where: { !$0.fixIts.isEmpty }) && expectedFixedSource == nil { + XCTFail("Expected a fixed source if the test case produces diagnostics with Fix-Its", file: file, line: line) + } else if let expectedFixedSource = expectedFixedSource { + let fixedTree = FixItApplier.applyFixes(in: diags, withMessages: applyFixIts, to: tree) + var fixedTreeDescription = fixedTree.description + if options.contains(.normalizeNewlinesInFixedSource) { + fixedTreeDescription = + fixedTreeDescription + .replacingOccurrences(of: "\r\n", with: "\n") + .replacingOccurrences(of: "\r", with: "\n") + } + assertStringsEqualWithDiff( + fixedTreeDescription.trimmingTrailingWhitespace(), + expectedFixedSource.trimmingTrailingWhitespace(), + file: file, + line: line + ) } - #if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION - let mutations: [(offset: Int, replacement: TokenSpec)] = parser.alternativeTokenChoices.flatMap { offset, replacements in - return replacements.map { (offset, $0) } + if expectedDiagnostics.allSatisfy({ $0.fixIts.isEmpty }) && expectedFixedSource != nil { + XCTFail("A fixed source was provided but the test case produces no diagnostics with Fix-Its", file: file, line: line) } - DispatchQueue.concurrentPerform(iterations: mutations.count) { index in - let mutation = mutations[index] - let alternateSource = MutatedTreePrinter.print(tree: Syntax(tree), mutations: [mutation.offset: mutation.replacement]) - assertRoundTrip(source: alternateSource, parse, file: file, line: line) + + if expectedDiagnostics.isEmpty { + assertBasicFormat(source: source, parse: parse, experimentalFeatures: experimentalFeatures, file: file, line: line) + } + + if enableLongTests { + DispatchQueue.concurrentPerform(iterations: Array(tree.tokens(viewMode: .all)).count) { tokenIndex in + let flippedTokenTree = TokenPresenceFlipper(flipTokenAtIndex: tokenIndex).rewrite(Syntax(tree)) + _ = ParseDiagnosticsGenerator.diagnostics(for: flippedTokenTree) + assertRoundTrip(source: flippedTokenTree.syntaxTextBytes, parse, experimentalFeatures: experimentalFeatures, file: file, line: line) + } + + #if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION + let mutations: [(offset: Int, replacement: TokenSpec)] = parser.alternativeTokenChoices.flatMap { offset, replacements in + return replacements.map { (offset, $0) } + } + DispatchQueue.concurrentPerform(iterations: mutations.count) { index in + let mutation = mutations[index] + let alternateSource = MutatedTreePrinter.print(tree: Syntax(tree), mutations: [mutation.offset: mutation.replacement]) + assertRoundTrip(source: alternateSource, parse, experimentalFeatures: experimentalFeatures, file: file, line: line) + } + #endif } - #endif } } @@ -758,15 +764,16 @@ class TriviaRemover: SyntaxRewriter { func assertBasicFormat( source: String, parse: (inout Parser) -> S, + experimentalFeatures: Parser.ExperimentalFeatures, file: StaticString = #file, line: UInt = #line ) { - var parser = Parser(source) + var parser = Parser(source, experimentalFeatures: experimentalFeatures) let sourceTree = parse(&parser) let withoutTrivia = TriviaRemover(viewMode: .sourceAccurate).rewrite(sourceTree) let formatted = withoutTrivia.formatted() - var formattedParser = Parser(formatted.description) + var formattedParser = Parser(formatted.description, experimentalFeatures: experimentalFeatures) let formattedReparsed = Syntax(parse(&formattedParser)) do { diff --git a/Tests/SwiftParserTest/AttributeTests.swift b/Tests/SwiftParserTest/AttributeTests.swift index bb5de7f0631..52e833f2a3d 100644 --- a/Tests/SwiftParserTest/AttributeTests.swift +++ b/Tests/SwiftParserTest/AttributeTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class AttributeTests: XCTestCase { +final class AttributeTests: ParserTestCase { func testMissingArgumentToAttribute() { assertParse( """ diff --git a/Tests/SwiftParserTest/AvailabilityTests.swift b/Tests/SwiftParserTest/AvailabilityTests.swift index 642df4317f0..9dc2904bd02 100644 --- a/Tests/SwiftParserTest/AvailabilityTests.swift +++ b/Tests/SwiftParserTest/AvailabilityTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class AvailabilityTests: XCTestCase { +final class AvailabilityTests: ParserTestCase { func testAvailableMember() { assertParse( """ diff --git a/Tests/SwiftParserTest/DeclarationTests.swift b/Tests/SwiftParserTest/DeclarationTests.swift index 0b1c4b97db7..7a8eda2fbf8 100644 --- a/Tests/SwiftParserTest/DeclarationTests.swift +++ b/Tests/SwiftParserTest/DeclarationTests.swift @@ -16,7 +16,7 @@ import SwiftSyntaxBuilder import SwiftBasicFormat import XCTest -final class DeclarationTests: XCTestCase { +final class DeclarationTests: ParserTestCase { func testImports() { assertParse("import Foundation") diff --git a/Tests/SwiftParserTest/DirectiveTests.swift b/Tests/SwiftParserTest/DirectiveTests.swift index 780832aec02..f8bf2222234 100644 --- a/Tests/SwiftParserTest/DirectiveTests.swift +++ b/Tests/SwiftParserTest/DirectiveTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class DirectiveTests: XCTestCase { +final class DirectiveTests: ParserTestCase { func testSwitchIfConfig() { assertParse( """ diff --git a/Tests/SwiftParserTest/ExpressionTests.swift b/Tests/SwiftParserTest/ExpressionTests.swift index 8caa40c3f1f..574bee52da2 100644 --- a/Tests/SwiftParserTest/ExpressionTests.swift +++ b/Tests/SwiftParserTest/ExpressionTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class ExpressionTests: XCTestCase { +final class ExpressionTests: ParserTestCase { func testTernary() { assertParse( "let a =1️⃣", @@ -1474,7 +1474,7 @@ final class ExpressionTests: XCTestCase { } } -final class MemberExprTests: XCTestCase { +final class MemberExprTests: ParserTestCase { func testMissing() { let cases: [UInt: String] = [ #line: "", @@ -1494,7 +1494,7 @@ final class MemberExprTests: XCTestCase { } } -final class StatementExpressionTests: XCTestCase { +final class StatementExpressionTests: ParserTestCase { private func ifZeroElseOne() -> ExprSyntax { .init( IfExprSyntax( diff --git a/Tests/SwiftParserTest/ExpressionTypeTests.swift b/Tests/SwiftParserTest/ExpressionTypeTests.swift index 85298c1c114..8f1f5b22bc1 100644 --- a/Tests/SwiftParserTest/ExpressionTypeTests.swift +++ b/Tests/SwiftParserTest/ExpressionTypeTests.swift @@ -13,7 +13,7 @@ import SwiftSyntax import XCTest -final class ExpressionTypeTests: XCTestCase { +final class ExpressionTypeTests: ParserTestCase { func testTypeExpression() { assertParse("_ = (any Sequence).self") } diff --git a/Tests/SwiftParserTest/IncrementalParsingTests.swift b/Tests/SwiftParserTest/IncrementalParsingTests.swift index 50d07db35a3..38faabbb246 100644 --- a/Tests/SwiftParserTest/IncrementalParsingTests.swift +++ b/Tests/SwiftParserTest/IncrementalParsingTests.swift @@ -15,7 +15,7 @@ import SwiftSyntax import SwiftParser import _SwiftSyntaxTestSupport -public class IncrementalParsingTests: XCTestCase { +public class IncrementalParsingTests: ParserTestCase { public func testBrokenMemberFunction() { assertIncrementalParse( diff --git a/Tests/SwiftParserTest/LexerTests.swift b/Tests/SwiftParserTest/LexerTests.swift index 854765471f7..c7345603152 100644 --- a/Tests/SwiftParserTest/LexerTests.swift +++ b/Tests/SwiftParserTest/LexerTests.swift @@ -60,7 +60,7 @@ fileprivate func assertRawBytesLexeme( XCTAssertEqual(lexeme.diagnostic, error, file: file, line: line) } -public class LexerTests: XCTestCase { +public class LexerTests: ParserTestCase { func testIdentifiers() { assertLexemes( "Hello World", diff --git a/Tests/SwiftParserTest/LinkageTests.swift b/Tests/SwiftParserTest/LinkageTests.swift index c13d0ed4fc6..8c9f736fb15 100644 --- a/Tests/SwiftParserTest/LinkageTests.swift +++ b/Tests/SwiftParserTest/LinkageTests.swift @@ -14,7 +14,7 @@ import Darwin import XCTest -final class LinkageTest: XCTestCase { +final class LinkageTest: ParserTestCase { // Assert that SwiftSyntax and SwiftParser do not introduce more link-time // dependencies than are strictly necessary. We want to minimize our link-time // dependencies. If this set changes - in particular, if it grows - consult diff --git a/Tests/SwiftParserTest/Parser+EntryTests.swift b/Tests/SwiftParserTest/Parser+EntryTests.swift index b31c714bdd0..3a788c140bb 100644 --- a/Tests/SwiftParserTest/Parser+EntryTests.swift +++ b/Tests/SwiftParserTest/Parser+EntryTests.swift @@ -14,7 +14,7 @@ import SwiftSyntax import SwiftParser import XCTest -public class EntryTests: XCTestCase { +public class EntryTests: ParserTestCase { func testTopLevelStringParse() throws { let source = "func test() {}" let tree = Parser.parse(source: source) diff --git a/Tests/SwiftParserTest/ParserTestCase.swift b/Tests/SwiftParserTest/ParserTestCase.swift new file mode 100644 index 00000000000..1d593d19f48 --- /dev/null +++ b/Tests/SwiftParserTest/ParserTestCase.swift @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 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 XCTest +import SwiftSyntax + +@_spi(ExperimentalLanguageFeatures) import SwiftParser + +/// The base class for all parser test cases. +public class ParserTestCase: XCTestCase { + /// The default set of experimental features to test with. + var experimentalFeatures: Parser.ExperimentalFeatures { [] } +} diff --git a/Tests/SwiftParserTest/ParserTests.swift b/Tests/SwiftParserTest/ParserTests.swift index 603ab80f358..7e18a8756b2 100644 --- a/Tests/SwiftParserTest/ParserTests.swift +++ b/Tests/SwiftParserTest/ParserTests.swift @@ -17,7 +17,7 @@ import SwiftSyntax import SwiftParser import SwiftParserDiagnostics -public class ParserTests: XCTestCase { +public class ParserTests: ParserTestCase { /// Run a single parse test. func runParseTest(fileURL: URL, checkDiagnostics: Bool) throws { let fileContents = try Data(contentsOf: fileURL) diff --git a/Tests/SwiftParserTest/PatternTests.swift b/Tests/SwiftParserTest/PatternTests.swift index 4ad168fc40d..2ba1c39a709 100644 --- a/Tests/SwiftParserTest/PatternTests.swift +++ b/Tests/SwiftParserTest/PatternTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class PatternTests: XCTestCase { +final class PatternTests: ParserTestCase { private var genericArgEnumPattern: Syntax { // let E.e(y) Syntax( diff --git a/Tests/SwiftParserTest/RegexLiteralTests.swift b/Tests/SwiftParserTest/RegexLiteralTests.swift index 1cb8653b90f..30fc6feeb63 100644 --- a/Tests/SwiftParserTest/RegexLiteralTests.swift +++ b/Tests/SwiftParserTest/RegexLiteralTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class RegexLiteralTests: XCTestCase { +final class RegexLiteralTests: ParserTestCase { func testForwardSlash1() { assertParse( #""" diff --git a/Tests/SwiftParserTest/SequentialToConcurrentEditTranslationTests.swift b/Tests/SwiftParserTest/SequentialToConcurrentEditTranslationTests.swift index 158be736d6e..1b962d2ef46 100644 --- a/Tests/SwiftParserTest/SequentialToConcurrentEditTranslationTests.swift +++ b/Tests/SwiftParserTest/SequentialToConcurrentEditTranslationTests.swift @@ -46,7 +46,7 @@ func verifySequentialToConcurrentTranslation( ) } -final class TranslateSequentialToConcurrentEditsTests: XCTestCase { +final class TranslateSequentialToConcurrentEditsTests: ParserTestCase { func testEmpty() { verifySequentialToConcurrentTranslation([], []) } diff --git a/Tests/SwiftParserTest/StatementTests.swift b/Tests/SwiftParserTest/StatementTests.swift index 1da809db554..f1ea85d05fc 100644 --- a/Tests/SwiftParserTest/StatementTests.swift +++ b/Tests/SwiftParserTest/StatementTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class StatementTests: XCTestCase { +final class StatementTests: ParserTestCase { func testIf() { assertParse( """ diff --git a/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift b/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift index ecdfa865033..d1ba1fddadd 100644 --- a/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift +++ b/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift @@ -19,7 +19,7 @@ import SwiftSyntaxBuilder /// /// Most tests are expressed by a single function call that compares the /// run-time String value against the parsed node's `representedLiteralValue`. -public class StringLiteralRepresentedLiteralValueTests: XCTestCase { +public class StringLiteralRepresentedLiteralValueTests: ParserTestCase { func testIntro() { test( diff --git a/Tests/SwiftParserTest/SyntaxTransformVisitorTest.swift b/Tests/SwiftParserTest/SyntaxTransformVisitorTest.swift index e204a872f19..c59da8fe0d7 100644 --- a/Tests/SwiftParserTest/SyntaxTransformVisitorTest.swift +++ b/Tests/SwiftParserTest/SyntaxTransformVisitorTest.swift @@ -12,9 +12,9 @@ import XCTest import SwiftParser -import SwiftSyntax +@_spi(SyntaxTransformVisitor) import SwiftSyntax -final class SyntaxTransformVisitorTest: XCTestCase { +final class SyntaxTransformVisitorTest: ParserTestCase { public func testFunctionCounter() { struct FuncCounter: SyntaxTransformVisitor { public func visitAny(_ node: Syntax) -> Int { diff --git a/Tests/SwiftParserTest/TriviaParserTests.swift b/Tests/SwiftParserTest/TriviaParserTests.swift index 58f2a8b052f..696a490c7a9 100644 --- a/Tests/SwiftParserTest/TriviaParserTests.swift +++ b/Tests/SwiftParserTest/TriviaParserTests.swift @@ -14,7 +14,7 @@ import XCTest @_spi(RawSyntax) import SwiftSyntax @_spi(RawSyntax) @_spi(Testing) import SwiftParser -final class TriviaParserTests: XCTestCase { +final class TriviaParserTests: ParserTestCase { func testTriviaParsing() { diff --git a/Tests/SwiftParserTest/TypeCompositionTests.swift b/Tests/SwiftParserTest/TypeCompositionTests.swift index b16c88093e7..d0f9ce14e83 100644 --- a/Tests/SwiftParserTest/TypeCompositionTests.swift +++ b/Tests/SwiftParserTest/TypeCompositionTests.swift @@ -14,7 +14,7 @@ import SwiftSyntax import SwiftParser import XCTest -final class TypeCompositionTests: XCTestCase { +final class TypeCompositionTests: ParserTestCase { func testComponents() { let cases: [UInt: String] = [ // Identifiers and member types diff --git a/Tests/SwiftParserTest/TypeMemberTests.swift b/Tests/SwiftParserTest/TypeMemberTests.swift index bebde366fd3..a5681d92c3e 100644 --- a/Tests/SwiftParserTest/TypeMemberTests.swift +++ b/Tests/SwiftParserTest/TypeMemberTests.swift @@ -14,7 +14,7 @@ import SwiftSyntax import SwiftParser import XCTest -final class TypeMemberTests: XCTestCase { +final class TypeMemberTests: ParserTestCase { func testKeyword() { assertParse( "MyType.class", diff --git a/Tests/SwiftParserTest/TypeMetatypeTests.swift b/Tests/SwiftParserTest/TypeMetatypeTests.swift index eea84ca2b4e..7cc024b016f 100644 --- a/Tests/SwiftParserTest/TypeMetatypeTests.swift +++ b/Tests/SwiftParserTest/TypeMetatypeTests.swift @@ -14,7 +14,7 @@ import SwiftSyntax import SwiftParser import XCTest -final class TypeMetatypeTests: XCTestCase { +final class TypeMetatypeTests: ParserTestCase { func testBaseType() { let cases: [UInt: String] = [ // Identifiers and member types diff --git a/Tests/SwiftParserTest/TypeTests.swift b/Tests/SwiftParserTest/TypeTests.swift index 230d1ceca62..5eccd0a0ab6 100644 --- a/Tests/SwiftParserTest/TypeTests.swift +++ b/Tests/SwiftParserTest/TypeTests.swift @@ -14,7 +14,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class TypeTests: XCTestCase { +final class TypeTests: ParserTestCase { func testMissingColonInType() { assertParse( """ diff --git a/Tests/SwiftParserTest/VariadicGenericsTests.swift b/Tests/SwiftParserTest/VariadicGenericsTests.swift index 72db1724983..a74c48dcbf1 100644 --- a/Tests/SwiftParserTest/VariadicGenericsTests.swift +++ b/Tests/SwiftParserTest/VariadicGenericsTests.swift @@ -13,7 +13,7 @@ import SwiftSyntax import XCTest -final class VariadicGenericsTests: XCTestCase { +final class VariadicGenericsTests: ParserTestCase { func testSimpleForwarding() { assertParse( """ @@ -297,7 +297,7 @@ final class VariadicGenericsTests: XCTestCase { } } -final class TypeParameterPackTests: XCTestCase { +final class TypeParameterPackTests: ParserTestCase { func testParameterPacks1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ActorTests.swift b/Tests/SwiftParserTest/translated/ActorTests.swift index 037f0391895..b7751910150 100644 --- a/Tests/SwiftParserTest/translated/ActorTests.swift +++ b/Tests/SwiftParserTest/translated/ActorTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ActorTests: XCTestCase { +final class ActorTests: ParserTestCase { func testActor1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/AlwaysEmitConformanceMetadataAttrTests.swift b/Tests/SwiftParserTest/translated/AlwaysEmitConformanceMetadataAttrTests.swift index a8c11b77737..8cc27542bb4 100644 --- a/Tests/SwiftParserTest/translated/AlwaysEmitConformanceMetadataAttrTests.swift +++ b/Tests/SwiftParserTest/translated/AlwaysEmitConformanceMetadataAttrTests.swift @@ -14,7 +14,7 @@ import XCTest -final class AlwaysEmitConformanceMetadataAttrTests: XCTestCase { +final class AlwaysEmitConformanceMetadataAttrTests: ParserTestCase { func testAlwaysEmitConformanceMetadataAttr() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/AsyncSyntaxTests.swift b/Tests/SwiftParserTest/translated/AsyncSyntaxTests.swift index ab51eb28eb5..ff751108d8d 100644 --- a/Tests/SwiftParserTest/translated/AsyncSyntaxTests.swift +++ b/Tests/SwiftParserTest/translated/AsyncSyntaxTests.swift @@ -14,7 +14,7 @@ import XCTest -final class AsyncSyntaxTests: XCTestCase { +final class AsyncSyntaxTests: ParserTestCase { func testAsyncSyntax1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/AsyncTests.swift b/Tests/SwiftParserTest/translated/AsyncTests.swift index 640da80996d..cf82d15c315 100644 --- a/Tests/SwiftParserTest/translated/AsyncTests.swift +++ b/Tests/SwiftParserTest/translated/AsyncTests.swift @@ -14,7 +14,7 @@ import XCTest -final class AsyncTests: XCTestCase { +final class AsyncTests: ParserTestCase { func testAsync1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift b/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift index 9e738ac3fbe..4bed36334f9 100644 --- a/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift +++ b/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift @@ -14,7 +14,7 @@ import XCTest -final class AvailabilityQueryTests: XCTestCase { +final class AvailabilityQueryTests: ParserTestCase { func testAvailabilityQuery1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift b/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift index 52ffaa36fb3..b88ad0639f8 100644 --- a/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift +++ b/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift @@ -14,7 +14,7 @@ import XCTest -final class AvailabilityQueryUnavailabilityTests: XCTestCase { +final class AvailabilityQueryUnavailabilityTests: ParserTestCase { func testAvailabilityQueryUnavailability1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/BorrowExprTests.swift b/Tests/SwiftParserTest/translated/BorrowExprTests.swift index 4b3b207844a..78d07b056c5 100644 --- a/Tests/SwiftParserTest/translated/BorrowExprTests.swift +++ b/Tests/SwiftParserTest/translated/BorrowExprTests.swift @@ -14,7 +14,7 @@ import XCTest -final class BorrowExprTests: XCTestCase { +final class BorrowExprTests: ParserTestCase { func testBorrowExpr1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift b/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift index a9320c71c10..a9478f3f93b 100644 --- a/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift +++ b/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift @@ -14,7 +14,7 @@ import XCTest -final class BraceRecoveryEofTests: XCTestCase { +final class BraceRecoveryEofTests: ParserTestCase { func testBraceRecoveryEof1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/BuiltinBridgeObjectTests.swift b/Tests/SwiftParserTest/translated/BuiltinBridgeObjectTests.swift index 542655719d0..bdc8e327401 100644 --- a/Tests/SwiftParserTest/translated/BuiltinBridgeObjectTests.swift +++ b/Tests/SwiftParserTest/translated/BuiltinBridgeObjectTests.swift @@ -14,7 +14,7 @@ import XCTest -final class BuiltinBridgeObjectTests: XCTestCase { +final class BuiltinBridgeObjectTests: ParserTestCase { func testBuiltinBridgeObject1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/BuiltinWordTests.swift b/Tests/SwiftParserTest/translated/BuiltinWordTests.swift index bd48116e107..cdb419de03c 100644 --- a/Tests/SwiftParserTest/translated/BuiltinWordTests.swift +++ b/Tests/SwiftParserTest/translated/BuiltinWordTests.swift @@ -14,7 +14,7 @@ import XCTest -final class BuiltinWordTests: XCTestCase { +final class BuiltinWordTests: ParserTestCase { func testBuiltinWord1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ConflictMarkersTests.swift b/Tests/SwiftParserTest/translated/ConflictMarkersTests.swift index 331aca7e9d2..e374e4c8936 100644 --- a/Tests/SwiftParserTest/translated/ConflictMarkersTests.swift +++ b/Tests/SwiftParserTest/translated/ConflictMarkersTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ConflictMarkersTests: XCTestCase { +final class ConflictMarkersTests: ParserTestCase { func testConflictMarkers1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift b/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift index 09e00f036ab..2887ad925c0 100644 --- a/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift +++ b/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ConsecutiveStatementsTests: XCTestCase { +final class ConsecutiveStatementsTests: ParserTestCase { func testSimple1() { assertParse( "let x = 21️⃣ let y = 3", diff --git a/Tests/SwiftParserTest/translated/CopyExprTests.swift b/Tests/SwiftParserTest/translated/CopyExprTests.swift index dbee930eebf..069773bfdb2 100644 --- a/Tests/SwiftParserTest/translated/CopyExprTests.swift +++ b/Tests/SwiftParserTest/translated/CopyExprTests.swift @@ -14,7 +14,7 @@ import XCTest -final class CopyExprTests: XCTestCase { +final class CopyExprTests: ParserTestCase { func testGlobal() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DebuggerTests.swift b/Tests/SwiftParserTest/translated/DebuggerTests.swift index 37d7bbe05a2..756e810a0ae 100644 --- a/Tests/SwiftParserTest/translated/DebuggerTests.swift +++ b/Tests/SwiftParserTest/translated/DebuggerTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DebuggerTests: XCTestCase { +final class DebuggerTests: ParserTestCase { func testDebugger1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DelayedExtensionTests.swift b/Tests/SwiftParserTest/translated/DelayedExtensionTests.swift index 7ea8eb4010f..5a34ef4eb25 100644 --- a/Tests/SwiftParserTest/translated/DelayedExtensionTests.swift +++ b/Tests/SwiftParserTest/translated/DelayedExtensionTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DelayedExtensionTests: XCTestCase { +final class DelayedExtensionTests: ParserTestCase { func testDelayedExtension1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift b/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift index d431a6ab729..3921e4805ed 100644 --- a/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift +++ b/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift @@ -16,7 +16,7 @@ import XCTest // TODO: The generic where clause next to generic parameters is only valid in language mode 4. We should disallow them in language mode 5. -final class DeprecatedWhereTests: XCTestCase { +final class DeprecatedWhereTests: ParserTestCase { func testDeprecatedWhere1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DiagnoseAvailabilityTests.swift b/Tests/SwiftParserTest/translated/DiagnoseAvailabilityTests.swift index 2d8f20d2828..6402a8d53ca 100644 --- a/Tests/SwiftParserTest/translated/DiagnoseAvailabilityTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnoseAvailabilityTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DiagnoseAvailabilityTests: XCTestCase { +final class DiagnoseAvailabilityTests: ParserTestCase { func testDiagnoseAvailability1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DiagnoseAvailabilityWindowsTests.swift b/Tests/SwiftParserTest/translated/DiagnoseAvailabilityWindowsTests.swift index b0d1afaf0ef..6b966bdbfa9 100644 --- a/Tests/SwiftParserTest/translated/DiagnoseAvailabilityWindowsTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnoseAvailabilityWindowsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DiagnoseAvailabilityWindowsTests: XCTestCase { +final class DiagnoseAvailabilityWindowsTests: ParserTestCase { func testDiagnoseAvailabilityWindows1() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift b/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift index 6e0171bc0c1..f2b6d31d99c 100644 --- a/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DiagnoseDynamicReplacementTests: XCTestCase { +final class DiagnoseDynamicReplacementTests: ParserTestCase { func testDiagnoseDynamicReplacement1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift b/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift index d0d82e71c53..ced81997cb9 100644 --- a/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift @@ -15,7 +15,7 @@ import XCTest // https://github.com/apple/swift/issues/44070 -final class DiagnoseInitializerAsTypedPatternTests: XCTestCase { +final class DiagnoseInitializerAsTypedPatternTests: ParserTestCase { func testDiagnoseInitializerAsTypedPattern3a() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift b/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift index 18bffaff61d..3a10023168c 100644 --- a/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DiagnosticMissingFuncKeywordTests: XCTestCase { +final class DiagnosticMissingFuncKeywordTests: ParserTestCase { func testDiagnosticMissingFuncKeyword2a() { // https://github.com/apple/swift/issues/52877 assertParse( diff --git a/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift b/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift index d0482bde3f6..279d19801fb 100644 --- a/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift +++ b/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift @@ -14,7 +14,7 @@ import XCTest -final class DollarIdentifierTests: XCTestCase { +final class DollarIdentifierTests: ParserTestCase { func testDollarIdentifier1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift b/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift index 57afebd2dbc..53e96c582e6 100644 --- a/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift +++ b/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift @@ -14,7 +14,7 @@ import XCTest -final class EffectfulPropertiesTests: XCTestCase { +final class EffectfulPropertiesTests: ParserTestCase { func testEffectfulProperties1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/EnumElementPatternSwift4Tests.swift b/Tests/SwiftParserTest/translated/EnumElementPatternSwift4Tests.swift index d5063eda94c..2ed5f705e10 100644 --- a/Tests/SwiftParserTest/translated/EnumElementPatternSwift4Tests.swift +++ b/Tests/SwiftParserTest/translated/EnumElementPatternSwift4Tests.swift @@ -14,7 +14,7 @@ import XCTest -final class EnumElementPatternSwift4Tests: XCTestCase { +final class EnumElementPatternSwift4Tests: ParserTestCase { func testEnumElementPatternSwift41() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/EnumTests.swift b/Tests/SwiftParserTest/translated/EnumTests.swift index 34afc9db9e7..aea5f29281f 100644 --- a/Tests/SwiftParserTest/translated/EnumTests.swift +++ b/Tests/SwiftParserTest/translated/EnumTests.swift @@ -14,7 +14,7 @@ import XCTest -final class EnumTests: XCTestCase { +final class EnumTests: ParserTestCase { func testEnum1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ErrorsTests.swift b/Tests/SwiftParserTest/translated/ErrorsTests.swift index 4a3f7993a5f..0a43fb9c238 100644 --- a/Tests/SwiftParserTest/translated/ErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/ErrorsTests.swift @@ -16,7 +16,7 @@ import SwiftSyntax import XCTest -final class ErrorsTests: XCTestCase { +final class ErrorsTests: ParserTestCase { func testErrors1() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/EscapedIdentifiersTests.swift b/Tests/SwiftParserTest/translated/EscapedIdentifiersTests.swift index 69eabfbf489..d64cdec77b7 100644 --- a/Tests/SwiftParserTest/translated/EscapedIdentifiersTests.swift +++ b/Tests/SwiftParserTest/translated/EscapedIdentifiersTests.swift @@ -14,7 +14,7 @@ import XCTest -final class EscapedIdentifiersTests: XCTestCase { +final class EscapedIdentifiersTests: ParserTestCase { func testEscapedIdentifiers1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift b/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift index 92dc7be034f..7da59369a23 100644 --- a/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift +++ b/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ForeachAsyncTests: XCTestCase { +final class ForeachAsyncTests: ParserTestCase { func testForeachAsync1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ForeachTests.swift b/Tests/SwiftParserTest/translated/ForeachTests.swift index aaf869cf8f7..aa716236fec 100644 --- a/Tests/SwiftParserTest/translated/ForeachTests.swift +++ b/Tests/SwiftParserTest/translated/ForeachTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ForeachTests: XCTestCase { +final class ForeachTests: ParserTestCase { func testForeach1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift index 3c18b179e87..00ee9285cf7 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ForwardSlashRegexSkippingAllowedTests: XCTestCase { +final class ForwardSlashRegexSkippingAllowedTests: ParserTestCase { func testForwardSlashRegexSkippingAllowed3() { // Ensures there is a parse error assertParse( diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift index 506b1464c71..3b1d4903788 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { +final class ForwardSlashRegexSkippingInvalidTests: ParserTestCase { func testForwardSlashRegexSkippingInvalid1() { // We don't consider this a regex literal when skipping as it has an initial // space. diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingTests.swift index a6f22540eb8..a2a0ddee2e4 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ForwardSlashRegexSkippingTests: XCTestCase { +final class ForwardSlashRegexSkippingTests: ParserTestCase { func testForwardSlashRegexSkipping3() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift index 227435fbe62..1b0a9e7cbd9 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift @@ -16,7 +16,7 @@ @_spi(RawSyntax) import SwiftParser import XCTest -final class ForwardSlashRegexTests: XCTestCase { +final class ForwardSlashRegexTests: ParserTestCase { func testForwardSlashRegex1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/GenericDisambiguationTests.swift b/Tests/SwiftParserTest/translated/GenericDisambiguationTests.swift index 5e6e156e438..d9b916ecc6e 100644 --- a/Tests/SwiftParserTest/translated/GenericDisambiguationTests.swift +++ b/Tests/SwiftParserTest/translated/GenericDisambiguationTests.swift @@ -16,7 +16,7 @@ import SwiftSyntax import XCTest -final class GenericDisambiguationTests: XCTestCase { +final class GenericDisambiguationTests: ParserTestCase { func testGenericDisambiguation1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/GuardTests.swift b/Tests/SwiftParserTest/translated/GuardTests.swift index 2164e4941c5..6a529927d9a 100644 --- a/Tests/SwiftParserTest/translated/GuardTests.swift +++ b/Tests/SwiftParserTest/translated/GuardTests.swift @@ -14,7 +14,7 @@ import XCTest -final class GuardTests: XCTestCase { +final class GuardTests: ParserTestCase { func testGuard1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/GuardTopLevelTests.swift b/Tests/SwiftParserTest/translated/GuardTopLevelTests.swift index f4134764a43..181b50a2526 100644 --- a/Tests/SwiftParserTest/translated/GuardTopLevelTests.swift +++ b/Tests/SwiftParserTest/translated/GuardTopLevelTests.swift @@ -14,7 +14,7 @@ import XCTest -final class GuardTopLevelTests: XCTestCase { +final class GuardTopLevelTests: ParserTestCase { func testGuardTopLevel1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/HashbangLibraryTests.swift b/Tests/SwiftParserTest/translated/HashbangLibraryTests.swift index 8b2e28767ed..4a851d36f0a 100644 --- a/Tests/SwiftParserTest/translated/HashbangLibraryTests.swift +++ b/Tests/SwiftParserTest/translated/HashbangLibraryTests.swift @@ -16,7 +16,7 @@ import SwiftSyntax import XCTest -final class HashbangLibraryTests: XCTestCase { +final class HashbangLibraryTests: ParserTestCase { func testHashbangLibrary1() { // Check that we diagnose and skip the hashbang at the beginning of the file // when compiling in library mode. diff --git a/Tests/SwiftParserTest/translated/HashbangMainTests.swift b/Tests/SwiftParserTest/translated/HashbangMainTests.swift index 45d8c64ed1b..1f86858adc6 100644 --- a/Tests/SwiftParserTest/translated/HashbangMainTests.swift +++ b/Tests/SwiftParserTest/translated/HashbangMainTests.swift @@ -14,7 +14,7 @@ import XCTest -final class HashbangMainTests: XCTestCase { +final class HashbangMainTests: ParserTestCase { func testHashbangMain1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/IdentifiersTests.swift b/Tests/SwiftParserTest/translated/IdentifiersTests.swift index e02a268d451..edbee78a25e 100644 --- a/Tests/SwiftParserTest/translated/IdentifiersTests.swift +++ b/Tests/SwiftParserTest/translated/IdentifiersTests.swift @@ -14,7 +14,7 @@ import XCTest -final class IdentifiersTests: XCTestCase { +final class IdentifiersTests: ParserTestCase { func testIdentifiers1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/IfconfigExprTests.swift b/Tests/SwiftParserTest/translated/IfconfigExprTests.swift index a40344d9c62..312af3ae22d 100644 --- a/Tests/SwiftParserTest/translated/IfconfigExprTests.swift +++ b/Tests/SwiftParserTest/translated/IfconfigExprTests.swift @@ -15,7 +15,7 @@ import XCTest import SwiftSyntax -final class IfconfigExprTests: XCTestCase { +final class IfconfigExprTests: ParserTestCase { func testIfconfigExpr1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift b/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift index eef4aeb0058..e291226f43e 100644 --- a/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift +++ b/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ImplicitGetterIncompleteTests: XCTestCase { +final class ImplicitGetterIncompleteTests: ParserTestCase { func testImplicitGetterIncomplete1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/InitDeinitTests.swift b/Tests/SwiftParserTest/translated/InitDeinitTests.swift index dd99add1eed..f87540f3129 100644 --- a/Tests/SwiftParserTest/translated/InitDeinitTests.swift +++ b/Tests/SwiftParserTest/translated/InitDeinitTests.swift @@ -16,7 +16,7 @@ import SwiftSyntax import XCTest -final class InitDeinitTests: XCTestCase { +final class InitDeinitTests: ParserTestCase { func testInitDeinit1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift b/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift index 80cc943f4ec..e97b5ef041f 100644 --- a/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift +++ b/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift @@ -14,7 +14,7 @@ import XCTest -final class InvalidIfExprTests: XCTestCase { +final class InvalidIfExprTests: ParserTestCase { func testInvalidIfExpr1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/InvalidStringInterpolationProtocolTests.swift b/Tests/SwiftParserTest/translated/InvalidStringInterpolationProtocolTests.swift index 0e3a1d50d2a..f45df1b6f3b 100644 --- a/Tests/SwiftParserTest/translated/InvalidStringInterpolationProtocolTests.swift +++ b/Tests/SwiftParserTest/translated/InvalidStringInterpolationProtocolTests.swift @@ -14,7 +14,7 @@ import XCTest -final class InvalidStringInterpolationProtocolTests: XCTestCase { +final class InvalidStringInterpolationProtocolTests: ParserTestCase { func testInvalidStringInterpolationProtocol1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/InvalidTests.swift b/Tests/SwiftParserTest/translated/InvalidTests.swift index 50a423fb926..da9f562ed7f 100644 --- a/Tests/SwiftParserTest/translated/InvalidTests.swift +++ b/Tests/SwiftParserTest/translated/InvalidTests.swift @@ -14,7 +14,7 @@ import XCTest -final class InvalidTests: XCTestCase { +final class InvalidTests: ParserTestCase { func testInvalid1a() { // rdar://15946844 assertParse( diff --git a/Tests/SwiftParserTest/translated/MatchingPatternsTests.swift b/Tests/SwiftParserTest/translated/MatchingPatternsTests.swift index 041eb9ddc2c..b3d162dcc97 100644 --- a/Tests/SwiftParserTest/translated/MatchingPatternsTests.swift +++ b/Tests/SwiftParserTest/translated/MatchingPatternsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class MatchingPatternsTests: XCTestCase { +final class MatchingPatternsTests: ParserTestCase { func testMatchingPatterns1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/MetatypeObjectConversionTests.swift b/Tests/SwiftParserTest/translated/MetatypeObjectConversionTests.swift index f186abcf5d1..ceb5641031f 100644 --- a/Tests/SwiftParserTest/translated/MetatypeObjectConversionTests.swift +++ b/Tests/SwiftParserTest/translated/MetatypeObjectConversionTests.swift @@ -14,7 +14,7 @@ import XCTest -final class MetatypeObjectConversionTests: XCTestCase { +final class MetatypeObjectConversionTests: ParserTestCase { func testMetatypeObjectConversion1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/MoveExprTests.swift b/Tests/SwiftParserTest/translated/MoveExprTests.swift index 5a3a8a60a54..98d5ad82b76 100644 --- a/Tests/SwiftParserTest/translated/MoveExprTests.swift +++ b/Tests/SwiftParserTest/translated/MoveExprTests.swift @@ -14,7 +14,7 @@ import XCTest -final class MoveExprTests: XCTestCase { +final class MoveExprTests: ParserTestCase { func testMoveExpr1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift b/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift index 5e518ce5c18..6ff03128790 100644 --- a/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift @@ -16,32 +16,34 @@ import XCTest import SwiftSyntax -func assertParseWithAllNewlineEndings( - _ markedSource: String, - substructure expectedSubstructure: (some SyntaxProtocol)? = Optional.none, - substructureAfterMarker: String = "START", - diagnostics expectedDiagnostics: [DiagnosticSpec] = [], - applyFixIts: [String]? = nil, - fixedSource expectedFixedSource: String? = nil, - file: StaticString = #file, - line: UInt = #line -) { - for newline in ["\n", "\r", "\r\n"] { - assertParse( - markedSource.replacingOccurrences(of: "\n", with: newline), - substructure: expectedSubstructure, - substructureAfterMarker: substructureAfterMarker, - diagnostics: expectedDiagnostics, - applyFixIts: applyFixIts, - fixedSource: expectedFixedSource, - options: [.normalizeNewlinesInFixedSource], - file: file, - line: line - ) +extension ParserTestCase { + fileprivate func assertParseWithAllNewlineEndings( + _ markedSource: String, + substructure expectedSubstructure: (some SyntaxProtocol)? = Optional.none, + substructureAfterMarker: String = "START", + diagnostics expectedDiagnostics: [DiagnosticSpec] = [], + applyFixIts: [String]? = nil, + fixedSource expectedFixedSource: String? = nil, + file: StaticString = #file, + line: UInt = #line + ) { + for newline in ["\n", "\r", "\r\n"] { + assertParse( + markedSource.replacingOccurrences(of: "\n", with: newline), + substructure: expectedSubstructure, + substructureAfterMarker: substructureAfterMarker, + diagnostics: expectedDiagnostics, + applyFixIts: applyFixIts, + fixedSource: expectedFixedSource, + options: [.normalizeNewlinesInFixedSource], + file: file, + line: line + ) + } } } -final class MultilineErrorsTests: XCTestCase { +final class MultilineErrorsTests: ParserTestCase { func testMultilineErrors1() { assertParseWithAllNewlineEndings( """ diff --git a/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift b/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift index d819fe38459..a5d11ea8d5b 100644 --- a/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift +++ b/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift @@ -14,7 +14,7 @@ import XCTest -final class MultilinePoundDiagnosticArgRdar41154797Tests: XCTestCase { +final class MultilinePoundDiagnosticArgRdar41154797Tests: ParserTestCase { func testMultilinePoundDiagnosticArgRdar411547971() { assertParse( ##""" diff --git a/Tests/SwiftParserTest/translated/MultilineStringTests.swift b/Tests/SwiftParserTest/translated/MultilineStringTests.swift index 4900c07f2ec..5fa6cd9232d 100644 --- a/Tests/SwiftParserTest/translated/MultilineStringTests.swift +++ b/Tests/SwiftParserTest/translated/MultilineStringTests.swift @@ -16,7 +16,7 @@ import SwiftSyntax import XCTest -final class MultilineStringTests: XCTestCase { +final class MultilineStringTests: ParserTestCase { func testMultilineString1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/NoimplicitcopyAttrTests.swift b/Tests/SwiftParserTest/translated/NoimplicitcopyAttrTests.swift index c531288738d..1b11c025029 100644 --- a/Tests/SwiftParserTest/translated/NoimplicitcopyAttrTests.swift +++ b/Tests/SwiftParserTest/translated/NoimplicitcopyAttrTests.swift @@ -14,7 +14,7 @@ import XCTest -final class NoimplicitcopyAttrTests: XCTestCase { +final class NoimplicitcopyAttrTests: ParserTestCase { func testNoimplicitcopyAttr1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/NumberIdentifierErrorsTests.swift b/Tests/SwiftParserTest/translated/NumberIdentifierErrorsTests.swift index e8309d712d4..8239b768474 100644 --- a/Tests/SwiftParserTest/translated/NumberIdentifierErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/NumberIdentifierErrorsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class NumberIdentifierErrorsTests: XCTestCase { +final class NumberIdentifierErrorsTests: ParserTestCase { func testNumberIdentifierErrors1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ObjcEnumTests.swift b/Tests/SwiftParserTest/translated/ObjcEnumTests.swift index a2e8b43b980..e618becc6c0 100644 --- a/Tests/SwiftParserTest/translated/ObjcEnumTests.swift +++ b/Tests/SwiftParserTest/translated/ObjcEnumTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ObjcEnumTests: XCTestCase { +final class ObjcEnumTests: ParserTestCase { func testObjcEnum1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift b/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift index 08b83885000..9e7a084aaa0 100644 --- a/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift +++ b/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ObjectLiteralsTests: XCTestCase { +final class ObjectLiteralsTests: ParserTestCase { func testObjectLiterals1a() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OperatorDeclDesignatedTypesTests.swift b/Tests/SwiftParserTest/translated/OperatorDeclDesignatedTypesTests.swift index a43022caaa0..45121fc9c30 100644 --- a/Tests/SwiftParserTest/translated/OperatorDeclDesignatedTypesTests.swift +++ b/Tests/SwiftParserTest/translated/OperatorDeclDesignatedTypesTests.swift @@ -16,7 +16,7 @@ import XCTest // TODO: Designated operator types are only valid in langauge mode 4. We should disallow them in language mode 5. -final class OperatorDeclDesignatedTypesTests: XCTestCase { +final class OperatorDeclDesignatedTypesTests: ParserTestCase { func testOperatorDeclDesignatedTypes1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OperatorDeclTests.swift b/Tests/SwiftParserTest/translated/OperatorDeclTests.swift index 8ef7683afd2..854e8564b76 100644 --- a/Tests/SwiftParserTest/translated/OperatorDeclTests.swift +++ b/Tests/SwiftParserTest/translated/OperatorDeclTests.swift @@ -14,7 +14,7 @@ import XCTest -final class OperatorDeclTests: XCTestCase { +final class OperatorDeclTests: ParserTestCase { func testOperatorDecl1a() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OperatorsTests.swift b/Tests/SwiftParserTest/translated/OperatorsTests.swift index 42cbd8cab3a..2f618be101f 100644 --- a/Tests/SwiftParserTest/translated/OperatorsTests.swift +++ b/Tests/SwiftParserTest/translated/OperatorsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class OperatorsTests: XCTestCase { +final class OperatorsTests: ParserTestCase { func testOperators1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OptionalChainLvaluesTests.swift b/Tests/SwiftParserTest/translated/OptionalChainLvaluesTests.swift index a24815bd5e6..1d20964d663 100644 --- a/Tests/SwiftParserTest/translated/OptionalChainLvaluesTests.swift +++ b/Tests/SwiftParserTest/translated/OptionalChainLvaluesTests.swift @@ -14,7 +14,7 @@ import XCTest -final class OptionalChainLvaluesTests: XCTestCase { +final class OptionalChainLvaluesTests: ParserTestCase { func testOptionalChainLvalues1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OptionalLvaluesTests.swift b/Tests/SwiftParserTest/translated/OptionalLvaluesTests.swift index 1766b08f9a8..942a83acbd1 100644 --- a/Tests/SwiftParserTest/translated/OptionalLvaluesTests.swift +++ b/Tests/SwiftParserTest/translated/OptionalLvaluesTests.swift @@ -14,7 +14,7 @@ import XCTest -final class OptionalLvaluesTests: XCTestCase { +final class OptionalLvaluesTests: ParserTestCase { func testOptionalLvalues1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OptionalTests.swift b/Tests/SwiftParserTest/translated/OptionalTests.swift index 3fe1307b4b1..f29ee9511b3 100644 --- a/Tests/SwiftParserTest/translated/OptionalTests.swift +++ b/Tests/SwiftParserTest/translated/OptionalTests.swift @@ -15,7 +15,7 @@ import SwiftSyntax import XCTest -final class OptionalTests: XCTestCase { +final class OptionalTests: ParserTestCase { func testOptional1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift b/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift index 5af8c3e2e3e..246ba27b7dd 100644 --- a/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift +++ b/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift @@ -14,7 +14,7 @@ import XCTest -final class OriginalDefinedInAttrTests: XCTestCase { +final class OriginalDefinedInAttrTests: ParserTestCase { func testOriginalDefinedInAttr1() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/PatternWithoutVariablesScriptTests.swift b/Tests/SwiftParserTest/translated/PatternWithoutVariablesScriptTests.swift index 1b5710d0bed..63bac4baeaf 100644 --- a/Tests/SwiftParserTest/translated/PatternWithoutVariablesScriptTests.swift +++ b/Tests/SwiftParserTest/translated/PatternWithoutVariablesScriptTests.swift @@ -14,7 +14,7 @@ import XCTest -final class PatternWithoutVariablesScriptTests: XCTestCase { +final class PatternWithoutVariablesScriptTests: ParserTestCase { func testPatternWithoutVariablesScript1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/PatternWithoutVariablesTests.swift b/Tests/SwiftParserTest/translated/PatternWithoutVariablesTests.swift index 88de0d47c24..09def6fb457 100644 --- a/Tests/SwiftParserTest/translated/PatternWithoutVariablesTests.swift +++ b/Tests/SwiftParserTest/translated/PatternWithoutVariablesTests.swift @@ -14,7 +14,7 @@ import XCTest -final class PatternWithoutVariablesTests: XCTestCase { +final class PatternWithoutVariablesTests: ParserTestCase { func testPatternWithoutVariables1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/PlaygroundLvaluesTests.swift b/Tests/SwiftParserTest/translated/PlaygroundLvaluesTests.swift index 2b5ac0e883d..b0549a74fd7 100644 --- a/Tests/SwiftParserTest/translated/PlaygroundLvaluesTests.swift +++ b/Tests/SwiftParserTest/translated/PlaygroundLvaluesTests.swift @@ -14,7 +14,7 @@ import XCTest -final class PlaygroundLvaluesTests: XCTestCase { +final class PlaygroundLvaluesTests: ParserTestCase { func testPlaygroundLvalues1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/PoundAssertTests.swift b/Tests/SwiftParserTest/translated/PoundAssertTests.swift index 26169743645..538cd7d45c6 100644 --- a/Tests/SwiftParserTest/translated/PoundAssertTests.swift +++ b/Tests/SwiftParserTest/translated/PoundAssertTests.swift @@ -14,7 +14,7 @@ import XCTest -final class PoundAssertTests: XCTestCase { +final class PoundAssertTests: ParserTestCase { func testPoundAssert1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/PrefixSlashTests.swift b/Tests/SwiftParserTest/translated/PrefixSlashTests.swift index c4b5195d67f..d5097fec1a9 100644 --- a/Tests/SwiftParserTest/translated/PrefixSlashTests.swift +++ b/Tests/SwiftParserTest/translated/PrefixSlashTests.swift @@ -14,7 +14,7 @@ import XCTest -final class PrefixSlashTests: XCTestCase { +final class PrefixSlashTests: ParserTestCase { func testPrefixSlash2() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift b/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift index 78f89575322..e3b38da7f72 100644 --- a/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift @@ -14,7 +14,7 @@ import XCTest -final class RawStringErrorsTests: XCTestCase { +final class RawStringErrorsTests: ParserTestCase { func testRawStringErrors1() { assertParse( ###""" diff --git a/Tests/SwiftParserTest/translated/RawStringTests.swift b/Tests/SwiftParserTest/translated/RawStringTests.swift index 5dee0c26c06..b16dfe33c7f 100644 --- a/Tests/SwiftParserTest/translated/RawStringTests.swift +++ b/Tests/SwiftParserTest/translated/RawStringTests.swift @@ -14,7 +14,7 @@ import XCTest -final class RawStringTests: XCTestCase { +final class RawStringTests: ParserTestCase { func testRawString1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/RecoveryLibraryTests.swift b/Tests/SwiftParserTest/translated/RecoveryLibraryTests.swift index 3b2bdc2345b..a6f511902ab 100644 --- a/Tests/SwiftParserTest/translated/RecoveryLibraryTests.swift +++ b/Tests/SwiftParserTest/translated/RecoveryLibraryTests.swift @@ -14,7 +14,7 @@ import XCTest -final class RecoveryLibraryTests: XCTestCase { +final class RecoveryLibraryTests: ParserTestCase { func testRecoveryLibrary() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/RecoveryTests.swift b/Tests/SwiftParserTest/translated/RecoveryTests.swift index 98980b0ec58..67e90b12bb8 100644 --- a/Tests/SwiftParserTest/translated/RecoveryTests.swift +++ b/Tests/SwiftParserTest/translated/RecoveryTests.swift @@ -2,7 +2,7 @@ import XCTest -final class RecoveryTests: XCTestCase { +final class RecoveryTests: ParserTestCase { func testRecovery4() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift b/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift index 63f744d0938..5c2e7dbbb13 100644 --- a/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift +++ b/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift @@ -14,7 +14,7 @@ import XCTest -final class RegexParseEndOfBufferTests: XCTestCase { +final class RegexParseEndOfBufferTests: ParserTestCase { func testRegexParseEndOfBuffer1() { assertParse( "var unterminated = #/(xy1️⃣", diff --git a/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift b/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift index 63478273b06..fbeda323b8d 100644 --- a/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift +++ b/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift @@ -14,7 +14,7 @@ import XCTest -final class RegexParseErrorTests: XCTestCase { +final class RegexParseErrorTests: ParserTestCase { func testRegexParseError1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/RegexTests.swift b/Tests/SwiftParserTest/translated/RegexTests.swift index 0c8f2715a82..7911e88c996 100644 --- a/Tests/SwiftParserTest/translated/RegexTests.swift +++ b/Tests/SwiftParserTest/translated/RegexTests.swift @@ -14,7 +14,7 @@ import XCTest -final class RegexTests: XCTestCase { +final class RegexTests: ParserTestCase { func testRegex1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ResultBuilderTests.swift b/Tests/SwiftParserTest/translated/ResultBuilderTests.swift index bc2d25d8bf3..dfae05eb47a 100644 --- a/Tests/SwiftParserTest/translated/ResultBuilderTests.swift +++ b/Tests/SwiftParserTest/translated/ResultBuilderTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ResultBuilderTests: XCTestCase { +final class ResultBuilderTests: ParserTestCase { func testResultBuilder1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/SelfRebindingTests.swift b/Tests/SwiftParserTest/translated/SelfRebindingTests.swift index e1db6a807ad..3d373a1ee32 100644 --- a/Tests/SwiftParserTest/translated/SelfRebindingTests.swift +++ b/Tests/SwiftParserTest/translated/SelfRebindingTests.swift @@ -14,7 +14,7 @@ import XCTest -final class SelfRebindingTests: XCTestCase { +final class SelfRebindingTests: ParserTestCase { func testSelfRebinding1() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/SemicolonTests.swift b/Tests/SwiftParserTest/translated/SemicolonTests.swift index 563f2ca5c96..13f268444f7 100644 --- a/Tests/SwiftParserTest/translated/SemicolonTests.swift +++ b/Tests/SwiftParserTest/translated/SemicolonTests.swift @@ -14,7 +14,7 @@ import XCTest -final class SemicolonTests: XCTestCase { +final class SemicolonTests: ParserTestCase { func testSemicolon1() { assertParse( #""" diff --git a/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift b/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift index 5d98c476d28..8e5bf467df4 100644 --- a/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift +++ b/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift @@ -14,7 +14,7 @@ import XCTest -final class StringLiteralEofTests: XCTestCase { +final class StringLiteralEofTests: ParserTestCase { func testStringLiteralEof1() { assertParse( ##""" diff --git a/Tests/SwiftParserTest/translated/SubscriptingTests.swift b/Tests/SwiftParserTest/translated/SubscriptingTests.swift index a0f09694feb..50547080a3d 100644 --- a/Tests/SwiftParserTest/translated/SubscriptingTests.swift +++ b/Tests/SwiftParserTest/translated/SubscriptingTests.swift @@ -14,7 +14,7 @@ import XCTest -final class SubscriptingTests: XCTestCase { +final class SubscriptingTests: ParserTestCase { func testSubscripting1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/SuperTests.swift b/Tests/SwiftParserTest/translated/SuperTests.swift index 2d4be219740..28931072819 100644 --- a/Tests/SwiftParserTest/translated/SuperTests.swift +++ b/Tests/SwiftParserTest/translated/SuperTests.swift @@ -15,7 +15,7 @@ import SwiftSyntax import XCTest -final class SuperTests: XCTestCase { +final class SuperTests: ParserTestCase { func testSuper1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift b/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift index f2f50f35bab..8fc0165f062 100644 --- a/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift +++ b/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift @@ -14,7 +14,7 @@ import XCTest -final class SwitchIncompleteTests: XCTestCase { +final class SwitchIncompleteTests: ParserTestCase { func testSwitchIncomplete1() { // Incomplete switch was parsing to an AST that // triggered an assertion failure. diff --git a/Tests/SwiftParserTest/translated/SwitchTests.swift b/Tests/SwiftParserTest/translated/SwitchTests.swift index 7a81e9267eb..2137e0f6671 100644 --- a/Tests/SwiftParserTest/translated/SwitchTests.swift +++ b/Tests/SwiftParserTest/translated/SwitchTests.swift @@ -14,7 +14,7 @@ import XCTest -final class SwitchTests: XCTestCase { +final class SwitchTests: ParserTestCase { func testSwitch1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift b/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift index e6a32bf87e0..d7fba689b8d 100644 --- a/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift +++ b/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift @@ -14,7 +14,7 @@ import XCTest -final class ToplevelLibraryTests: XCTestCase { +final class ToplevelLibraryTests: ParserTestCase { func testToplevelLibrary1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift b/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift index b40314d2e9a..c6ff24d0183 100644 --- a/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift +++ b/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift @@ -15,7 +15,7 @@ import SwiftSyntax import XCTest -final class TrailingClosuresTests: XCTestCase { +final class TrailingClosuresTests: ParserTestCase { func testTrailingClosures1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/TrailingSemiTests.swift b/Tests/SwiftParserTest/translated/TrailingSemiTests.swift index 2c920a92456..8d55b94e36b 100644 --- a/Tests/SwiftParserTest/translated/TrailingSemiTests.swift +++ b/Tests/SwiftParserTest/translated/TrailingSemiTests.swift @@ -14,7 +14,7 @@ import XCTest -final class TrailingSemiTests: XCTestCase { +final class TrailingSemiTests: ParserTestCase { func testTrailingSemi1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/TryTests.swift b/Tests/SwiftParserTest/translated/TryTests.swift index 1c486113296..0f97c10c700 100644 --- a/Tests/SwiftParserTest/translated/TryTests.swift +++ b/Tests/SwiftParserTest/translated/TryTests.swift @@ -14,7 +14,7 @@ import XCTest -final class TryTests: XCTestCase { +final class TryTests: ParserTestCase { func testTry1() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/TypeExprTests.swift b/Tests/SwiftParserTest/translated/TypeExprTests.swift index 072175f04f3..ec86cb09539 100644 --- a/Tests/SwiftParserTest/translated/TypeExprTests.swift +++ b/Tests/SwiftParserTest/translated/TypeExprTests.swift @@ -17,7 +17,7 @@ import SwiftSyntax // Types in expression contexts must be followed by a member access or // constructor call. -final class TypeExprTests: XCTestCase { +final class TypeExprTests: ParserTestCase { func testTypeExpr3() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/TypealiasTests.swift b/Tests/SwiftParserTest/translated/TypealiasTests.swift index b10bffbf53b..05f407ef765 100644 --- a/Tests/SwiftParserTest/translated/TypealiasTests.swift +++ b/Tests/SwiftParserTest/translated/TypealiasTests.swift @@ -14,7 +14,7 @@ import XCTest -final class TypealiasTests: XCTestCase { +final class TypealiasTests: ParserTestCase { func testTypealias2a() { assertParse( """ diff --git a/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift b/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift index a76ea0fb07f..4be5607e46d 100644 --- a/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift +++ b/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift @@ -14,7 +14,7 @@ import XCTest -final class UnclosedStringInterpolationTests: XCTestCase { +final class UnclosedStringInterpolationTests: ParserTestCase { func testUnclosedStringInterpolation1() { assertParse( #"""