Skip to content

Commit 11b9042

Browse files
authored
Merge pull request #1983 from ahoppen/ahoppen/renames-again
Some more renames of syntax nodes
2 parents aa54b10 + a2cf2df commit 11b9042

34 files changed

+205
-123
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ public let ATTRIBUTE_NODES: [Node] = [
190190
traits: ["WithTrailingComma"],
191191
children: [
192192
Child(
193-
name: "AvailabilityVersionRestriction",
193+
name: "PlatformVersion",
194+
deprecatedName: "AvailabilityVersionRestriction",
194195
kind: .node(kind: .platformVersion)
195196
),
196197
Child(

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 2 additions & 3 deletions
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
),
@@ -1384,8 +1384,7 @@ public let EXPR_NODES: [Node] = [
13841384
Child(
13851385
name: "Operator",
13861386
deprecatedName: "OperatorToken",
1387-
kind: .token(choices: [.token(tokenKind: "PrefixOperatorToken")]),
1388-
isOptional: true
1387+
kind: .token(choices: [.token(tokenKind: "PrefixOperatorToken")])
13891388
),
13901389
Child(
13911390
name: "Expression",

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: 9 additions & 4 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 {
@@ -65,7 +70,7 @@ extension SyntaxClassification {
6570
switch keyPath {
6671
case \AttributeSyntax.attributeName:
6772
return (.attribute, true)
68-
case \PlatformVersionItemSyntax.availabilityVersionRestriction:
73+
case \PlatformVersionItemSyntax.platformVersion:
6974
return (.keyword, false)
7075
case \AvailabilityVersionRestrictionSyntax.platform:
7176
return (.keyword, false)
@@ -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/Attributes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ extension Parser {
865865
keepGoing = self.consume(if: .comma)
866866
elements.append(
867867
RawPlatformVersionItemSyntax(
868-
availabilityVersionRestriction: versionRestriction,
868+
platformVersion: versionRestriction,
869869
trailingComma: keepGoing,
870870
arena: self.arena
871871
)
@@ -925,7 +925,7 @@ extension Parser {
925925
keepGoing = self.consume(if: .comma)
926926
platforms.append(
927927
RawPlatformVersionItemSyntax(
928-
availabilityVersionRestriction: restriction,
928+
platformVersion: restriction,
929929
trailingComma: keepGoing,
930930
arena: self.arena
931931
)

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/IncrementalParseTransition.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension Parser {
3535
}
3636
}
3737

38-
/// Accepts a re-used ``Syntax`` node that `IncrementalParseTransition`
38+
/// Accepts a re-used `Syntax` node that `IncrementalParseTransition`
3939
/// determined they should be re-used for a parse invocation.
4040
///
4141
/// The client can use this information to potentially avoid unnecessary work

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/ParseDiagnosticsGenerator.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
10431043
addDiagnostic(unexpected, UnknownDirectiveError(unexpected: unexpected), handledNodes: [unexpected.id, node.baseName.id])
10441044
} else if let availability = unexpected.first?.as(AvailabilityConditionSyntax.self) {
10451045
if let prefixOperatorExpr = node.parent?.as(PrefixOperatorExprSyntax.self),
1046-
let operatorToken = prefixOperatorExpr.operator,
1047-
operatorToken.text == "!",
1046+
prefixOperatorExpr.operator.text == "!",
10481047
let conditionElement = prefixOperatorExpr.parent?.as(ConditionElementSyntax.self)
10491048
{
10501049
// Diagnose !#available(...) and !#unavailable(...)
@@ -1059,7 +1058,10 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
10591058
NegatedAvailabilityCondition(availabilityCondition: availability, negatedAvailabilityKeyword: negatedAvailabilityKeyword),
10601059
fixIts: [
10611060
FixIt(
1062-
message: ReplaceTokensFixIt(replaceTokens: [operatorToken, availability.availabilityKeyword], replacements: [negatedAvailabilityKeyword]),
1061+
message: ReplaceTokensFixIt(
1062+
replaceTokens: [prefixOperatorExpr.operator, availability.availabilityKeyword],
1063+
replacements: [negatedAvailabilityKeyword]
1064+
),
10631065
changes: [
10641066
.replace(oldNode: Syntax(conditionElement), newNode: Syntax(negatedConditionElement))
10651067
]

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
@@ -150,6 +150,11 @@ public extension TokenKind {
150150
return .regexPoundDelimiter(text)
151151
}
152152

153+
@available(*, deprecated, renamed: "floatLiteral")
154+
static func floatingLiteral(_ text: String) -> TokenKind {
155+
return .floatLiteral(text)
156+
}
157+
153158
@available(*, deprecated, renamed: "leftSquare")
154159
static var leftSquareBracket: TokenKind {
155160
return .leftSquare
@@ -220,6 +225,21 @@ public extension TokenSyntax {
220225
)
221226
}
222227

228+
@available(*, deprecated, renamed: "floatLiteral")
229+
static func floatingLiteral(
230+
_ text: String,
231+
leadingTrivia: Trivia = [],
232+
trailingTrivia: Trivia = [],
233+
presence: SourcePresence = .present
234+
) -> TokenSyntax {
235+
return floatLiteral(
236+
text,
237+
leadingTrivia: leadingTrivia,
238+
trailingTrivia: trailingTrivia,
239+
presence: presence
240+
)
241+
}
242+
223243
@available(*, deprecated, renamed: "leftSquareToken")
224244
static func leftSquareBracketToken(
225245
leadingTrivia: Trivia = [],

Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,12 +2437,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
24372437
return "pattern"
24382438
case \PatternExprSyntax.unexpectedAfterPattern:
24392439
return "unexpectedAfterPattern"
2440-
case \PlatformVersionItemSyntax.unexpectedBeforeAvailabilityVersionRestriction:
2441-
return "unexpectedBeforeAvailabilityVersionRestriction"
2442-
case \PlatformVersionItemSyntax.availabilityVersionRestriction:
2443-
return "availabilityVersionRestriction"
2444-
case \PlatformVersionItemSyntax.unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma:
2445-
return "unexpectedBetweenAvailabilityVersionRestrictionAndTrailingComma"
2440+
case \PlatformVersionItemSyntax.unexpectedBeforePlatformVersion:
2441+
return "unexpectedBeforePlatformVersion"
2442+
case \PlatformVersionItemSyntax.platformVersion:
2443+
return "platformVersion"
2444+
case \PlatformVersionItemSyntax.unexpectedBetweenPlatformVersionAndTrailingComma:
2445+
return "unexpectedBetweenPlatformVersionAndTrailingComma"
24462446
case \PlatformVersionItemSyntax.trailingComma:
24472447
return "trailingComma"
24482448
case \PlatformVersionItemSyntax.unexpectedAfterTrailingComma:

0 commit comments

Comments
 (0)