Skip to content

Remove __FILE__ et al as keywords and syntax nodes. #1135

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

Merged
merged 5 commits into from
Dec 12, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -229,72 +229,6 @@ public let EXPR_NODES: [Node] = [
element: "Expr",
elementName: "Expression"),

Node(name: "PoundLineExpr",
nameForDiagnostics: nil,
kind: "Expr",
children: [
Child(name: "PoundLine",
kind: "PoundLineToken",
tokenChoices: [
"PoundLine"
])
]),

Node(name: "PoundFileExpr",
nameForDiagnostics: nil,
kind: "Expr",
children: [
Child(name: "PoundFile",
kind: "PoundFileToken",
tokenChoices: [
"PoundFile"
])
]),

Node(name: "PoundFileIDExpr",
nameForDiagnostics: nil,
kind: "Expr",
children: [
Child(name: "PoundFileID",
kind: "PoundFileIDToken",
tokenChoices: [
"PoundFileID"
])
]),

Node(name: "PoundFilePathExpr",
nameForDiagnostics: nil,
kind: "Expr",
children: [
Child(name: "PoundFilePath",
kind: "PoundFilePathToken",
tokenChoices: [
"PoundFilePath"
])
]),

Node(name: "PoundFunctionExpr",
nameForDiagnostics: nil,
kind: "Expr",
children: [
Child(name: "PoundFunction",
kind: "PoundFunctionToken",
tokenChoices: [
"PoundFunction"
])
]),

Node(name: "PoundDsohandleExpr",
nameForDiagnostics: nil,
kind: "Expr",
children: [
Child(name: "PoundDsohandle",
kind: "PoundDsohandleToken",
tokenChoices: [
"PoundDsohandle"
])
]),

