File tree Expand file tree Collapse file tree 2 files changed +4
-15
lines changed Expand file tree Collapse file tree 2 files changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,9 @@ public struct AddExtensionMacro: ExtensionMacro {
4141 conformingTo protocols: [ TypeSyntax ] ,
4242 in context: some MacroExpansionContext
4343 ) throws -> [ ExtensionDeclSyntax ] {
44- let typeName = declaration. declGroupName
4544 return protocols. map {
4645 ( """
47- extension \( typeName ) : \( $0) {
46+ extension \( type . trimmed ) : \( $0) {
4847 struct _Extension_ \( $0) : \( $0) {
4948 var nested = 8
5049 }
@@ -53,8 +52,8 @@ public struct AddExtensionMacro: ExtensionMacro {
5352 . cast ( ExtensionDeclSyntax . self)
5453 } + [
5554 ( """
56- extension \( typeName ) {
57- static let _extension_ \( typeName ) = 3
55+ extension \( type . trimmed ) {
56+ static let _extension_ \( declaration . declGroupName ) = 3
5857 }
5958 """ as DeclSyntax ) . cast ( ExtensionDeclSyntax . self)
6059 ]
Original file line number Diff line number Diff line change @@ -40,10 +40,9 @@ public struct AddExtensionMacro: ExtensionMacro {
4040 conformingTo protocols: [ TypeSyntax ] ,
4141 in context: some MacroExpansionContext
4242 ) throws -> [ ExtensionDeclSyntax ] {
43- let typeName = declaration. declGroupName
4443 return protocols. map {
4544 ( """
46- extension \( typeName ) : \( $0) {
45+ extension \( type . trimmed ) : \( $0) {
4746 struct _Extension_ \( $0) : \( $0) {}
4847 }
4948 """ as DeclSyntax )
@@ -66,12 +65,3 @@ extension DeclSyntaxProtocol {
6665 fatalError ( " Not implemented " )
6766 }
6867}
69-
70- extension DeclGroupSyntax {
71- var declGroupName : TokenSyntax {
72- if let structDecl = self . as ( StructDeclSyntax . self) {
73- return structDecl. name. trimmed
74- }
75- fatalError ( " Not implemented " )
76- }
77- }
You can’t perform that action at this time.
0 commit comments