Skip to content

Commit a2cf2df

Browse files
committed
Rename TokenKind.floatingLiteral -> floatLiteral
This is consistent with `FloatLiteralExprSyntax`
1 parent d54a829 commit a2cf2df

26 files changed

+93
-68
lines changed

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ public let EXPR_NODES: [Node] = [
770770
Child(
771771
name: "Literal",
772772
deprecatedName: "FloatingDigits",
773-
kind: .token(choices: [.token(tokenKind: "FloatingLiteralToken")])
773+
kind: .token(choices: [.token(tokenKind: "FloatLiteralToken")])
774774
)
775775
]
776776
),

CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
7979
.other(name: "endOfFile", nameForDiagnostics: "end of file", text: ""),
8080
.punctuator(name: "equal", text: "="),
8181
.punctuator(name: "exclamationMark", text: "!"),
82-
.other(name: "floatingLiteral", nameForDiagnostics: "floating literal"),
82+
.other(name: "floatLiteral", nameForDiagnostics: "float literal"),
8383
.other(name: "identifier", nameForDiagnostics: "identifier"),
8484
.punctuator(name: "infixQuestionMark", text: "?"),
8585
.other(name: "integerLiteral", nameForDiagnostics: "integer literal"),

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class ValidateSyntaxNodes: XCTestCase {
178178
}
179179
}
180180

181-
case .token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "FloatingLiteralToken"):
181+
case .token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "FloatLiteralToken"):
182182
// We allow arbitrary naming of identifiers and literals
183183
break
184184
case .token(tokenKind: "CommaToken"):

