Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public let ATTRIBUTE_NODES: [Node] = [
traits: ["WithTrailingComma"],
children: [
Child(
name: "AvailabilityVersionRestriction",
name: "PlatformVersion",
deprecatedName: "AvailabilityVersionRestriction",
kind: .node(kind: .platformVersion)
),
Child(
Expand Down
5 changes: 2 additions & 3 deletions CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
)
]
),
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
13 changes: 9 additions & 4 deletions Sources/SwiftIDEUtils/SyntaxClassification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand All @@ -65,7 +70,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)
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftParser/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ extension Parser {
keepGoing = self.consume(if: .comma)
elements.append(
RawPlatformVersionItemSyntax(
availabilityVersionRestriction: versionRestriction,
platformVersion: versionRestriction,
trailingComma: keepGoing,
arena: self.arena
)
Expand Down Expand Up @@ -974,7 +974,7 @@ extension Parser {
keepGoing = self.consume(if: .comma)
platforms.append(
RawPlatformVersionItemSyntax(
availabilityVersionRestriction: restriction,
platformVersion: restriction,
trailingComma: keepGoing,
arena: self.arena
)
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftParser/Availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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..<periodIndex].allSatisfy({ Unicode.Scalar($0).isDigit })
{
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftParser/Expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ extension Parser {
arena: self.arena
)
)
case (.floatingLiteral, let handle)?:
case (.floatLiteral, let handle)?:
let literal = self.eat(handle)
return RawExprSyntax(
RawFloatLiteralExprSyntax(
Expand Down Expand Up @@ -1186,7 +1186,7 @@ extension Parser {
return RawExprSyntax(
RawFloatLiteralExprSyntax(
literal: RawTokenSyntax(
missing: .floatingLiteral,
missing: .floatLiteral,
text: text,
arena: self.arena
),
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/IncrementalParseTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Sources/SwiftParser/Lexer/Cursor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ extension Lexer.Cursor {
let errorPos = tmp
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
return Lexer.Result(
.floatingLiteral,
.floatLiteral,
error: LexingDiagnostic(errorKind, position: errorPos)
)
}
Expand All @@ -1419,13 +1419,13 @@ 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)
}

mutating func lexHexNumber() -> Lexer.Result {
Expand Down Expand Up @@ -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)
)
}
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/Lexer/RegexLiteralLexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/TokenPrecedence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ enum TokenPrecedence: Comparable {
self = .unknownToken
// MARK: Identifier like
case // Literals
.floatingLiteral, .integerLiteral,
.floatLiteral, .integerLiteral,
// Pound literals
.poundAvailable, .poundSourceLocation, .poundUnavailable,
// Identifiers
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/TokenSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftParser/TokenSpecSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ enum PrimaryExpressionStart: TokenSpecSet {
case `Self`
case dollarIdentifier
case `false`
case floatingLiteral
case floatLiteral
case identifier
case `init`
case integerLiteral
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftParser/generated/TokenSpecStaticMembers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)
Expand All @@ -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))
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = [],
Expand Down
12 changes: 6 additions & 6 deletions Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading