Skip to content

Commit d0ba40a

Browse files
committed
Don’t generate SyntaxClassification.swift
1 parent 2b00673 commit d0ba40a

File tree

13 files changed

+40
-241
lines changed

13 files changed

+40
-241
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public let ATTRIBUTE_NODES: [Node] = [
4646
name: "AttributeName",
4747
kind: .node(kind: .type),
4848
nameForDiagnostics: "name",
49-
documentation: "The name of the attribute.",
50-
classification: "Attribute"
49+
documentation: "The name of the attribute."
5150
),
5251
Child(
5352
name: "LeftParen",
@@ -191,8 +190,7 @@ public let ATTRIBUTE_NODES: [Node] = [
191190
children: [
192191
Child(
193192
name: "AvailabilityVersionRestriction",
194-
kind: .node(kind: .availabilityVersionRestriction),
195-
classification: "Keyword"
193+
kind: .node(kind: .availabilityVersionRestriction)
196194
),
197195
Child(
198196
name: "TrailingComma",

CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ public let AVAILABILITY_NODES: [Node] = [
118118
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
119119
nameForDiagnostics: "platform",
120120
documentation:
121-
"The name of the OS on which the availability should be restricted or 'swift' if the availability should be restricted based on a Swift version.",
122-
classification: "Keyword"
121+
"The name of the OS on which the availability should be restricted or 'swift' if the availability should be restricted based on a Swift version."
123122
),
124123
Child(
125124
name: "Version",

CodeGeneration/Sources/SyntaxSupport/Child.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public class Child {
6161
public let kind: ChildKind
6262
public let nameForDiagnostics: String?
6363
public let documentation: String?
64-
public let forceClassification: Bool
6564
public let isOptional: Bool
66-
public let classification: SyntaxClassification?
6765

6866
public var syntaxNodeKind: SyntaxNodeKind {
6967
switch kind {
@@ -165,9 +163,7 @@ public class Child {
165163
kind: ChildKind,
166164
nameForDiagnostics: String? = nil,
167165
documentation: String? = nil,
168-
isOptional: Bool = false,
169-
classification: String? = nil,
170-
forceClassification: Bool = false
166+
isOptional: Bool = false
171167
) {
172168
if let firstCharInName = name.first {
173169
precondition(firstCharInName.isUppercase == true, "The first letter of a child’s name should be uppercase")
@@ -177,8 +173,6 @@ public class Child {
177173
self.kind = kind
178174
self.nameForDiagnostics = nameForDiagnostics
179175
self.documentation = documentation
180-
self.classification = classificationByName(classification)
181-
self.forceClassification = forceClassification
182176
self.isOptional = isOptional
183177
}
184178
}

CodeGeneration/Sources/SyntaxSupport/Classification.swift

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

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,7 @@ public let DECL_NODES: [Node] = [
542542
.keyword(text: "static"),
543543
.keyword(text: "unowned"),
544544
.keyword(text: "weak"),
545-
]),
546-
classification: "Attribute"
545+
])
547546
),
548547
Child(
549548
name: "Detail",
@@ -1128,15 +1127,13 @@ public let DECL_NODES: [Node] = [
11281127
children: [
11291128
Child(
11301129
name: "PoundKeyword",
1131-
kind: .token(choices: [.token(tokenKind: "PoundIfToken"), .token(tokenKind: "PoundElseifToken"), .token(tokenKind: "PoundElseToken")]),
1132-
classification: "BuildConfigId"
1130+
kind: .token(choices: [.token(tokenKind: "PoundIfToken"), .token(tokenKind: "PoundElseifToken"), .token(tokenKind: "PoundElseToken")])
11331131
),
11341132
Child(
11351133
name: "Condition",
11361134
kind: .node(kind: .expr),
11371135
nameForDiagnostics: "condition",
1138-
isOptional: true,
1139-
classification: "BuildConfigId"
1136+
isOptional: true
11401137
),
11411138
Child(
11421139
name: "Elements",
@@ -1180,8 +1177,7 @@ public let DECL_NODES: [Node] = [
11801177
),
11811178
Child(
11821179
name: "PoundEndif",
1183-
kind: .token(choices: [.token(tokenKind: "PoundEndifToken")]),
1184-
classification: "BuildConfigId"
1180+
kind: .token(choices: [.token(tokenKind: "PoundEndifToken")])
11851181
),
11861182
]
11871183
),
@@ -1597,8 +1593,7 @@ public let DECL_NODES: [Node] = [
15971593
),
15981594
Child(
15991595
name: "Identifier",
1600-
kind: .token(choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")]),
1601-
classification: "OperatorIdentifier"
1596+
kind: .token(choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")])
16021597
),
16031598
Child(
16041599
name: "OperatorPrecedenceAndTypes",
@@ -1820,8 +1815,7 @@ public let DECL_NODES: [Node] = [
18201815
Child(
18211816
name: "AssociativityLabel",
18221817
deprecatedName: "AssociativityKeyword",
1823-
kind: .token(choices: [.keyword(text: "associativity")]),
1824-
classification: "Keyword"
1818+
kind: .token(choices: [.keyword(text: "associativity")])
18251819
),
18261820
Child(
18271821
name: "Colon",
@@ -1938,8 +1932,7 @@ public let DECL_NODES: [Node] = [
19381932
name: "HigherThanOrLowerThanLabel",
19391933
deprecatedName: "HigherThanOrLowerThan",
19401934
kind: .token(choices: [.keyword(text: "higherThan"), .keyword(text: "lowerThan")]),
1941-
documentation: "The relation to specified other precedence groups.",
1942-
classification: "Keyword"
1935+
documentation: "The relation to specified other precedence groups."
19431936
),
19441937
Child(
19451938
name: "Colon",

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -740,19 +740,15 @@ public let EXPR_NODES: [Node] = [
740740
),
741741
Child(
742742
name: "LeftParen",
743-
kind: .token(choices: [.token(tokenKind: "LeftParenToken")]),
744-
classification: "StringInterpolationAnchor",
745-
forceClassification: true
743+
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
746744
),
747745
Child(
748746
name: "Expressions",
749747
kind: .collection(kind: .tupleExprElementList, collectionElementName: "Expression")
750748
),
751749
Child(
752750
name: "RightParen",
753-
kind: .token(choices: [.token(tokenKind: "RightParenToken")]),
754-
classification: "StringInterpolationAnchor",
755-
forceClassification: true
751+
kind: .token(choices: [.token(tokenKind: "RightParenToken")])
756752
),
757753
]
758754
),

CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class TokenSpec {
1515
public let name: String
1616
public let nameForDiagnostics: String
1717
public let text: String?
18-
public let classification: SyntaxClassification?
1918
public let isKeyword: Bool
2019
public let associatedValueClass: String?
2120

@@ -33,14 +32,12 @@ public class TokenSpec {
3332
name: String,
3433
nameForDiagnostics: String,
3534
text: String? = nil,
36-
classification: String = "None",
3735
isKeyword: Bool = false,
3836
associatedValueClass: String? = nil
3937
) {
4038
self.name = name
4139
self.nameForDiagnostics = nameForDiagnostics
4240
self.text = text
43-
self.classification = classificationByName(classification)
4441
self.isKeyword = isKeyword
4542
self.associatedValueClass = associatedValueClass
4643
}
@@ -50,14 +47,12 @@ public class PoundKeywordSpec: TokenSpec {
5047
init(
5148
name: String,
5249
nameForDiagnostics: String? = nil,
53-
text: String,
54-
classification: String = "Keyword"
50+
text: String
5551
) {
5652
super.init(
5753
name: name,
5854
nameForDiagnostics: nameForDiagnostics ?? text,
5955
text: text,
60-
classification: classification,
6156
isKeyword: true
6257
)
6358
}
@@ -69,16 +64,14 @@ public class PoundObjectLiteralSpec: PoundKeywordSpec {
6964
init(
7065
name: String,
7166
text: String,
72-
classification: String = "ObjectLiteral",
7367
nameForDiagnostics: String,
7468
`protocol`: String
7569
) {
7670
self.`protocol` = `protocol`
7771
super.init(
7872
name: name,
7973
nameForDiagnostics: nameForDiagnostics,
80-
text: text,
81-
classification: classification
74+
text: text
8275
)
8376
}
8477
}
@@ -88,42 +81,36 @@ public class PoundConfigSpec: PoundKeywordSpec {}
8881
public class PoundDirectiveKeywordSpec: PoundKeywordSpec {
8982
init(
9083
name: String,
91-
text: String,
92-
classification: String = "PoundDirectiveKeyword"
84+
text: String
9385
) {
9486
super.init(
9587
name: name,
96-
text: text,
97-
classification: classification
88+
text: text
9889
)
9990
}
10091
}
10192

10293
public class PoundConditionalDirectiveKeywordSpec: PoundDirectiveKeywordSpec {
10394
override init(
10495
name: String,
105-
text: String,
106-
classification: String = "PoundDirectiveKeyword"
96+
text: String
10797
) {
10898
super.init(
10999
name: name,
110-
text: text,
111-
classification: classification
100+
text: text
112101
)
113102
}
114103
}
115104

116105
public class PunctuatorSpec: TokenSpec {
117106
init(
118107
name: String,
119-
text: String,
120-
classification: String = "None"
108+
text: String
121109
) {
122110
super.init(
123111
name: name,
124112
nameForDiagnostics: text,
125113
text: text,
126-
classification: classification,
127114
isKeyword: false
128115
)
129116
}
@@ -135,30 +122,30 @@ public class MiscSpec: TokenSpec {}
135122

136123
public let SYNTAX_TOKENS: [TokenSpec] = [
137124
PunctuatorSpec(name: "Arrow", text: "->"),
138-
PunctuatorSpec(name: "AtSign", text: "@", classification: "Attribute"),
125+
PunctuatorSpec(name: "AtSign", text: "@"),
139126
PunctuatorSpec(name: "Backslash", text: "\\"),
140127
PunctuatorSpec(name: "Backtick", text: "`"),
141-
MiscSpec(name: "BinaryOperator", nameForDiagnostics: "binary operator", classification: "OperatorIdentifier"),
128+
MiscSpec(name: "BinaryOperator", nameForDiagnostics: "binary operator"),
142129
PunctuatorSpec(name: "Colon", text: ":"),
143130
PunctuatorSpec(name: "Comma", text: ","),
144-
MiscSpec(name: "DollarIdentifier", nameForDiagnostics: "dollar identifier", classification: "DollarIdentifier"),
131+
MiscSpec(name: "DollarIdentifier", nameForDiagnostics: "dollar identifier"),
145132
PunctuatorSpec(name: "Ellipsis", text: "..."),
146133
MiscSpec(name: "EndOfFile", nameForDiagnostics: "end of file", text: ""),
147134
PunctuatorSpec(name: "Equal", text: "="),
148135
PunctuatorSpec(name: "ExclamationMark", text: "!"),
149-
MiscSpec(name: "ExtendedRegexDelimiter", nameForDiagnostics: "extended delimiter", classification: "RegexLiteral"),
150-
LiteralSpec(name: "FloatingLiteral", nameForDiagnostics: "floating literal", classification: "FloatingLiteral"),
151-
MiscSpec(name: "Identifier", nameForDiagnostics: "identifier", classification: "Identifier"),
136+
MiscSpec(name: "ExtendedRegexDelimiter", nameForDiagnostics: "extended delimiter"),
137+
LiteralSpec(name: "FloatingLiteral", nameForDiagnostics: "floating literal"),
138+
MiscSpec(name: "Identifier", nameForDiagnostics: "identifier"),
152139
PunctuatorSpec(name: "InfixQuestionMark", text: "?"),
153-
LiteralSpec(name: "IntegerLiteral", nameForDiagnostics: "integer literal", classification: "IntegerLiteral"),
154-
MiscSpec(name: "Keyword", nameForDiagnostics: "keyword", classification: "Keyword", associatedValueClass: "Keyword"),
140+
LiteralSpec(name: "IntegerLiteral", nameForDiagnostics: "integer literal"),
141+
MiscSpec(name: "Keyword", nameForDiagnostics: "keyword", associatedValueClass: "Keyword"),
155142
PunctuatorSpec(name: "LeftAngle", text: "<"),
156143
PunctuatorSpec(name: "LeftBrace", text: "{"),
157144
PunctuatorSpec(name: "LeftParen", text: "("),
158145
PunctuatorSpec(name: "LeftSquare", text: "["),
159-
PunctuatorSpec(name: "MultilineStringQuote", text: "\"\"\"", classification: "StringLiteral"),
146+
PunctuatorSpec(name: "MultilineStringQuote", text: "\"\"\""),
160147
PunctuatorSpec(name: "Period", text: "."),
161-
MiscSpec(name: "PostfixOperator", nameForDiagnostics: "postfix operator", classification: "OperatorIdentifier"),
148+
MiscSpec(name: "PostfixOperator", nameForDiagnostics: "postfix operator"),
162149
PunctuatorSpec(name: "PostfixQuestionMark", text: "?"),
163150
PunctuatorSpec(name: "Pound", text: "#"),
164151
PoundConfigSpec(name: "PoundAvailable", text: "#available"),
@@ -169,18 +156,18 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
169156
PoundDirectiveKeywordSpec(name: "PoundSourceLocation", text: "#sourceLocation"),
170157
PoundConfigSpec(name: "PoundUnavailable", text: "#unavailable"),
171158
PunctuatorSpec(name: "PrefixAmpersand", text: "&"),
172-
MiscSpec(name: "PrefixOperator", nameForDiagnostics: "prefix operator", classification: "OperatorIdentifier"),
159+
MiscSpec(name: "PrefixOperator", nameForDiagnostics: "prefix operator"),
173160
MiscSpec(name: "RawStringDelimiter", nameForDiagnostics: "raw string delimiter"),
174-
MiscSpec(name: "RegexLiteralPattern", nameForDiagnostics: "regex pattern", classification: "RegexLiteral"),
175-
PunctuatorSpec(name: "RegexSlash", text: "/", classification: "RegexLiteral"),
161+
MiscSpec(name: "RegexLiteralPattern", nameForDiagnostics: "regex pattern"),
162+
PunctuatorSpec(name: "RegexSlash", text: "/"),
176163
PunctuatorSpec(name: "RightAngle", text: ">"),
177164
PunctuatorSpec(name: "RightBrace", text: "}"),
178165
PunctuatorSpec(name: "RightParen", text: ")"),
179166
PunctuatorSpec(name: "RightSquare", text: "]"),
180167
PunctuatorSpec(name: "Semicolon", text: ";"),
181-
PunctuatorSpec(name: "SingleQuote", text: "\'", classification: "StringLiteral"),
182-
PunctuatorSpec(name: "StringQuote", text: "\"", classification: "StringLiteral"),
183-
MiscSpec(name: "StringSegment", nameForDiagnostics: "string segment", classification: "StringLiteral"),
168+
PunctuatorSpec(name: "SingleQuote", text: "\'"),
169+
PunctuatorSpec(name: "StringQuote", text: "\""),
170+
MiscSpec(name: "StringSegment", nameForDiagnostics: "string segment"),
184171
MiscSpec(name: "Unknown", nameForDiagnostics: "token"),
185172
MiscSpec(name: "Wildcard", nameForDiagnostics: "wildcard", text: "_"),
186173
]

0 commit comments

Comments
 (0)