Sources/SwiftIDEUtils/SyntaxClassification.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public enum SyntaxClassification {
2828
/// An editor placeholder of the form `<#content#>`
2929
case editorPlaceholder
3030
/// A floating point literal.
31-
case floatingLiteral
31+
case floatLiteral
3232
/// A generic identifier.
3333
case identifier
3434
/// An integer literal.
@@ -51,6 +51,11 @@ public enum SyntaxClassification {
5151
case stringLiteral
5252
/// An identifier referring to a type.
5353
case typeIdentifier
54+
55+
@available(*, deprecated, renamed: "floatLiteral")
56+
public static var floatingLiteral: Self {
57+
return .floatLiteral
58+
}
5459
}
5560

5661
extension SyntaxClassification {
@@ -124,8 +129,8 @@ extension RawTokenKind {
124129
return .none
125130
case .exclamationMark:
126131
return .none
127-
case .floatingLiteral:
128-
return .floatingLiteral
132+
case .floatLiteral:
133+
return .floatLiteral
129134
case .identifier:
130135
return .identifier
131136
case .infixQuestionMark:

Sources/SwiftParser/Availability.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ extension Parser {
210210
}
211211

212212
let version: RawVersionTupleSyntax?
213-
if self.at(.integerLiteral, .floatingLiteral) {
213+
if self.at(.integerLiteral, .floatLiteral) {
214214
version = self.parseVersionTuple(maxComponentCount: 3)
215215
} else {
216216
version = nil
@@ -237,7 +237,7 @@ extension Parser {
237237
return self.consumeAnyToken()
238238
}
239239

240-
/// Consume the unexpected version token(e.g. integerLiteral, floatingLiteral, identifier) until the period no longer appears.
240+
/// Consume the unexpected version token(e.g. integerLiteral, floatLiteral, identifier) until the period no longer appears.
241241
private mutating func parseUnexpectedVersionTokens() -> RawUnexpectedNodesSyntax? {
242242
var unexpectedTokens: [RawTokenSyntax] = []
243243
var keepGoing: RawTokenSyntax? = nil
@@ -246,7 +246,7 @@ extension Parser {
246246
if let keepGoing {
247247
unexpectedTokens.append(keepGoing)
248248
}
249-
if let unexpectedVersion = self.consume(if: .integerLiteral, .floatingLiteral, .identifier) {
249+
if let unexpectedVersion = self.consume(if: .integerLiteral, .floatLiteral, .identifier) {
250250
unexpectedTokens.append(unexpectedVersion)
251251
}
252252
keepGoing = self.consume(if: .period)
@@ -256,7 +256,7 @@ extension Parser {
256256

257257
/// Parse a dot-separated list of version numbers.
258258
mutating func parseVersionTuple(maxComponentCount: Int) -> RawVersionTupleSyntax {
259-
if self.at(.floatingLiteral),
259+
if self.at(.floatLiteral),
260260
let periodIndex = self.currentToken.tokenText.firstIndex(of: UInt8(ascii: ".")),
261261
self.currentToken.tokenText[0..<periodIndex].allSatisfy({ Unicode.Scalar($0).isDigit })
262262
{

Sources/SwiftParser/Expressions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ extension Parser {
10971097
arena: self.arena
10981098
)
10991099
)
1100-
case (.floatingLiteral, let handle)?:
1100+
case (.floatLiteral, let handle)?:
11011101
let literal = self.eat(handle)
11021102
return RawExprSyntax(
11031103
RawFloatLiteralExprSyntax(
@@ -1186,7 +1186,7 @@ extension Parser {
11861186
return RawExprSyntax(
11871187
RawFloatLiteralExprSyntax(
11881188
literal: RawTokenSyntax(
1189-
missing: .floatingLiteral,
1189+
missing: .floatLiteral,
11901190
text: text,
11911191
arena: self.arena
11921192
),

Sources/SwiftParser/Lexer/Cursor.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ extension Lexer.Cursor {
14071407
let errorPos = tmp
14081408
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
14091409
return Lexer.Result(
1410-
.floatingLiteral,
1410+
.floatLiteral,
14111411
error: LexingDiagnostic(errorKind, position: errorPos)
14121412
)
14131413
}
@@ -1419,13 +1419,13 @@ extension Lexer.Cursor {
14191419
let errorPos = tmp
14201420
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
14211421
return Lexer.Result(
1422-
.floatingLiteral,
1422+
.floatLiteral,
14231423
error: LexingDiagnostic(.invalidFloatingPointExponentDigit, position: errorPos)
14241424
)
14251425
}
14261426
}
14271427

1428-
return Lexer.Result(.floatingLiteral)
1428+
return Lexer.Result(.floatLiteral)
14291429
}
14301430

14311431
mutating func lexHexNumber() -> Lexer.Result {
@@ -1529,7 +1529,7 @@ extension Lexer.Cursor {
15291529
let errorPos = tmp
15301530
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
15311531
return Lexer.Result(
1532-
.floatingLiteral,
1532+
.floatLiteral,
15331533
error: LexingDiagnostic(errorKind, position: errorPos)
15341534
)
15351535
}
@@ -1541,11 +1541,11 @@ extension Lexer.Cursor {
15411541
let errorPos = tmp
15421542
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
15431543
return Lexer.Result(
1544-
.floatingLiteral,
1544+
.floatLiteral,
15451545
error: LexingDiagnostic(.invalidFloatingPointExponentDigit, position: errorPos)
15461546
)
15471547
}
1548-
return Lexer.Result(.floatingLiteral)
1548+
return Lexer.Result(.floatLiteral)
15491549
}
15501550
}
15511551

Sources/SwiftParser/Lexer/RegexLiteralLexer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ extension Lexer.Cursor {
640640
return false
641641

642642
// Literals are themselves expressions and therefore don't sequence expressions.
643-
case .floatingLiteral, .integerLiteral:
643+
case .floatLiteral, .integerLiteral:
644644
return false
645645

646646
// Pound keywords that do not generally sequence expressions.

Sources/SwiftParser/Parser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ extension Parser {
524524
self.missingToken(.identifier)
525525
)
526526
}
527-
if let number = self.consume(if: .integerLiteral, .floatingLiteral, .dollarIdentifier) {
527+
if let number = self.consume(if: .integerLiteral, .floatLiteral, .dollarIdentifier) {
528528
return (
529529
RawUnexpectedNodesSyntax(elements: [RawSyntax(number)], arena: self.arena),
530530
self.missingToken(.identifier)

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum TokenPrecedence: Comparable {
117117
self = .unknownToken
118118
// MARK: Identifier like
119119
case // Literals
120-
.floatingLiteral, .integerLiteral,
120+
.floatLiteral, .integerLiteral,
121121
// Pound literals
122122
.poundAvailable, .poundSourceLocation, .poundUnavailable,
123123
// Identifiers

Sources/SwiftParser/TokenSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public struct TokenSpec {
172172
switch rawTokenKind {
173173
case .binaryOperator: return .binaryOperator("+")
174174
case .dollarIdentifier: return .dollarIdentifier("$0")
175-
case .floatingLiteral: return .floatingLiteral("1.0")
175+
case .floatLiteral: return .floatLiteral("1.0")
176176
case .identifier: return .identifier("myIdent")
177177
case .integerLiteral: return .integerLiteral("1")
178178
case .keyword: return .keyword(keyword!)

Sources/SwiftParser/TokenSpecSet.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ enum PrimaryExpressionStart: TokenSpecSet {
774774
case `Self`
775775
case dollarIdentifier
776776
case `false`
777-
case floatingLiteral
777+
case floatLiteral
778778
case identifier
779779
case `init`
780780
case integerLiteral
@@ -804,7 +804,7 @@ enum PrimaryExpressionStart: TokenSpecSet {
804804
case TokenSpec(.Self): self = .Self
805805
case TokenSpec(.dollarIdentifier): self = .dollarIdentifier
806806
case TokenSpec(.false): self = .false
807-
case TokenSpec(.floatingLiteral): self = .floatingLiteral
807+
case TokenSpec(.floatLiteral): self = .floatLiteral
808808
case TokenSpec(.identifier): self = .identifier
809809
case TokenSpec(.`init`): self = .`init`
810810
case TokenSpec(.integerLiteral): self = .integerLiteral
@@ -837,7 +837,7 @@ enum PrimaryExpressionStart: TokenSpecSet {
837837
case .Self: return .keyword(.Self)
838838
case .dollarIdentifier: return .dollarIdentifier
839839
case .false: return .keyword(.false)
840-
case .floatingLiteral: return .floatingLiteral
840+
case .floatLiteral: return .floatLiteral
841841
case .identifier: return .identifier
842842
case .`init`: return .keyword(.`init`)
843843
case .integerLiteral: return .integerLiteral

Sources/SwiftParser/generated/TokenSpecStaticMembers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ extension TokenSpec {
6363
return TokenSpec(.exclamationMark)
6464
}
6565

66-
static var floatingLiteral: TokenSpec {
67-
return TokenSpec(.floatingLiteral)
66+
static var floatLiteral: TokenSpec {
67+
return TokenSpec(.floatLiteral)
6868
}
6969

7070
static var identifier: TokenSpec {

Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public struct InvalidIdentifierError: ParserError {
355355

356356
public var message: String {
357357
switch invalidIdentifier.tokenKind {
358-
case .floatingLiteral(let text), .integerLiteral(let text):
358+
case .floatLiteral(let text), .integerLiteral(let text):
359359
fallthrough
360360
case .unknown(let text) where text.first?.isNumber == true:
361361
let name = missingIdentifier.childNameInParent ?? "identifier"

Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ extension TokenKind {
4141
return "="
4242
case .exclamationMark:
4343
return "!"
44-
case .floatingLiteral:
45-
return "floating literal"
44+
case .floatLiteral:
45+
return "float literal"
4646
case .identifier:
4747
return "identifier"
4848
case .infixQuestionMark:

Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public extension TokenKind {
135135
return .regexPoundDelimiter(text)
136136
}
137137

138+
@available(*, deprecated, renamed: "floatLiteral")
139+
static func floatingLiteral(_ text: String) -> TokenKind {
140+
return .floatLiteral(text)
141+
}
142+
138143
@available(*, deprecated, renamed: "leftSquare")
139144
static var leftSquareBracket: TokenKind {
140145
return .leftSquare
@@ -205,6 +210,21 @@ public extension TokenSyntax {
205210
)
206211
}
207212

213+
@available(*, deprecated, renamed: "floatLiteral")
214+
static func floatingLiteral(
215+
_ text: String,
216+
leadingTrivia: Trivia = [],
217+
trailingTrivia: Trivia = [],
218+
presence: SourcePresence = .present
219+
) -> TokenSyntax {
220+
return floatLiteral(
221+
text,
222+
leadingTrivia: leadingTrivia,
223+
trailingTrivia: trailingTrivia,
224+
presence: presence
225+
)
226+
}
227+
208228
@available(*, deprecated, renamed: "leftSquareToken")
209229
static func leftSquareBracketToken(
210230
leadingTrivia: Trivia = [],

Sources/SwiftSyntax/generated/TokenKind.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public enum TokenKind: Hashable {
2626
case endOfFile
2727
case equal
2828
case exclamationMark
29-
case floatingLiteral(String)
29+
case floatLiteral(String)
3030
case identifier(String)
3131
case infixQuestionMark
3232
case integerLiteral(String)
@@ -92,7 +92,7 @@ public enum TokenKind: Hashable {
9292
return #"="#
9393
case .exclamationMark:
9494
return #"!"#
95-
case .floatingLiteral(let text):
95+
case .floatLiteral(let text):
9696
return text
9797
case .identifier(let text):
9898
return text
@@ -283,7 +283,7 @@ public enum TokenKind: Hashable {
283283
return true
284284
case .exclamationMark:
285285
return true
286-
case .floatingLiteral:
286+
case .floatLiteral:
287287
return false
288288
case .identifier:
289289
return false
@@ -388,7 +388,7 @@ extension TokenKind: Equatable {
388388
return true
389389
case (.exclamationMark, .exclamationMark):
390390
return true
391-
case (.floatingLiteral(let lhsText), .floatingLiteral(let rhsText)):
391+
case (.floatLiteral(let lhsText), .floatLiteral(let rhsText)):
392392
return lhsText == rhsText
393393
case (.identifier(let lhsText), .identifier(let rhsText)):
394394
return lhsText == rhsText
@@ -487,7 +487,7 @@ public enum RawTokenKind: UInt8, Equatable, Hashable {
487487
case endOfFile
488488
case equal
489489
case exclamationMark
490-
case floatingLiteral
490+
case floatLiteral
491491
case identifier
492492
case infixQuestionMark
493493
case integerLiteral
@@ -636,7 +636,7 @@ public enum RawTokenKind: UInt8, Equatable, Hashable {
636636
return true
637637
case .exclamationMark:
638638
return true
639-
case .floatingLiteral:
639+
case .floatLiteral:
640640
return false
641641
case .identifier:
642642
return false
@@ -753,8 +753,8 @@ extension TokenKind {
753753
case .exclamationMark:
754754
precondition(text.isEmpty || rawKind.defaultText.map(String.init) == text)
755755
return .exclamationMark
756-
case .floatingLiteral:
757-
return .floatingLiteral(text)
756+
case .floatLiteral:
757+
return .floatLiteral(text)
758758
case .identifier:
759759
return .identifier(text)
760760
case .infixQuestionMark:
@@ -888,8 +888,8 @@ extension TokenKind {
888888
return (.equal, nil)
889889
case .exclamationMark:
890890
return (.exclamationMark, nil)
891-
case .floatingLiteral(let str):
892-
return (.floatingLiteral, str)
891+
case .floatLiteral(let str):
892+
return (.floatLiteral, str)
893893
case .identifier(let str):
894894
return (.identifier, str)
895895
case .infixQuestionMark:

Sources/SwiftSyntax/generated/Tokens.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ extension TokenSyntax {
185185
)
186186
}
187187

188-
public static func floatingLiteral(
188+
public static func floatLiteral(
189189
_ text: String,
190190
leadingTrivia: Trivia = [],
191191
trailingTrivia: Trivia = [],
192192
presence: SourcePresence = .present
193193

194194
) -> TokenSyntax {
195195
return TokenSyntax(
196-
.floatingLiteral(text),
196+
.floatLiteral(text),
197197
leadingTrivia: leadingTrivia,
198198
trailingTrivia: trailingTrivia,
199199
presence: presence

Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
11751175
case .floatLiteralExpr:
11761176
assert(layout.count == 3)
11771177
assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self))
1178-
assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.floatingLiteral)]))
1178+
assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.floatLiteral)]))
11791179
assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self))
11801180
case .forStmt:
11811181
assert(layout.count == 21)

0 commit comments

Comments
 (0)