From d54a8294237ca2dd79e3a4b614a0d7053ab0edde Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 2 Aug 2023 16:30:49 -0700 Subject: [PATCH 1/2] A couple more renames of SwiftSyntax nodes --- .../SyntaxSupport/AttributeNodes.swift | 3 +- .../Sources/SyntaxSupport/ExprNodes.swift | 3 +- .../SwiftIDEUtils/SyntaxClassification.swift | 2 +- Sources/SwiftParser/Attributes.swift | 4 +- .../IncrementalParseTransition.swift | 2 +- .../ParseDiagnosticsGenerator.swift | 8 ++- .../generated/ChildNameForKeyPath.swift | 12 ++-- .../RenamedChildrenCompatibility.swift | 59 ++++++++++++++++++- .../generated/raw/RawSyntaxNodes.swift | 26 ++++---- .../generated/raw/RawSyntaxValidation.swift | 2 +- .../syntaxNodes/SyntaxExprNodes.swift | 12 ++-- .../generated/syntaxNodes/SyntaxNodes.swift | 34 +++++------ 12 files changed, 112 insertions(+), 55 deletions(-) diff --git a/CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift b/CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift index d098549b0de..3a500d4535d 100644 --- a/CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift @@ -190,7 +190,8 @@ public let ATTRIBUTE_NODES: [Node] = [ traits: ["WithTrailingComma"], children: [ Child( - name: "AvailabilityVersionRestriction", + name: "PlatformVersion", + deprecatedName: "AvailabilityVersionRestriction", kind: .node(kind: .platformVersion) ), Child( diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 7d9ed1d11e6..d61108a5a01 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -1384,8 +1384,7 @@ public let EXPR_NODES: [Node] = [ Child( name: "Operator", deprecatedName: "OperatorToken", - kind: .token(choices: [.token(tokenKind: "PrefixOperatorToken")]), - isOptional: true + kind: .token(choices: [.token(tokenKind: "PrefixOperatorToken")]) ), Child( name: "Expression", diff --git a/Sources/SwiftIDEUtils/SyntaxClassification.swift b/Sources/SwiftIDEUtils/SyntaxClassification.swift index a33c4a05780..a04dafe1e91 100644 --- a/Sources/SwiftIDEUtils/SyntaxClassification.swift +++ b/Sources/SwiftIDEUtils/SyntaxClassification.swift @@ -65,7 +65,7 @@ extension SyntaxClassification { switch keyPath { case \AttributeSyntax.attributeName: return (.attribute, true) - case \PlatformVersionItemSyntax.availabilityVersionRestriction: + case \PlatformVersionItemSyntax.platformVersion: return (.keyword, false) case \AvailabilityVersionRestrictionSyntax.platform: return (.keyword, false) diff --git a/Sources/SwiftParser/Attributes.swift b/Sources/SwiftParser/Attributes.swift index 75aaa26915c..e387c938e9a 100644 --- a/Sources/SwiftParser/Attributes.swift +++ b/Sources/SwiftParser/Attributes.swift @@ -914,7 +914,7 @@ extension Parser { keepGoing = self.consume(if: .comma) elements.append( RawPlatformVersionItemSyntax( - availabilityVersionRestriction: versionRestriction, + platformVersion: versionRestriction, trailingComma: keepGoing, arena: self.arena ) @@ -974,7 +974,7 @@ extension Parser { keepGoing = self.consume(if: .comma) platforms.append( RawPlatformVersionItemSyntax( - availabilityVersionRestriction: restriction, + platformVersion: restriction, trailingComma: keepGoing, arena: self.arena ) diff --git a/Sources/SwiftParser/IncrementalParseTransition.swift b/Sources/SwiftParser/IncrementalParseTransition.swift index 7aaa46f39b6..488626d19c4 100644 --- a/Sources/SwiftParser/IncrementalParseTransition.swift +++ b/Sources/SwiftParser/IncrementalParseTransition.swift @@ -35,7 +35,7 @@ extension Parser { } } -/// Accepts a re-used ``Syntax`` node that `IncrementalParseTransition` +/// Accepts a re-used `Syntax` node that `IncrementalParseTransition` /// determined they should be re-used for a parse invocation. /// /// The client can use this information to potentially avoid unnecessary work diff --git a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift index ef325a9c330..c2f79e49f0f 100644 --- a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift @@ -1043,8 +1043,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor { addDiagnostic(unexpected, UnknownDirectiveError(unexpected: unexpected), handledNodes: [unexpected.id, node.baseName.id]) } else if let availability = unexpected.first?.as(AvailabilityConditionSyntax.self) { if let prefixOperatorExpr = node.parent?.as(PrefixOperatorExprSyntax.self), - let operatorToken = prefixOperatorExpr.operator, - operatorToken.text == "!", + prefixOperatorExpr.operator.text == "!", let conditionElement = prefixOperatorExpr.parent?.as(ConditionElementSyntax.self) { // Diagnose !#available(...) and !#unavailable(...) @@ -1059,7 +1058,10 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor { NegatedAvailabilityCondition(availabilityCondition: availability, negatedAvailabilityKeyword: negatedAvailabilityKeyword), fixIts: [ FixIt( - message: ReplaceTokensFixIt(replaceTokens: [operatorToken, availability.availabilityKeyword], replacements: [negatedAvailabilityKeyword]), + message: ReplaceTokensFixIt( + replaceTokens: [prefixOperatorExpr.operator, availability.availabilityKeyword], + replacements: [negatedAvailabilityKeyword] + ), changes: [ .replace(oldNode: Syntax(conditionElement), newNode: Syntax(negatedConditionElement)) ] diff --git a/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift b/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift index 7622f215bab..8e0c72c6c71 100644 --- a/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift +++ b/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift @@ -2437,12 +2437,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? { return "pattern" case \PatternExprSyntax.unexpectedAfterPattern: return "unexpectedAfterPattern" - case \PlatformVersionItemSyntax.unexpectedBeforeAvailabilityVersionRestriction: - return "unexpectedBeforeAvailabilityVersionRestriction" - case \PlatformVersionItemSyntax.availabilityVersionRestriction: - return "availabilityVersionRestriction" - case \PlatformVersionItemSyntax.unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: - return "unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma" + case \PlatformVersionItemSyntax.unexpectedBeforePlatformVersion: + return "unexpectedBeforePlatformVersion" + case \PlatformVersionItemSyntax.platformVersion: + return "platformVersion" + case \PlatformVersionItemSyntax.unexpectedBetweenPlatformVersionAndTrailingComma: + return "unexpectedBetweenPlatformVersionAndTrailingComma" case \PlatformVersionItemSyntax.trailingComma: return "trailingComma" case \PlatformVersionItemSyntax.unexpectedAfterTrailingComma: diff --git a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift index a9ef147ae30..d231e25fd0d 100644 --- a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift +++ b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift @@ -5767,6 +5767,61 @@ extension PatternBindingSyntax { } } +extension PlatformVersionItemSyntax { + @available(*, deprecated, renamed: "unexpectedBeforePlatformVersion") + public var unexpectedBeforeAvailabilityVersionRestriction: UnexpectedNodesSyntax? { + get { + return unexpectedBeforePlatformVersion + } + set { + unexpectedBeforePlatformVersion = newValue + } + } + + @available(*, deprecated, renamed: "platformVersion") + public var availabilityVersionRestriction: PlatformVersionSyntax { + get { + return platformVersion + } + set { + platformVersion = newValue + } + } + + @available(*, deprecated, renamed: "unexpectedBetweenPlatformVersionAndTrailingComma") + public var unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: UnexpectedNodesSyntax? { + get { + return unexpectedBetweenPlatformVersionAndTrailingComma + } + set { + unexpectedBetweenPlatformVersionAndTrailingComma = newValue + } + } + + @available(*, deprecated, renamed: "PlatformVersionItemSyntax(leadingTrivia:_:platformVersion:_:trailingComma:_:trailingTrivia:)") + @_disfavoredOverload + public init( + leadingTrivia: Trivia? = nil, + _ unexpectedBeforeAvailabilityVersionRestriction: UnexpectedNodesSyntax? = nil, + availabilityVersionRestriction: PlatformVersionSyntax, + _ unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: UnexpectedNodesSyntax? = nil, + trailingComma: TokenSyntax? = nil, + _ unexpectedAfterTrailingComma: UnexpectedNodesSyntax? = nil, + trailingTrivia: Trivia? = nil + + ) { + self.init( + leadingTrivia: leadingTrivia, + unexpectedBeforeAvailabilityVersionRestriction, + platformVersion: availabilityVersionRestriction, + unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma, + trailingComma: trailingComma, + unexpectedAfterTrailingComma, + trailingTrivia: trailingTrivia + ) + } +} + extension PostfixOperatorExprSyntax { @available(*, deprecated, renamed: "unexpectedBetweenExpressionAndOperator") public var unexpectedBetweenExpressionAndOperatorToken: UnexpectedNodesSyntax? { @@ -6354,7 +6409,7 @@ extension PrefixOperatorExprSyntax { } @available(*, deprecated, renamed: "operator") - public var operatorToken: TokenSyntax? { + public var operatorToken: TokenSyntax { get { return `operator` } @@ -6398,7 +6453,7 @@ extension PrefixOperatorExprSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeOperatorToken: UnexpectedNodesSyntax? = nil, - operatorToken: TokenSyntax? = nil, + operatorToken: TokenSyntax, _ unexpectedBetweenOperatorTokenAndPostfixExpression: UnexpectedNodesSyntax? = nil, postfixExpression: some ExprSyntaxProtocol, _ unexpectedAfterPostfixExpression: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift index 0d625d13a95..85fa79f4b60 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift @@ -16273,9 +16273,9 @@ public struct RawPlatformVersionItemSyntax: RawSyntaxNodeProtocol { } public init( - _ unexpectedBeforeAvailabilityVersionRestriction: RawUnexpectedNodesSyntax? = nil, - availabilityVersionRestriction: RawPlatformVersionSyntax, - _ unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: RawUnexpectedNodesSyntax? = nil, + _ unexpectedBeforePlatformVersion: RawUnexpectedNodesSyntax? = nil, + platformVersion: RawPlatformVersionSyntax, + _ unexpectedBetweenPlatformVersionAndTrailingComma: RawUnexpectedNodesSyntax? = nil, trailingComma: RawTokenSyntax?, _ unexpectedAfterTrailingComma: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena @@ -16283,24 +16283,24 @@ public struct RawPlatformVersionItemSyntax: RawSyntaxNodeProtocol { let raw = RawSyntax.makeLayout( kind: .platformVersionItem, uninitializedCount: 5, arena: arena) { layout in layout.initialize(repeating: nil) - layout[0] = unexpectedBeforeAvailabilityVersionRestriction?.raw - layout[1] = availabilityVersionRestriction.raw - layout[2] = unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma?.raw + layout[0] = unexpectedBeforePlatformVersion?.raw + layout[1] = platformVersion.raw + layout[2] = unexpectedBetweenPlatformVersionAndTrailingComma?.raw layout[3] = trailingComma?.raw layout[4] = unexpectedAfterTrailingComma?.raw } self.init(unchecked: raw) } - public var unexpectedBeforeAvailabilityVersionRestriction: RawUnexpectedNodesSyntax? { + public var unexpectedBeforePlatformVersion: RawUnexpectedNodesSyntax? { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var availabilityVersionRestriction: RawPlatformVersionSyntax { + public var platformVersion: RawPlatformVersionSyntax { layoutView.children[1].map(RawPlatformVersionSyntax.init(raw:))! } - public var unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: RawUnexpectedNodesSyntax? { + public var unexpectedBetweenPlatformVersionAndTrailingComma: RawUnexpectedNodesSyntax? { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } @@ -17361,7 +17361,7 @@ public struct RawPrefixOperatorExprSyntax: RawExprSyntaxNodeProtocol { public init( _ unexpectedBeforeOperator: RawUnexpectedNodesSyntax? = nil, - operator: RawTokenSyntax?, + operator: RawTokenSyntax, _ unexpectedBetweenOperatorAndExpression: RawUnexpectedNodesSyntax? = nil, expression: RawExprSyntax, _ unexpectedAfterExpression: RawUnexpectedNodesSyntax? = nil, @@ -17371,7 +17371,7 @@ public struct RawPrefixOperatorExprSyntax: RawExprSyntaxNodeProtocol { kind: .prefixOperatorExpr, uninitializedCount: 5, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeOperator?.raw - layout[1] = `operator`?.raw + layout[1] = `operator`.raw layout[2] = unexpectedBetweenOperatorAndExpression?.raw layout[3] = expression.raw layout[4] = unexpectedAfterExpression?.raw @@ -17383,8 +17383,8 @@ public struct RawPrefixOperatorExprSyntax: RawExprSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var `operator`: RawTokenSyntax? { - layoutView.children[1].map(RawTokenSyntax.init(raw:)) + public var `operator`: RawTokenSyntax { + layoutView.children[1].map(RawTokenSyntax.init(raw:))! } public var unexpectedBetweenOperatorAndExpression: RawUnexpectedNodesSyntax? { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index 6f299b3af5c..757f80ba06b 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -2122,7 +2122,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .prefixOperatorExpr: assert(layout.count == 5) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax?.self, tokenChoices: [.tokenKind(.prefixOperator)])) + assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.prefixOperator)])) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawExprSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift index c0b494df66e..31882067daf 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift @@ -5227,7 +5227,7 @@ public struct PostfixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { /// ### Children /// -/// - `operator`: ``? +/// - `operator`: `` /// - `expression`: ``ExprSyntax`` public struct PrefixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public let _syntaxNode: Syntax @@ -5253,7 +5253,7 @@ public struct PrefixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeOperator: UnexpectedNodesSyntax? = nil, - operator: TokenSyntax? = nil, + operator: TokenSyntax, _ unexpectedBetweenOperatorAndExpression: UnexpectedNodesSyntax? = nil, expression: some ExprSyntaxProtocol, _ unexpectedAfterExpression: UnexpectedNodesSyntax? = nil, @@ -5271,7 +5271,7 @@ public struct PrefixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeOperator?.raw, - `operator`?.raw, + `operator`.raw, unexpectedBetweenOperatorAndExpression?.raw, expression.raw, unexpectedAfterExpression?.raw @@ -5298,12 +5298,12 @@ public struct PrefixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { } } - public var `operator`: TokenSyntax? { + public var `operator`: TokenSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(TokenSyntax.init) + return TokenSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = PrefixOperatorExprSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = PrefixOperatorExprSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift index 9ac1555d071..2fe2c579f8d 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift @@ -14323,7 +14323,7 @@ public struct PatternBindingSyntax: SyntaxProtocol, SyntaxHashable { /// /// ### Children /// -/// - `availabilityVersionRestriction`: ``PlatformVersionSyntax`` +/// - `platformVersion`: ``PlatformVersionSyntax`` /// - `trailingComma`: `','`? /// /// ### Contained in @@ -14353,9 +14353,9 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, - _ unexpectedBeforeAvailabilityVersionRestriction: UnexpectedNodesSyntax? = nil, - availabilityVersionRestriction: PlatformVersionSyntax, - _ unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: UnexpectedNodesSyntax? = nil, + _ unexpectedBeforePlatformVersion: UnexpectedNodesSyntax? = nil, + platformVersion: PlatformVersionSyntax, + _ unexpectedBetweenPlatformVersionAndTrailingComma: UnexpectedNodesSyntax? = nil, trailingComma: TokenSyntax? = nil, _ unexpectedAfterTrailingComma: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -14364,16 +14364,16 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { // Extend the lifetime of all parameters so their arenas don't get destroyed // before they can be added as children of the new arena. let data: SyntaxData = withExtendedLifetime((SyntaxArena(), ( - unexpectedBeforeAvailabilityVersionRestriction, - availabilityVersionRestriction, - unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma, + unexpectedBeforePlatformVersion, + platformVersion, + unexpectedBetweenPlatformVersionAndTrailingComma, trailingComma, unexpectedAfterTrailingComma ))) { (arena, _) in let layout: [RawSyntax?] = [ - unexpectedBeforeAvailabilityVersionRestriction?.raw, - availabilityVersionRestriction.raw, - unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma?.raw, + unexpectedBeforePlatformVersion?.raw, + platformVersion.raw, + unexpectedBetweenPlatformVersionAndTrailingComma?.raw, trailingComma?.raw, unexpectedAfterTrailingComma?.raw ] @@ -14390,7 +14390,7 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { self.init(data) } - public var unexpectedBeforeAvailabilityVersionRestriction: UnexpectedNodesSyntax? { + public var unexpectedBeforePlatformVersion: UnexpectedNodesSyntax? { get { return data.child(at: 0, parent: Syntax(self)).map(UnexpectedNodesSyntax.init) } @@ -14399,7 +14399,7 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { } } - public var availabilityVersionRestriction: PlatformVersionSyntax { + public var platformVersion: PlatformVersionSyntax { get { return PlatformVersionSyntax(data.child(at: 1, parent: Syntax(self))!) } @@ -14408,7 +14408,7 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { } } - public var unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma: UnexpectedNodesSyntax? { + public var unexpectedBetweenPlatformVersionAndTrailingComma: UnexpectedNodesSyntax? { get { return data.child(at: 2, parent: Syntax(self)).map(UnexpectedNodesSyntax.init) } @@ -14438,9 +14438,9 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([ - \Self.unexpectedBeforeAvailabilityVersionRestriction, - \Self.availabilityVersionRestriction, - \Self.unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma, + \Self.unexpectedBeforePlatformVersion, + \Self.platformVersion, + \Self.unexpectedBetweenPlatformVersionAndTrailingComma, \Self.trailingComma, \Self.unexpectedAfterTrailingComma ]) @@ -14459,7 +14459,7 @@ public struct PlatformVersionItemSyntax: SyntaxProtocol, SyntaxHashable { /// ### Contained in /// /// - ``AvailabilityArgumentSyntax``.``AvailabilityArgumentSyntax/argument`` -/// - ``PlatformVersionItemSyntax``.``PlatformVersionItemSyntax/availabilityVersionRestriction`` +/// - ``PlatformVersionItemSyntax``.``PlatformVersionItemSyntax/platformVersion`` public struct PlatformVersionSyntax: SyntaxProtocol, SyntaxHashable { public let _syntaxNode: Syntax From a2cf2dff03565e98084e0d94ffc1b05e942816fe Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 2 Aug 2023 14:13:59 -0700 Subject: [PATCH 2/2] Rename TokenKind.floatingLiteral -> floatLiteral This is consistent with `FloatLiteralExprSyntax` --- .../Sources/SyntaxSupport/ExprNodes.swift | 2 +- .../Sources/SyntaxSupport/TokenSpec.swift | 2 +- .../ValidateSyntaxNodes.swift | 2 +- .../SwiftIDEUtils/SyntaxClassification.swift | 11 +++++-- Sources/SwiftParser/Availability.swift | 8 ++--- Sources/SwiftParser/Expressions.swift | 4 +-- Sources/SwiftParser/Lexer/Cursor.swift | 12 +++---- .../SwiftParser/Lexer/RegexLiteralLexer.swift | 2 +- Sources/SwiftParser/Parser.swift | 2 +- Sources/SwiftParser/TokenPrecedence.swift | 2 +- Sources/SwiftParser/TokenSpec.swift | 2 +- Sources/SwiftParser/TokenSpecSet.swift | 6 ++-- .../generated/TokenSpecStaticMembers.swift | 4 +-- .../ParserDiagnosticMessages.swift | 2 +- .../generated/TokenNameForDiagnostics.swift | 4 +-- .../SwiftSyntaxCompatibility.swift | 20 ++++++++++++ Sources/SwiftSyntax/generated/TokenKind.swift | 20 ++++++------ Sources/SwiftSyntax/generated/Tokens.swift | 4 +-- .../generated/raw/RawSyntaxValidation.swift | 2 +- .../syntaxNodes/SyntaxExprNodes.swift | 2 +- .../ConvenienceInitializers.swift | 2 +- .../Syntax+StringInterpolation.swift | 2 +- .../ClassifiedSyntaxTreePrinter.swift | 2 +- Tests/SwiftParserTest/LexerTests.swift | 32 +++++++++---------- .../translated/IfconfigExprTests.swift | 2 +- .../FloatLiteralTests.swift | 8 ++--- 26 files changed, 93 insertions(+), 68 deletions(-) diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index d61108a5a01..3dcf8b7604b 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -770,7 +770,7 @@ public let EXPR_NODES: [Node] = [ Child( name: "Literal", deprecatedName: "FloatingDigits", - kind: .token(choices: [.token(tokenKind: "FloatingLiteralToken")]) + kind: .token(choices: [.token(tokenKind: "FloatLiteralToken")]) ) ] ), diff --git a/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift b/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift index 6c468c19109..bab4e04e31f 100644 --- a/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift +++ b/CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift @@ -79,7 +79,7 @@ public let SYNTAX_TOKENS: [TokenSpec] = [ .other(name: "endOfFile", nameForDiagnostics: "end of file", text: ""), .punctuator(name: "equal", text: "="), .punctuator(name: "exclamationMark", text: "!"), - .other(name: "floatingLiteral", nameForDiagnostics: "floating literal"), + .other(name: "floatLiteral", nameForDiagnostics: "float literal"), .other(name: "identifier", nameForDiagnostics: "identifier"), .punctuator(name: "infixQuestionMark", text: "?"), .other(name: "integerLiteral", nameForDiagnostics: "integer literal"), diff --git a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift index b9c42077c5c..239ebd47125 100644 --- a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift +++ b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift @@ -178,7 +178,7 @@ class ValidateSyntaxNodes: XCTestCase { } } - case .token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "FloatingLiteralToken"): + case .token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "FloatLiteralToken"): // We allow arbitrary naming of identifiers and literals break case .token(tokenKind: "CommaToken"): diff --git a/Sources/SwiftIDEUtils/SyntaxClassification.swift b/Sources/SwiftIDEUtils/SyntaxClassification.swift index a04dafe1e91..5ba88f8b523 100644 --- a/Sources/SwiftIDEUtils/SyntaxClassification.swift +++ b/Sources/SwiftIDEUtils/SyntaxClassification.swift @@ -28,7 +28,7 @@ public enum SyntaxClassification { /// An editor placeholder of the form `<#content#>` case editorPlaceholder /// A floating point literal. - case floatingLiteral + case floatLiteral /// A generic identifier. case identifier /// An integer literal. @@ -51,6 +51,11 @@ public enum SyntaxClassification { case stringLiteral /// An identifier referring to a type. case typeIdentifier + + @available(*, deprecated, renamed: "floatLiteral") + public static var floatingLiteral: Self { + return .floatLiteral + } } extension SyntaxClassification { @@ -124,8 +129,8 @@ extension RawTokenKind { return .none case .exclamationMark: return .none - case .floatingLiteral: - return .floatingLiteral + case .floatLiteral: + return .floatLiteral case .identifier: return .identifier case .infixQuestionMark: diff --git a/Sources/SwiftParser/Availability.swift b/Sources/SwiftParser/Availability.swift index 2d12d9c3176..8101741d60a 100644 --- a/Sources/SwiftParser/Availability.swift +++ b/Sources/SwiftParser/Availability.swift @@ -210,7 +210,7 @@ extension Parser { } let version: RawVersionTupleSyntax? - if self.at(.integerLiteral, .floatingLiteral) { + if self.at(.integerLiteral, .floatLiteral) { version = self.parseVersionTuple(maxComponentCount: 3) } else { version = nil @@ -237,7 +237,7 @@ extension Parser { return self.consumeAnyToken() } - /// Consume the unexpected version token(e.g. integerLiteral, floatingLiteral, identifier) until the period no longer appears. + /// Consume the unexpected version token(e.g. integerLiteral, floatLiteral, identifier) until the period no longer appears. private mutating func parseUnexpectedVersionTokens() -> RawUnexpectedNodesSyntax? { var unexpectedTokens: [RawTokenSyntax] = [] var keepGoing: RawTokenSyntax? = nil @@ -246,7 +246,7 @@ extension Parser { if let keepGoing { unexpectedTokens.append(keepGoing) } - if let unexpectedVersion = self.consume(if: .integerLiteral, .floatingLiteral, .identifier) { + if let unexpectedVersion = self.consume(if: .integerLiteral, .floatLiteral, .identifier) { unexpectedTokens.append(unexpectedVersion) } keepGoing = self.consume(if: .period) @@ -256,7 +256,7 @@ extension Parser { /// Parse a dot-separated list of version numbers. mutating func parseVersionTuple(maxComponentCount: Int) -> RawVersionTupleSyntax { - if self.at(.floatingLiteral), + if self.at(.floatLiteral), let periodIndex = self.currentToken.tokenText.firstIndex(of: UInt8(ascii: ".")), self.currentToken.tokenText[0.. Lexer.Result { @@ -1529,7 +1529,7 @@ extension Lexer.Cursor { let errorPos = tmp self.advance(while: { $0.isValidIdentifierContinuationCodePoint }) return Lexer.Result( - .floatingLiteral, + .floatLiteral, error: LexingDiagnostic(errorKind, position: errorPos) ) } @@ -1541,11 +1541,11 @@ extension Lexer.Cursor { let errorPos = tmp self.advance(while: { $0.isValidIdentifierContinuationCodePoint }) return Lexer.Result( - .floatingLiteral, + .floatLiteral, error: LexingDiagnostic(.invalidFloatingPointExponentDigit, position: errorPos) ) } - return Lexer.Result(.floatingLiteral) + return Lexer.Result(.floatLiteral) } } diff --git a/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift b/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift index 5e8a76860da..300ceda63ca 100644 --- a/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift +++ b/Sources/SwiftParser/Lexer/RegexLiteralLexer.swift @@ -640,7 +640,7 @@ extension Lexer.Cursor { return false // Literals are themselves expressions and therefore don't sequence expressions. - case .floatingLiteral, .integerLiteral: + case .floatLiteral, .integerLiteral: return false // Pound keywords that do not generally sequence expressions. diff --git a/Sources/SwiftParser/Parser.swift b/Sources/SwiftParser/Parser.swift index f5c67c200e8..6fbdcc0502a 100644 --- a/Sources/SwiftParser/Parser.swift +++ b/Sources/SwiftParser/Parser.swift @@ -524,7 +524,7 @@ extension Parser { self.missingToken(.identifier) ) } - if let number = self.consume(if: .integerLiteral, .floatingLiteral, .dollarIdentifier) { + if let number = self.consume(if: .integerLiteral, .floatLiteral, .dollarIdentifier) { return ( RawUnexpectedNodesSyntax(elements: [RawSyntax(number)], arena: self.arena), self.missingToken(.identifier) diff --git a/Sources/SwiftParser/TokenPrecedence.swift b/Sources/SwiftParser/TokenPrecedence.swift index a1e745aafd1..3eb38c2802f 100644 --- a/Sources/SwiftParser/TokenPrecedence.swift +++ b/Sources/SwiftParser/TokenPrecedence.swift @@ -117,7 +117,7 @@ enum TokenPrecedence: Comparable { self = .unknownToken // MARK: Identifier like case // Literals - .floatingLiteral, .integerLiteral, + .floatLiteral, .integerLiteral, // Pound literals .poundAvailable, .poundSourceLocation, .poundUnavailable, // Identifiers diff --git a/Sources/SwiftParser/TokenSpec.swift b/Sources/SwiftParser/TokenSpec.swift index 8cdb1dfb76a..da0b3fc74fd 100644 --- a/Sources/SwiftParser/TokenSpec.swift +++ b/Sources/SwiftParser/TokenSpec.swift @@ -172,7 +172,7 @@ public struct TokenSpec { switch rawTokenKind { case .binaryOperator: return .binaryOperator("+") case .dollarIdentifier: return .dollarIdentifier("$0") - case .floatingLiteral: return .floatingLiteral("1.0") + case .floatLiteral: return .floatLiteral("1.0") case .identifier: return .identifier("myIdent") case .integerLiteral: return .integerLiteral("1") case .keyword: return .keyword(keyword!) diff --git a/Sources/SwiftParser/TokenSpecSet.swift b/Sources/SwiftParser/TokenSpecSet.swift index f35e555aecb..fa94daba197 100644 --- a/Sources/SwiftParser/TokenSpecSet.swift +++ b/Sources/SwiftParser/TokenSpecSet.swift @@ -774,7 +774,7 @@ enum PrimaryExpressionStart: TokenSpecSet { case `Self` case dollarIdentifier case `false` - case floatingLiteral + case floatLiteral case identifier case `init` case integerLiteral @@ -804,7 +804,7 @@ enum PrimaryExpressionStart: TokenSpecSet { case TokenSpec(.Self): self = .Self case TokenSpec(.dollarIdentifier): self = .dollarIdentifier case TokenSpec(.false): self = .false - case TokenSpec(.floatingLiteral): self = .floatingLiteral + case TokenSpec(.floatLiteral): self = .floatLiteral case TokenSpec(.identifier): self = .identifier case TokenSpec(.`init`): self = .`init` case TokenSpec(.integerLiteral): self = .integerLiteral @@ -837,7 +837,7 @@ enum PrimaryExpressionStart: TokenSpecSet { case .Self: return .keyword(.Self) case .dollarIdentifier: return .dollarIdentifier case .false: return .keyword(.false) - case .floatingLiteral: return .floatingLiteral + case .floatLiteral: return .floatLiteral case .identifier: return .identifier case .`init`: return .keyword(.`init`) case .integerLiteral: return .integerLiteral diff --git a/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift b/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift index 2b9ad4798c9..4b994dd023b 100644 --- a/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift +++ b/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift @@ -63,8 +63,8 @@ extension TokenSpec { return TokenSpec(.exclamationMark) } - static var floatingLiteral: TokenSpec { - return TokenSpec(.floatingLiteral) + static var floatLiteral: TokenSpec { + return TokenSpec(.floatLiteral) } static var identifier: TokenSpec { diff --git a/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift b/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift index 2ac728f6f57..17f804be5f4 100644 --- a/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift +++ b/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift @@ -355,7 +355,7 @@ public struct InvalidIdentifierError: ParserError { public var message: String { switch invalidIdentifier.tokenKind { - case .floatingLiteral(let text), .integerLiteral(let text): + case .floatLiteral(let text), .integerLiteral(let text): fallthrough case .unknown(let text) where text.first?.isNumber == true: let name = missingIdentifier.childNameInParent ?? "identifier" diff --git a/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift index c00767d72b4..8e069bea2a6 100644 --- a/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift +++ b/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift @@ -41,8 +41,8 @@ extension TokenKind { return "=" case .exclamationMark: return "!" - case .floatingLiteral: - return "floating literal" + case .floatLiteral: + return "float literal" case .identifier: return "identifier" case .infixQuestionMark: diff --git a/Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift b/Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift index 7b344924b8f..6e5c52a0655 100644 --- a/Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift +++ b/Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift @@ -135,6 +135,11 @@ public extension TokenKind { return .regexPoundDelimiter(text) } + @available(*, deprecated, renamed: "floatLiteral") + static func floatingLiteral(_ text: String) -> TokenKind { + return .floatLiteral(text) + } + @available(*, deprecated, renamed: "leftSquare") static var leftSquareBracket: TokenKind { return .leftSquare @@ -205,6 +210,21 @@ public extension TokenSyntax { ) } + @available(*, deprecated, renamed: "floatLiteral") + static func floatingLiteral( + _ text: String, + leadingTrivia: Trivia = [], + trailingTrivia: Trivia = [], + presence: SourcePresence = .present + ) -> TokenSyntax { + return floatLiteral( + text, + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia, + presence: presence + ) + } + @available(*, deprecated, renamed: "leftSquareToken") static func leftSquareBracketToken( leadingTrivia: Trivia = [], diff --git a/Sources/SwiftSyntax/generated/TokenKind.swift b/Sources/SwiftSyntax/generated/TokenKind.swift index 365ef9978e3..746df258be5 100644 --- a/Sources/SwiftSyntax/generated/TokenKind.swift +++ b/Sources/SwiftSyntax/generated/TokenKind.swift @@ -26,7 +26,7 @@ public enum TokenKind: Hashable { case endOfFile case equal case exclamationMark - case floatingLiteral(String) + case floatLiteral(String) case identifier(String) case infixQuestionMark case integerLiteral(String) @@ -92,7 +92,7 @@ public enum TokenKind: Hashable { return #"="# case .exclamationMark: return #"!"# - case .floatingLiteral(let text): + case .floatLiteral(let text): return text case .identifier(let text): return text @@ -283,7 +283,7 @@ public enum TokenKind: Hashable { return true case .exclamationMark: return true - case .floatingLiteral: + case .floatLiteral: return false case .identifier: return false @@ -388,7 +388,7 @@ extension TokenKind: Equatable { return true case (.exclamationMark, .exclamationMark): return true - case (.floatingLiteral(let lhsText), .floatingLiteral(let rhsText)): + case (.floatLiteral(let lhsText), .floatLiteral(let rhsText)): return lhsText == rhsText case (.identifier(let lhsText), .identifier(let rhsText)): return lhsText == rhsText @@ -487,7 +487,7 @@ public enum RawTokenKind: UInt8, Equatable, Hashable { case endOfFile case equal case exclamationMark - case floatingLiteral + case floatLiteral case identifier case infixQuestionMark case integerLiteral @@ -636,7 +636,7 @@ public enum RawTokenKind: UInt8, Equatable, Hashable { return true case .exclamationMark: return true - case .floatingLiteral: + case .floatLiteral: return false case .identifier: return false @@ -753,8 +753,8 @@ extension TokenKind { case .exclamationMark: precondition(text.isEmpty || rawKind.defaultText.map(String.init) == text) return .exclamationMark - case .floatingLiteral: - return .floatingLiteral(text) + case .floatLiteral: + return .floatLiteral(text) case .identifier: return .identifier(text) case .infixQuestionMark: @@ -888,8 +888,8 @@ extension TokenKind { return (.equal, nil) case .exclamationMark: return (.exclamationMark, nil) - case .floatingLiteral(let str): - return (.floatingLiteral, str) + case .floatLiteral(let str): + return (.floatLiteral, str) case .identifier(let str): return (.identifier, str) case .infixQuestionMark: diff --git a/Sources/SwiftSyntax/generated/Tokens.swift b/Sources/SwiftSyntax/generated/Tokens.swift index 4d98f39feb9..ce26945133b 100644 --- a/Sources/SwiftSyntax/generated/Tokens.swift +++ b/Sources/SwiftSyntax/generated/Tokens.swift @@ -185,7 +185,7 @@ extension TokenSyntax { ) } - public static func floatingLiteral( + public static func floatLiteral( _ text: String, leadingTrivia: Trivia = [], trailingTrivia: Trivia = [], @@ -193,7 +193,7 @@ extension TokenSyntax { ) -> TokenSyntax { return TokenSyntax( - .floatingLiteral(text), + .floatLiteral(text), leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, presence: presence diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index 757f80ba06b..097377e7648 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -1175,7 +1175,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .floatLiteralExpr: assert(layout.count == 3) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.floatingLiteral)])) + assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.floatLiteral)])) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) case .forStmt: assert(layout.count == 21) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift index 31882067daf..8aca93c9231 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift @@ -2305,7 +2305,7 @@ public struct EditorPlaceholderExprSyntax: ExprSyntaxProtocol, SyntaxHashable { /// ### Children /// -/// - `literal`: `` +/// - `literal`: `` public struct FloatLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public let _syntaxNode: Syntax diff --git a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift index a6cebe82197..5152d73097f 100644 --- a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift +++ b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift @@ -155,7 +155,7 @@ extension ExprSyntax { extension FloatLiteralExprSyntax: ExpressibleByFloatLiteral { public init(_ value: Float) { - self.init(literal: .floatingLiteral(String(value))) + self.init(literal: .floatLiteral(String(value))) } public init(floatLiteral value: Float) { diff --git a/Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift b/Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift index 0c5324c9595..6e0e7f34213 100644 --- a/Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift +++ b/Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift @@ -273,7 +273,7 @@ extension ExpressibleByLiteralSyntax where Self: FloatingPoint, Self: LosslessSt case .negativeNormal, .negativeSubnormal, .positiveZero, .positiveSubnormal, .positiveNormal: // TODO: Thousands separators? let digits = String(self) - return ExprSyntax(FloatLiteralExprSyntax(literal: .floatingLiteral(digits))) + return ExprSyntax(FloatLiteralExprSyntax(literal: .floatLiteral(digits))) } } diff --git a/Sources/lit-test-helper/ClassifiedSyntaxTreePrinter.swift b/Sources/lit-test-helper/ClassifiedSyntaxTreePrinter.swift index 32e8bfb8f61..e6cba747214 100644 --- a/Sources/lit-test-helper/ClassifiedSyntaxTreePrinter.swift +++ b/Sources/lit-test-helper/ClassifiedSyntaxTreePrinter.swift @@ -23,7 +23,7 @@ extension SyntaxClassification { case .dollarIdentifier: return "dollar" case .operatorIdentifier: return "op" case .integerLiteral: return "int" - case .floatingLiteral: return "float" + case .floatLiteral: return "float" case .stringLiteral: return "str" case .stringInterpolationAnchor: return "anchor" case .regexLiteral: return "regex" diff --git a/Tests/SwiftParserTest/LexerTests.swift b/Tests/SwiftParserTest/LexerTests.swift index 1336c52d033..854765471f7 100644 --- a/Tests/SwiftParserTest/LexerTests.swift +++ b/Tests/SwiftParserTest/LexerTests.swift @@ -169,19 +169,19 @@ public class LexerTests: XCTestCase { assertLexemes( "1.0", lexemes: [ - LexemeSpec(.floatingLiteral, text: "1.0") + LexemeSpec(.floatLiteral, text: "1.0") ] ) assertLexemes( "1.0e10", lexemes: [ - LexemeSpec(.floatingLiteral, text: "1.0e10") + LexemeSpec(.floatLiteral, text: "1.0e10") ] ) assertLexemes( "1.0E10", lexemes: [ - LexemeSpec(.floatingLiteral, text: "1.0E10") + LexemeSpec(.floatLiteral, text: "1.0E10") ] ) assertLexemes( @@ -193,27 +193,27 @@ public class LexerTests: XCTestCase { assertLexemes( "0xff.0p2", lexemes: [ - LexemeSpec(.floatingLiteral, text: "0xff.0p2") + LexemeSpec(.floatLiteral, text: "0xff.0p2") ] ) assertLexemes( "-0xff.0p2", lexemes: [ LexemeSpec(.prefixOperator, text: "-"), - LexemeSpec(.floatingLiteral, text: "0xff.0p2"), + LexemeSpec(.floatLiteral, text: "0xff.0p2"), ] ) assertLexemes( "+0xff.0p2", lexemes: [ LexemeSpec(.prefixOperator, text: "+"), - LexemeSpec(.floatingLiteral, text: "0xff.0p2"), + LexemeSpec(.floatLiteral, text: "0xff.0p2"), ] ) assertLexemes( "0x1.921fb4p1", lexemes: [ - LexemeSpec(.floatingLiteral, text: "0x1.921fb4p1") + LexemeSpec(.floatLiteral, text: "0x1.921fb4p1") ] ) } @@ -747,15 +747,15 @@ public class LexerTests: XCTestCase { LexemeSpec(.leftParen, text: "("), LexemeSpec(.identifier, text: "white"), LexemeSpec(.colon, text: ":", trailing: " "), - LexemeSpec(.floatingLiteral, text: "216.0"), + LexemeSpec(.floatLiteral, text: "216.0"), LexemeSpec(.binaryOperator, text: "/"), - LexemeSpec(.floatingLiteral, text: "255.0"), + LexemeSpec(.floatLiteral, text: "255.0"), LexemeSpec(.comma, text: ",", trailing: " "), LexemeSpec(.identifier, text: "alpha"), LexemeSpec(.colon, text: ":", trailing: " "), - LexemeSpec(.floatingLiteral, text: "44.0"), + LexemeSpec(.floatLiteral, text: "44.0"), LexemeSpec(.binaryOperator, text: "/"), - LexemeSpec(.floatingLiteral, text: "255.0"), + LexemeSpec(.floatLiteral, text: "255.0"), LexemeSpec(.rightParen, text: ")"), ] ) @@ -898,7 +898,7 @@ public class LexerTests: XCTestCase { ) assertLexemes( " 0x1p1️⃣_", - lexemes: [LexemeSpec(.floatingLiteral, leading: " ", text: "0x1p_", diagnostic: "'_' is not a valid first character in floating point exponent")] + lexemes: [LexemeSpec(.floatLiteral, leading: " ", text: "0x1p_", diagnostic: "'_' is not a valid first character in floating point exponent")] ) assertLexemes( "01️⃣QWERTY", @@ -918,11 +918,11 @@ public class LexerTests: XCTestCase { ) assertLexemes( "1.0e+1️⃣QWERTY", - lexemes: [LexemeSpec(.floatingLiteral, text: "1.0e+QWERTY", diagnostic: "'Q' is not a valid digit in floating point exponent")] + lexemes: [LexemeSpec(.floatLiteral, text: "1.0e+QWERTY", diagnostic: "'Q' is not a valid digit in floating point exponent")] ) assertLexemes( "0x1p+1️⃣QWERTY", - lexemes: [LexemeSpec(.floatingLiteral, text: "0x1p+QWERTY", diagnostic: "'Q' is not a valid digit in floating point exponent")] + lexemes: [LexemeSpec(.floatLiteral, text: "0x1p+QWERTY", diagnostic: "'Q' is not a valid digit in floating point exponent")] ) } @@ -1228,9 +1228,9 @@ public class LexerTests: XCTestCase { assertLexemes( "0.1...0.2", lexemes: [ - LexemeSpec(.floatingLiteral, text: "0.1"), + LexemeSpec(.floatLiteral, text: "0.1"), LexemeSpec(.binaryOperator, text: "..."), - LexemeSpec(.floatingLiteral, text: "0.2"), + LexemeSpec(.floatLiteral, text: "0.2"), ] ) } diff --git a/Tests/SwiftParserTest/translated/IfconfigExprTests.swift b/Tests/SwiftParserTest/translated/IfconfigExprTests.swift index f00d98ace1f..ba12260dc46 100644 --- a/Tests/SwiftParserTest/translated/IfconfigExprTests.swift +++ b/Tests/SwiftParserTest/translated/IfconfigExprTests.swift @@ -661,7 +661,7 @@ final class IfconfigExprTests: XCTestCase { LabeledExprSyntax( expression: PrefixOperatorExprSyntax( operator: .prefixOperator("<"), - expression: FloatLiteralExprSyntax(literal: .floatingLiteral("10.0")) + expression: FloatLiteralExprSyntax(literal: .floatLiteral("10.0")) ) ) ]), diff --git a/Tests/SwiftSyntaxBuilderTest/FloatLiteralTests.swift b/Tests/SwiftSyntaxBuilderTest/FloatLiteralTests.swift index b5362ee7756..4273055a5ec 100644 --- a/Tests/SwiftSyntaxBuilderTest/FloatLiteralTests.swift +++ b/Tests/SwiftSyntaxBuilderTest/FloatLiteralTests.swift @@ -17,10 +17,10 @@ import SwiftSyntaxBuilder final class FloatLiteralTests: XCTestCase { func testFloatLiteral() { let testCases: [UInt: (FloatLiteralExprSyntax, String)] = [ - #line: (FloatLiteralExprSyntax(literal: .floatingLiteral(String(123.321))), "123.321"), - #line: (FloatLiteralExprSyntax(literal: .floatingLiteral(String(-123.321))), "-123.321"), - #line: (FloatLiteralExprSyntax(literal: .floatingLiteral("2_123.321")), "2_123.321"), - #line: (FloatLiteralExprSyntax(literal: .floatingLiteral("-2_123.321")), "-2_123.321"), + #line: (FloatLiteralExprSyntax(literal: .floatLiteral(String(123.321))), "123.321"), + #line: (FloatLiteralExprSyntax(literal: .floatLiteral(String(-123.321))), "-123.321"), + #line: (FloatLiteralExprSyntax(literal: .floatLiteral("2_123.321")), "2_123.321"), + #line: (FloatLiteralExprSyntax(literal: .floatLiteral("-2_123.321")), "-2_123.321"), #line: (FloatLiteralExprSyntax(2_123.321), "2123.321"), #line: (FloatLiteralExprSyntax(-2_123.321), "-2123.321"), #line: (2_123.321, "2123.321"),