1818import SwiftSyntax
1919
2020private func makeName( from declarationChain: [ Decl ] ) -> String {
21- return declarationChain. map { $0. name } . joined ( separator: " . " )
21+ return declarationChain. map { $0. nameString } . joined ( separator: " . " )
2222}
2323
2424public struct DeclContext {
@@ -150,12 +150,12 @@ public protocol Decl {
150150 /// means we don't have to reimplement the property in terms of Syntax(self).
151151 var _syntaxNode : Syntax { get }
152152
153- var name : String { get }
153+ var nameString : String { get }
154154
155155 var isResilient : Bool { get }
156156 var isStored : Bool { get }
157157
158- var modifiers : ModifierListSyntax ? { get }
158+ var modifiers : DeclModifierListSyntax ? { get }
159159
160160 func lookupDirect( _ name: String ) -> Decl ?
161161}
@@ -173,7 +173,7 @@ public extension Decl where Self: DeclWithMembers {
173173 func lookupDirect( _ name: String ) -> Decl ? {
174174 for item in memberBlock. members {
175175 guard let member = item. decl. as ( Decl . self) else { continue }
176- if member. name == name {
176+ if member. nameString == name {
177177 return member
178178 }
179179 }
@@ -186,7 +186,7 @@ public extension Decl where Self: AbstractFunctionDecl {
186186 guard let body = self . body else { return nil }
187187 for item in body. statements {
188188 guard let decl = item. item. as ( Decl . self) else { continue }
189- if decl. name == name {
189+ if decl. nameString == name {
190190 return decl
191191 }
192192 }
@@ -195,14 +195,14 @@ public extension Decl where Self: AbstractFunctionDecl {
195195}
196196
197197extension SourceFileSyntax : Decl {
198- public var name : String { return " (file) " }
198+ public var nameString : String { return " (file) " }
199199
200- public var modifiers : ModifierListSyntax ? { return nil }
200+ public var modifiers : DeclModifierListSyntax ? { return nil }
201201
202202 public func lookupDirect( _ name: String ) -> Decl ? {
203203 for item in statements {
204204 guard let decl = item. item. as ( Decl . self) else { continue }
205- if decl. name == name {
205+ if decl. nameString == name {
206206 return decl
207207 }
208208 }
@@ -211,8 +211,8 @@ extension SourceFileSyntax: Decl {
211211}
212212
213213extension ClassDeclSyntax : Decl {
214- public var name : String {
215- return identifier . text
214+ public var nameString : String {
215+ return name . text
216216 }
217217
218218 public var isResilient : Bool {
@@ -221,8 +221,8 @@ extension ClassDeclSyntax: Decl {
221221}
222222
223223extension StructDeclSyntax : Decl {
224- public var name : String {
225- return identifier . text
224+ public var nameString : String {
225+ return name . text
226226 }
227227
228228 public var isResilient : Bool {
@@ -231,8 +231,8 @@ extension StructDeclSyntax: Decl {
231231}
232232
233233extension EnumDeclSyntax : Decl {
234- public var name : String {
235- return identifier . text
234+ public var nameString : String {
235+ return name . text
236236 }
237237
238238 public var isResilient : Bool {
@@ -241,30 +241,30 @@ extension EnumDeclSyntax: Decl {
241241}
242242
243243extension ProtocolDeclSyntax : Decl {
244- public var name : String {
245- return identifier . text
244+ public var nameString : String {
245+ return name . text
246246 }
247247}
248248
249249extension ExtensionDeclSyntax : Decl {
250- public var name : String {
250+ public var nameString : String {
251251 return " (extension \( extendedType. typeText) ) "
252252 }
253253}
254254
255- extension TypealiasDeclSyntax : Decl {
256- public var name : String {
257- return identifier . text
255+ extension TypeAliasDeclSyntax : Decl {
256+ public var nameString : String {
257+ return name . text
258258 }
259259
260260 public func lookupDirect( _ name: String ) -> Decl ? {
261261 fatalError ( " Not implemented: \( type ( of: self ) ) .lookupDirect(_:) " )
262262 }
263263}
264264
265- extension AssociatedtypeDeclSyntax : Decl {
266- public var name : String {
267- return identifier . text
265+ extension AssociatedTypeDeclSyntax : Decl {
266+ public var nameString : String {
267+ return name . text
268268 }
269269
270270 public func lookupDirect( _ name: String ) -> Decl ? {
@@ -338,7 +338,7 @@ extension VariableDeclSyntax: Decl {
338338 }
339339 }
340340
341- public var name : String {
341+ public var nameString : String {
342342 let list = boundProperties
343343 if list. count == 1 { return list. first!. name. text }
344344 let nameList = list. map { $0. name. text }
@@ -376,7 +376,7 @@ extension VariableDeclSyntax: Decl {
376376 case . accessors( let accessors) :
377377 // Check the individual accessors.
378378 return accessors. allSatisfy { accessor in
379- switch accessor. accessorKind . text {
379+ switch accessor. accessorSpecifier . text {
380380 case " willSet " , " didSet " :
381381 // These accessors are allowed on stored properties.
382382 return true
@@ -385,10 +385,6 @@ extension VariableDeclSyntax: Decl {
385385 return false
386386 }
387387 }
388-
389- default :
390- // This binding doesn't include any computed getters.
391- return true
392388 }
393389 }
394390 }
@@ -399,27 +395,27 @@ extension VariableDeclSyntax: Decl {
399395}
400396
401397extension EnumCaseElementSyntax {
402- var name : String {
398+ var nameString : String {
403399 let params : String
404- if let paramList = associatedValue ? . parameterList {
400+ if let paramList = parameterClause ? . parameters {
405401 params = paramList. map {
406402 " \( $0. firstName? . text ?? " _ " ) : "
407403 } . joined ( )
408404 }
409405 else {
410406 params = " "
411407 }
412- return " \( identifier . text) ( \( params ) ) "
408+ return " \( name . text) ( \( params ) ) "
413409 }
414410}
415411
416412extension EnumCaseDeclSyntax : Decl {
417- public var name : String {
413+ public var nameString : String {
418414 if elements. count == 1 {
419- return elements. first!. name
415+ return elements. first!. nameString
420416 }
421417 else {
422- return " ( " + elements. map { $0. name } . joined ( separator: " , " ) + " ) "
418+ return " ( " + elements. map { $0. nameString } . joined ( separator: " , " ) + " ) "
423419 }
424420 }
425421
@@ -435,7 +431,7 @@ extension EnumCaseDeclSyntax: Decl {
435431extension IfConfigDeclSyntax {
436432 var containsStoredMembers : Bool {
437433 return clauses. contains { clause in
438- guard let members = clause. elements? . as ( MemberDeclListSyntax . self) else {
434+ guard let members = clause. elements? . as ( MemberBlockItemListSyntax . self) else {
439435 return false
440436 }
441437
@@ -468,7 +464,7 @@ extension Optional where Wrapped == AttributeListSyntax {
468464 }
469465}
470466
471- extension Optional where Wrapped == ModifierListSyntax {
467+ extension Optional where Wrapped == DeclModifierListSyntax {
472468 func contains( named name: String ) -> Bool {
473469 return self ? . contains { $0. name. text == name } ?? false
474470 }
0 commit comments