Node(name: "SymbolicReferenceExpr",
nameForDiagnostics: nil,
kind: "Expr",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
ExprKeywordSpec(name: "True", text: "true"),
ExprKeywordSpec(name: "Try", text: "try", requiresTrailingSpace: true),
ExprKeywordSpec(name: "Throws", text: "throws", requiresTrailingSpace: true),
KeywordSpec(name: "__FILE__", text: "__FILE__", requiresTrailingSpace: true),
KeywordSpec(name: "__LINE__", text: "__LINE__", requiresTrailingSpace: true),
KeywordSpec(name: "__COLUMN__", text: "__COLUMN__", requiresTrailingSpace: true),
KeywordSpec(name: "__FUNCTION__", text: "__FUNCTION__", requiresTrailingSpace: true),
KeywordSpec(name: "__DSO_HANDLE__", text: "__DSO_HANDLE__", requiresTrailingSpace: true),
PatternKeywordSpec(name: "Wildcard", text: "_", requiresTrailingSpace: true),
PunctuatorSpec(name: "LeftParen", kind: "l_paren", text: "("),
PunctuatorSpec(name: "RightParen", kind: "r_paren", text: ")"),
Expand Down
10 changes: 0 additions & 10 deletions Sources/IDEUtils/generated/SyntaxClassification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,6 @@ extension RawTokenKind {
return .keyword
case .throwsKeyword:
return .keyword
case .__file__Keyword:
return .keyword
case .__line__Keyword:
return .keyword
case .__column__Keyword:
return .keyword
case .__function__Keyword:
return .keyword
case .__dso_handle__Keyword:
return .keyword
case .wildcardKeyword:
return .keyword
case .leftParen:
Expand Down
10 changes: 0 additions & 10 deletions Sources/SwiftBasicFormat/generated/BasicFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,6 @@ open class BasicFormat: SyntaxRewriter {
return true
case .throwsKeyword:
return true
case .__file__Keyword:
return true
case .__line__Keyword:
return true
case .__column__Keyword:
return true
case .__function__Keyword:
return true
case .__dso_handle__Keyword:
return true
case .wildcardKeyword:
return true
case .leftAngle:
Expand Down
30 changes: 0 additions & 30 deletions Sources/SwiftParser/Expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1009,36 +1009,6 @@ extension Parser {
booleanLiteral: tok,
arena: self.arena
))
case (.__file__Keyword, let handle)?:
let tok = self.eat(handle)
return RawExprSyntax(RawPoundFileExprSyntax(
poundFile: tok,
arena: self.arena
))
case (.__function__Keyword, let handle)?:
let tok = self.eat(handle)
return RawExprSyntax(RawPoundFunctionExprSyntax(
poundFunction: tok,
arena: self.arena
))
case (.__line__Keyword, let handle)?:
let tok = self.eat(handle)
return RawExprSyntax(RawPoundLineExprSyntax(
poundLine: tok,
arena: self.arena
))
case (.__column__Keyword, let handle)?:
let tok = self.eat(handle)
return RawExprSyntax(RawPoundColumnExprSyntax(
poundColumn: tok,
arena: self.arena
))
case (.__dso_handle__Keyword, let handle)?:
let tok = self.eat(handle)
return RawExprSyntax(RawPoundDsohandleExprSyntax(
poundDsohandle: tok,
arena: self.arena
))
case (.identifier, let handle)?, (.selfKeyword, let handle)?, (.initKeyword, let handle)?:
// If we have "case let x." or "case let x(", we parse x as a normal
// name, not a binding, because it is the start of an enum pattern or
Expand Down
15 changes: 0 additions & 15 deletions Sources/SwiftParser/RawTokenKindSubset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,6 @@ enum ParameterModifier: RawTokenKindSubset {
}

enum PrimaryExpressionStart: RawTokenKindSubset {
case __column__Keyword
case __dso_handle__Keyword
case __file__Keyword
case __function__Keyword
case __line__Keyword
case anyKeyword
case capitalSelfKeyword
case dollarIdentifier
Expand All @@ -710,11 +705,6 @@ enum PrimaryExpressionStart: RawTokenKindSubset {

init?(lexeme: Lexer.Lexeme) {
switch lexeme.tokenKind {
case .__column__Keyword: self = .__column__Keyword
case .__dso_handle__Keyword: self = .__dso_handle__Keyword
case .__file__Keyword: self = .__file__Keyword
case .__function__Keyword: self = .__function__Keyword
case .__line__Keyword: self = .__line__Keyword
case .anyKeyword: self = .anyKeyword
case .capitalSelfKeyword: self = .capitalSelfKeyword
case .dollarIdentifier: self = .dollarIdentifier
Expand Down Expand Up @@ -742,11 +732,6 @@ enum PrimaryExpressionStart: RawTokenKindSubset {

var rawTokenKind: SwiftSyntax.RawTokenKind {
switch self {
case .__column__Keyword: return .__column__Keyword
case .__dso_handle__Keyword: return .__dso_handle__Keyword
case .__file__Keyword: return .__file__Keyword
case .__function__Keyword: return .__function__Keyword
case .__line__Keyword: return .__line__Keyword
case .anyKeyword: return .anyKeyword
case .capitalSelfKeyword: return .capitalSelfKeyword
case .dollarIdentifier: return .dollarIdentifier
Expand Down
2 changes: 0 additions & 2 deletions Sources/SwiftParser/TokenPrecedence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ public enum TokenPrecedence: Comparable {
case
// Literals
.capitalSelfKeyword, .falseKeyword, .floatingLiteral, .integerLiteral, .nilKeyword, .regexLiteral, .selfKeyword, .stringLiteral, .superKeyword, .trueKeyword,
// Legacy literals
.__column__Keyword, .__dso_handle__Keyword, .__file__Keyword, .__function__Keyword, .__line__Keyword,
// Pound literals
.poundAvailableKeyword, .poundColorLiteralKeyword, .poundColumnKeyword, .poundDsohandleKeyword, .poundFileIDKeyword, .poundFileKeyword, .poundFileLiteralKeyword, .poundFilePathKeyword, .poundFunctionKeyword, .poundImageLiteralKeyword, .poundKeyPathKeyword, .poundLineKeyword, .poundSelectorKeyword, .poundSourceLocationKeyword, .poundUnavailableKeyword, .poundHasSymbolKeyword,
// Identifiers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ allows Swift tools to parse, inspect, generate, and transform Swift source code.
- <doc:SwiftSyntax/DiscardAssignmentExprSyntax>
- <doc:SwiftSyntax/AssignmentExprSyntax>
- <doc:SwiftSyntax/SequenceExprSyntax>
- <doc:SwiftSyntax/PoundLineExprSyntax>
- <doc:SwiftSyntax/PoundFileExprSyntax>
- <doc:SwiftSyntax/PoundFileIDExprSyntax>
- <doc:SwiftSyntax/PoundFilePathExprSyntax>
- <doc:SwiftSyntax/PoundFunctionExprSyntax>
- <doc:SwiftSyntax/PoundDsohandleExprSyntax>
- <doc:SwiftSyntax/SymbolicReferenceExprSyntax>
- <doc:SwiftSyntax/PrefixOperatorExprSyntax>
- <doc:SwiftSyntax/BinaryOperatorExprSyntax>
Expand Down
Loading