Skip to content

Commit e10d848

Browse files
committed
Move code from Misc.swift to other files
Nobody loves files whose best description is “miscellaneous”.
1 parent b80213d commit e10d848

File tree

9 files changed

+851
-888
lines changed

9 files changed

+851
-888
lines changed

CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ struct GenerateSwiftSyntax: ParsableCommand {
9999

100100
// SwiftSyntax
101101
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["Keyword.swift"], keywordFile),
102-
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["Misc.swift"], miscFile),
103102
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["raw", "RawSyntaxNodes.swift"], rawSyntaxNodesFile),
104103
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["raw", "RawSyntaxValidation.swift"], rawSyntaxValidationFile),
105104
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["SyntaxAnyVisitor.swift"], syntaxAnyVisitorFile),

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/MiscFile.swift

Lines changed: 0 additions & 54 deletions
This file was deleted.

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,25 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
246246
"""
247247
)
248248
}
249+
250+
try! ExtensionDeclSyntax("extension Syntax") {
251+
try VariableDeclSyntax("public static var structure: SyntaxNodeStructure") {
252+
let choices = ArrayExprSyntax {
253+
ArrayElementSyntax(
254+
leadingTrivia: .newline,
255+
expression: ExprSyntax(".node(TokenSyntax.self)")
256+
)
257+
258+
for node in NON_BASE_SYNTAX_NODES {
259+
ArrayElementSyntax(
260+
leadingTrivia: .newline,
261+
expression: ExprSyntax(".node(\(raw: node.name).self)")
262+
)
263+
}
264+
}
265+
266+
StmtSyntax("return .choices(\(choices))")
267+
}
268+
}
269+
249270
}

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,19 @@ let syntaxKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
5555
}
5656
}
5757
}
58+
59+
try VariableDeclSyntax("public var syntaxNodeType: SyntaxProtocol.Type") {
60+
try SwitchExprSyntax("switch self") {
61+
SwitchCaseSyntax("case .token:") {
62+
StmtSyntax("return TokenSyntax.self")
63+
}
64+
65+
for node in NON_BASE_SYNTAX_NODES {
66+
SwitchCaseSyntax("case .\(raw: node.swiftSyntaxKind):") {
67+
StmtSyntax("return \(raw: node.name).self")
68+
}
69+
}
70+
}
71+
}
5872
}
5973
}

Sources/SwiftSyntax/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ add_swift_host_library(SwiftSyntax
3535
generated/raw/RawSyntaxValidation.swift
3636

3737
generated/Keyword.swift
38-
generated/Misc.swift
3938
generated/SyntaxAnyVisitor.swift
4039
generated/SyntaxBaseNodes.swift
4140
generated/SyntaxCollections.swift

0 commit comments

Comments
 (0)