Skip to content

Commit 8ceafa7

Browse files
committed
Remove the DeclName nod in favor of IdentifierExprSyntax
`DeclName` was only used for attributes and has the same structure as `IdentifierExprSyntax`. Let’s use `IdentifierExprSyntax` instead.
1 parent e0ee126 commit 8ceafa7

21 files changed

+31
-489
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -295,35 +295,6 @@ public let ATTRIBUTE_NODES: [Node] = [
295295
]
296296
),
297297

298-
Node(
299-
kind: .declName,
300-
base: .syntax,
301-
nameForDiagnostics: "declaration name",
302-
children: [
303-
Child(
304-
name: "BaseName",
305-
deprecatedName: "DeclBaseName",
306-
kind: .token(choices: [
307-
.token(tokenKind: "IdentifierToken"),
308-
.token(tokenKind: "BinaryOperatorToken"),
309-
.keyword(text: "init"),
310-
.keyword(text: "self"),
311-
.keyword(text: "Self"),
312-
]),
313-
nameForDiagnostics: "base name",
314-
documentation: "The base name of the protocol's requirement."
315-
),
316-
Child(
317-
name: "Arguments",
318-
deprecatedName: "DeclNameArguments",
319-
kind: .node(kind: .declNameArguments),
320-
nameForDiagnostics: "arguments",
321-
documentation: "The argument labels of the protocol's requirement if it is a function requirement.",
322-
isOptional: true
323-
),
324-
]
325-
),
326-
327298
// The argument of the derivative registration attribute
328299
// '@derivative(of: ...)' and the transpose registration attribute
329300
// '@transpose(of: ...)'.
@@ -591,7 +562,7 @@ public let ATTRIBUTE_NODES: [Node] = [
591562
Child(
592563
name: "DeclName",
593564
deprecatedName: "Declname",
594-
kind: .node(kind: .declName)
565+
kind: .node(kind: .identifierExpr)
595566
),
596567
]
597568
),
@@ -872,7 +843,7 @@ public let ATTRIBUTE_NODES: [Node] = [
872843
Child(
873844
name: "DeclName",
874845
deprecatedName: "Declname",
875-
kind: .node(kind: .declName),
846+
kind: .node(kind: .identifierExpr),
876847
nameForDiagnostics: "declaration name",
877848
documentation: "The value for this argument"
878849
),

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public enum SyntaxNodeKind: String, CaseIterable {
8484
case declModifier
8585
case declModifierDetail
8686
case declModifierList
87-
case declName
8887
case declNameArgument
8988
case declNameArgumentList
9089
case declNameArguments

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,6 @@ class ValidateSyntaxNodes: XCTestCase {
464464
message:
465465
"child 'Arguments' is named inconsistently with 'IdentifierExprSyntax.DeclNameArguments', which has the same type ('DeclNameArgumentsSyntax')"
466466
),
467-
ValidationFailure(
468-
node: .declName,
469-
message:
470-
"child 'Arguments' is named inconsistently with 'IdentifierExprSyntax.DeclNameArguments', which has the same type ('DeclNameArgumentsSyntax')"
471-
),
472467
// MARK: Alternate names for InitializerClauseSyntax
473468
// The cases below don’t have intializers but just a syntactic element that happens to be spelled the same
474469
ValidationFailure(

Sources/SwiftParser/Attributes.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,9 @@ extension Parser {
682682
let ident = self.eat(handle)
683683
let (unexpectedBeforeColon, colon) = self.expect(.colon)
684684
let (targetFunction, args) = self.parseDeclNameRef([.zeroArgCompoundNames, .keywordsUsingSpecialNames, .operators])
685-
let declName = RawDeclNameSyntax(
686-
baseName: targetFunction,
687-
arguments: args,
685+
let declName = RawIdentifierExprSyntax(
686+
identifier: targetFunction,
687+
declNameArguments: args,
688688
arena: self.arena
689689
)
690690
let comma = self.consume(if: .comma)
@@ -1031,7 +1031,7 @@ extension Parser {
10311031
.zeroArgCompoundNames, .keywordsUsingSpecialNames, .operators,
10321032
])
10331033
}
1034-
let method = RawDeclNameSyntax(baseName: base, arguments: args, arena: self.arena)
1034+
let method = RawIdentifierExprSyntax(identifier: base, declNameArguments: args, arena: self.arena)
10351035
return RawDynamicReplacementAttributeArgumentsSyntax(
10361036
unexpectedBeforeLabel,
10371037
forLabel: label,

Sources/SwiftParser/generated/Parser+TokenSpecSet.swift

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -652,48 +652,6 @@ extension DeclModifierSyntax {
652652
}
653653
}
654654

655-
extension DeclNameSyntax {
656-
enum BaseNameOptions: TokenSpecSet {
657-
case identifier
658-
case binaryOperator
659-
case `init`
660-
case `self`
661-
case `Self`
662-
663-
init?(lexeme: Lexer.Lexeme) {
664-
switch PrepareForKeywordMatch(lexeme) {
665-
case TokenSpec(.identifier):
666-
self = .identifier
667-
case TokenSpec(.binaryOperator):
668-
self = .binaryOperator
669-
case TokenSpec(.`init`):
670-
self = .`init`
671-
case TokenSpec(.`self`):
672-
self = .`self`
673-
case TokenSpec(.`Self`):
674-
self = .`Self`
675-
default:
676-
return nil
677-
}
678-
}
679-
680-
var spec: TokenSpec {
681-
switch self {
682-
case .identifier:
683-
return .identifier
684-
case .binaryOperator:
685-
return .binaryOperator
686-
case .`init`:
687-
return .keyword(.`init`)
688-
case .`self`:
689-
return .keyword(.`self`)
690-
case .`Self`:
691-
return .keyword(.`Self`)
692-
}
693-
}
694-
}
695-
}
696-
697655
extension DerivativeAttributeArgumentsSyntax {
698656
enum AccessorSpecifierOptions: TokenSpecSet {
699657
case get

Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String? {
7878
return "statements"
7979
case \ContinueStmtSyntax.label:
8080
return "label"
81-
case \DeclNameSyntax.baseName:
82-
return "base name"
83-
case \DeclNameSyntax.arguments:
84-
return "arguments"
8581
case \DeinitializerDeclSyntax.attributes:
8682
return "attributes"
8783
case \DeinitializerDeclSyntax.modifiers:

Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ extension SyntaxKind {
105105
return "'copy' expression"
106106
case .declModifier:
107107
return "modifier"
108-
case .declName:
109-
return "declaration name"
110108
case .deferStmt:
111109
return "'defer' statement"
112110
case .deinitializerDecl:

Sources/SwiftSyntax/Documentation.docc/generated/SwiftSyntax.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
321321
- <doc:SwiftSyntax/ConventionWitnessMethodAttributeArgumentsSyntax>
322322
- <doc:SwiftSyntax/DeclModifierDetailSyntax>
323323
- <doc:SwiftSyntax/DeclNameArgumentsSyntax>
324-
- <doc:SwiftSyntax/DeclNameSyntax>
325324
- <doc:SwiftSyntax/DeinitializerEffectSpecifiersSyntax>
326325
- <doc:SwiftSyntax/DerivativeAttributeArgumentsSyntax>
327326
- <doc:SwiftSyntax/DifferentiabilityArgumentsSyntax>

Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -793,16 +793,6 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
793793
return "rightParen"
794794
case \DeclNameArgumentsSyntax.unexpectedAfterRightParen:
795795
return "unexpectedAfterRightParen"
796-
case \DeclNameSyntax.unexpectedBeforeBaseName:
797-
return "unexpectedBeforeBaseName"
798-
case \DeclNameSyntax.baseName:
799-
return "baseName"
800-
case \DeclNameSyntax.unexpectedBetweenBaseNameAndArguments:
801-
return "unexpectedBetweenBaseNameAndArguments"
802-
case \DeclNameSyntax.arguments:
803-
return "arguments"
804-
case \DeclNameSyntax.unexpectedAfterArguments:
805-
return "unexpectedAfterArguments"
806796
case \DeferStmtSyntax.unexpectedBeforeDeferKeyword:
807797
return "unexpectedBeforeDeferKeyword"
808798
case \DeferStmtSyntax.deferKeyword:

Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,81 +1558,6 @@ extension ConsumeExprSyntax {
15581558
}
15591559
}
15601560

1561-
extension DeclNameSyntax {
1562-
@available(*, deprecated, renamed: "unexpectedBeforeBaseName")
1563-
public var unexpectedBeforeDeclBaseName: UnexpectedNodesSyntax? {
1564-
get {
1565-
return unexpectedBeforeBaseName
1566-
}
1567-
set {
1568-
unexpectedBeforeBaseName = newValue
1569-
}
1570-
}
1571-
1572-
@available(*, deprecated, renamed: "baseName")
1573-
public var declBaseName: TokenSyntax {
1574-
get {
1575-
return baseName
1576-
}
1577-
set {
1578-
baseName = newValue
1579-
}
1580-
}
1581-
1582-
@available(*, deprecated, renamed: "unexpectedBetweenBaseNameAndArguments")
1583-
public var unexpectedBetweenDeclBaseNameAndDeclNameArguments: UnexpectedNodesSyntax? {
1584-
get {
1585-
return unexpectedBetweenBaseNameAndArguments
1586-
}
1587-
set {
1588-
unexpectedBetweenBaseNameAndArguments = newValue
1589-
}
1590-
}
1591-
1592-
@available(*, deprecated, renamed: "arguments")
1593-
public var declNameArguments: DeclNameArgumentsSyntax? {
1594-
get {
1595-
return arguments
1596-
}
1597-
set {
1598-
arguments = newValue
1599-
}
1600-
}
1601-
1602-
@available(*, deprecated, renamed: "unexpectedAfterArguments")
1603-
public var unexpectedAfterDeclNameArguments: UnexpectedNodesSyntax? {
1604-
get {
1605-
return unexpectedAfterArguments
1606-
}
1607-
set {
1608-
unexpectedAfterArguments = newValue
1609-
}
1610-
}
1611-
1612-
@available(*, deprecated, message: "Use an initializer with baseName, arguments argument(s).")
1613-
@_disfavoredOverload
1614-
public init(
1615-
leadingTrivia: Trivia? = nil,
1616-
_ unexpectedBeforeDeclBaseName: UnexpectedNodesSyntax? = nil,
1617-
declBaseName: TokenSyntax,
1618-
_ unexpectedBetweenDeclBaseNameAndDeclNameArguments: UnexpectedNodesSyntax? = nil,
1619-
declNameArguments: DeclNameArgumentsSyntax? = nil,
1620-
_ unexpectedAfterDeclNameArguments: UnexpectedNodesSyntax? = nil,
1621-
trailingTrivia: Trivia? = nil
1622-
1623-
) {
1624-
self.init(
1625-
leadingTrivia: leadingTrivia,
1626-
unexpectedBeforeDeclBaseName,
1627-
baseName: declBaseName,
1628-
unexpectedBetweenDeclBaseNameAndDeclNameArguments,
1629-
arguments: declNameArguments,
1630-
unexpectedAfterDeclNameArguments,
1631-
trailingTrivia: trailingTrivia
1632-
)
1633-
}
1634-
}
1635-
16361561
extension DerivativeAttributeArgumentsSyntax {
16371562
@available(*, deprecated, renamed: "unexpectedBetweenPeriodAndAccessorSpecifier")
16381563
public var unexpectedBetweenPeriodAndAccessorKind: UnexpectedNodesSyntax? {
@@ -2300,7 +2225,7 @@ extension DynamicReplacementAttributeArgumentsSyntax {
23002225
}
23012226

23022227
@available(*, deprecated, renamed: "declName")
2303-
public var declname: DeclNameSyntax {
2228+
public var declname: IdentifierExprSyntax {
23042229
get {
23052230
return declName
23062231
}
@@ -2328,7 +2253,7 @@ extension DynamicReplacementAttributeArgumentsSyntax {
23282253
_ unexpectedBetweenForLabelAndColon: UnexpectedNodesSyntax? = nil,
23292254
colon: TokenSyntax = .colonToken(),
23302255
_ unexpectedBetweenColonAndDeclname: UnexpectedNodesSyntax? = nil,
2331-
declname: DeclNameSyntax,
2256+
declname: IdentifierExprSyntax,
23322257
_ unexpectedAfterDeclname: UnexpectedNodesSyntax? = nil,
23332258
trailingTrivia: Trivia? = nil
23342259

@@ -7118,7 +7043,7 @@ extension SpecializeTargetFunctionArgumentSyntax {
71187043
}
71197044

71207045
@available(*, deprecated, renamed: "declName")
7121-
public var declname: DeclNameSyntax {
7046+
public var declname: IdentifierExprSyntax {
71227047
get {
71237048
return declName
71247049
}
@@ -7146,7 +7071,7 @@ extension SpecializeTargetFunctionArgumentSyntax {
71467071
_ unexpectedBetweenLabelAndColon: UnexpectedNodesSyntax? = nil,
71477072
colon: TokenSyntax = .colonToken(),
71487073
_ unexpectedBetweenColonAndDeclname: UnexpectedNodesSyntax? = nil,
7149-
declname: DeclNameSyntax,
7074+
declname: IdentifierExprSyntax,
71507075
_ unexpectedBetweenDeclnameAndTrailingComma: UnexpectedNodesSyntax? = nil,
71517076
trailingComma: TokenSyntax? = nil,
71527077
_ unexpectedAfterTrailingComma: UnexpectedNodesSyntax? = nil,

0 commit comments

Comments
 (0)