Skip to content

Rename TokenKind.eof to TokenKind.endOfFile #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
4 changes: 2 additions & 2 deletions Sources/SwiftBasicFormat/BasicFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ open class BasicFormat: SyntaxRewriter {
(.backslash, _),
(.backtick, _),
(.dollarIdentifier, .period), // a.b
(.eof, _),
(.endOfFile, _),
(.exclamationMark, .leftParen), // myOptionalClosure!()
(.exclamationMark, .period), // myOptionalBar!.foo()
(.extendedRegexDelimiter, .leftParen), // opening extended regex delimiter should never be separate by a space
Expand Down Expand Up @@ -254,7 +254,7 @@ open class BasicFormat: SyntaxRewriter {
(.stringSegment, _),
(_, .comma),
(_, .ellipsis),
(_, .eof),
(_, .endOfFile),
(_, .exclamationMark),
(_, .postfixOperator),
(_, .postfixQuestionMark),
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/generated/IsLexerClassified.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extension TokenKind {
@_spi(Diagnostics) @_spi(Testing)
public var isLexerClassifiedKeyword: Bool {
switch self {
case .eof:
case .endOfFile:
return false
case .poundAvailableKeyword:
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
extension TokenKind {
var nameForDiagnostics: String {
switch self {
case .eof:
case .endOfFile:
return "end of file"
case .arrow:
return #"->"#
Expand Down
14 changes: 7 additions & 7 deletions Sources/SwiftSyntax/generated/TokenKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/// Enumerates the kinds of tokens in the Swift language.
public enum TokenKind: Hashable {
case eof
case endOfFile
Copy link
Member

@TTOzzi TTOzzi Jun 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mininny 👋
The subfiles in the directory generated are automatically generated through CodeGeneration.
(For example, TokenKind.swift is generated by CodeGeneration's TokenKindFile.swift.)
You need to change the code in CodeGeneration and refer to the instructions in these documents to generate the code 🙂
https://github.com/apple/swift-syntax/blob/main/CONTRIBUTING.md#generating-source-code
https://github.com/apple/swift-syntax/blob/main/CodeGeneration/README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks! I'll rebuild the project with codegen. It's my first time contributing here so I didn't realize it. Please disregard this PR for now :)

case arrow
case atSign
case backslash
Expand Down Expand Up @@ -164,7 +164,7 @@ public enum TokenKind: Hashable {
return text
case .wildcard:
return #"_"#
case .eof:
case .endOfFile:
return ""
}
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public enum TokenKind: Hashable {
return #"""#
case .wildcard:
return #"_"#
case .eof:
case .endOfFile:
return ""
default:
return ""
Expand All @@ -259,7 +259,7 @@ public enum TokenKind: Hashable {
/// quote characters in a string literal.
public var isPunctuation: Bool {
switch self {
case .eof:
case .endOfFile:
return false
case .arrow:
return true
Expand Down Expand Up @@ -364,7 +364,7 @@ public enum TokenKind: Hashable {
extension TokenKind: Equatable {
public static func == (lhs: TokenKind, rhs: TokenKind) -> Bool {
switch (lhs, rhs) {
case (.eof, .eof):
case (.endOfFile, .endOfFile):
return true
case (.arrow, .arrow):
return true
Expand Down Expand Up @@ -720,7 +720,7 @@ extension TokenKind {
public static func fromRaw(kind rawKind: RawTokenKind, text: String) -> TokenKind {
switch rawKind {
case .eof:
return .eof
return .endOfFile
case .arrow:
precondition(text.isEmpty || rawKind.defaultText.map(String.init) == text)
return .arrow
Expand Down Expand Up @@ -863,7 +863,7 @@ extension TokenKind {
@_spi(RawSyntax)
public func decomposeToRaw() -> (rawKind: RawTokenKind, string: String?) {
switch self {
case .eof:
case .endOfFile:
return (.eof, nil)
case .arrow:
return (.arrow, nil)
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/generated/Tokens.swift
Original file line number Diff line number Diff line change
Expand Up @@ -711,12 +711,12 @@ extension TokenSyntax {
)
}

public static func eof(
public static func endOfFile(
leadingTrivia: Trivia = [],
presence: SourcePresence = .present
) -> TokenSyntax {
return TokenSyntax(
.eof,
.endOfFile,
leadingTrivia: leadingTrivia,
trailingTrivia: [],
presence: presence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self))
assertNoError(kind, 1, verify(layout[1], as: RawCodeBlockItemListSyntax.self))
assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self))
assertNoError(kind, 3, verify(layout[3], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.eof)]))
assertNoError(kind, 3, verify(layout[3], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.endOfFile)]))
assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self))
case .specializeAttributeSpecList:
for (index, element) in layout.enumerated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16327,7 +16327,7 @@ public struct SourceFileSyntax: SyntaxProtocol, SyntaxHashable {
_ unexpectedBeforeStatements: UnexpectedNodesSyntax? = nil,
statements: CodeBlockItemListSyntax,
_ unexpectedBetweenStatementsAndEOFToken: UnexpectedNodesSyntax? = nil,
eofToken: TokenSyntax = .eof(),
eofToken: TokenSyntax = .endOfFile(),
_ unexpectedAfterEOFToken: UnexpectedNodesSyntax? = nil,
trailingTrivia: Trivia? = nil

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntaxBuilder/ValidatingSyntaxNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension Trivia {
self = trivia
if pieces.contains(where: { $0.isUnexpected }) {
var diagnostics: [Diagnostic] = []
let tree = SourceFileSyntax(statements: [], eofToken: .eof(leadingTrivia: self))
let tree = SourceFileSyntax(statements: [], eofToken: .endOfFile(leadingTrivia: self))
var offset = 0
for piece in pieces {
if case .unexpectedText(let contents) = piece {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ extension SourceFileSyntax {
leadingTrivia: Trivia? = nil,
unexpectedBeforeStatements: UnexpectedNodesSyntax? = nil,
unexpectedBetweenStatementsAndEOFToken: UnexpectedNodesSyntax? = nil,
eofToken: TokenSyntax = .eof(),
eofToken: TokenSyntax = .endOfFile(),
unexpectedAfterEOFToken: UnexpectedNodesSyntax? = nil,
@CodeBlockItemListBuilder statementsBuilder: () throws -> CodeBlockItemListSyntax,
trailingTrivia: Trivia? = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extension SyntaxProtocol {
if case .keyword(let keyword) = tokenKind {
tokenInitializerName = "keyword"
tokenKindArgument = ExprSyntax(".\(raw: keyword)")
} else if tokenKind.isLexerClassifiedKeyword || tokenKind == .eof {
} else if tokenKind.isLexerClassifiedKeyword || tokenKind == .endOfFile {
tokenInitializerName = String(describing: tokenKind)
tokenKindArgument = nil
} else if tokenKind.decomposeToRaw().rawKind.defaultText != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class HashbangLibraryTests: XCTestCase {
)
)
]),
eofToken: .eof()
eofToken: .endOfFile()
)
),
options: [.substructureCheckTrivia]
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftSyntaxTest/AbsolutePositionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AbsolutePositionTests: XCTestCase {
}
let root = SourceFileSyntax(
statements: CodeBlockItemListSyntax(l),
eofToken: .eof()
eofToken: .endOfFile()
)
_ = root.statements[idx].position
_ = root.statements[idx].byteSize
Expand Down Expand Up @@ -67,7 +67,7 @@ public class AbsolutePositionTests: XCTestCase {
)
return SourceFileSyntax(
statements: CodeBlockItemListSyntax(items),
eofToken: .eof()
eofToken: .endOfFile()
)
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftSyntaxTest/DebugDescriptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public class DebugDescriptionTests: XCTestCase {
rightParen: .rightParenToken()
)))
]),
eofToken: .eof()
eofToken: .endOfFile()
)
"""
)
Expand All @@ -218,7 +218,7 @@ public class DebugDescriptionTests: XCTestCase {
rightParen: .rightParenToken()
)))
]),
eofToken: .eof()
eofToken: .endOfFile()
)
"""
)
Expand Down