@@ -31,32 +31,37 @@ extension LiveViewMacro: ExpressionMacro {
3131 case 1 :
3232 registries = " typealias Registries = \( addons. first!) "
3333 default :
34- func multiRegistry( _ addons: some RandomAccessCollection < SimpleTypeIdentifierSyntax > ) -> SimpleTypeIdentifierSyntax {
34+ func multiRegistry( _ addons: some RandomAccessCollection < IdentifierTypeSyntax > ) -> IdentifierTypeSyntax {
3535 switch addons. count {
3636 case 2 :
37- return SimpleTypeIdentifierSyntax (
37+ return IdentifierTypeSyntax (
3838 name: " _MultiRegistry " ,
3939 genericArgumentClause: . init( arguments: . init( [
40- . init( argumentType : addons. first!, trailingComma: . commaToken( ) ) ,
41- . init( argumentType : addons. last!)
40+ . init( argument : addons. first!, trailingComma: . commaToken( ) ) ,
41+ . init( argument : addons. last!)
4242 ] ) )
4343 )
4444 default :
45- return SimpleTypeIdentifierSyntax (
45+ return IdentifierTypeSyntax (
4646 name: " _MultiRegistry " ,
4747 genericArgumentClause: . init( arguments: . init( [
48- . init( argumentType : addons. first!, trailingComma: . commaToken( ) ) ,
49- . init( argumentType : multiRegistry ( addons. dropFirst ( ) ) )
48+ . init( argument : addons. first!, trailingComma: . commaToken( ) ) ,
49+ . init( argument : multiRegistry ( addons. dropFirst ( ) ) )
5050 ] ) )
5151 )
5252 }
5353 }
5454 registries = " typealias Registries = \( multiRegistry ( addons) ) "
5555 }
5656
57- let liveViewArguments = node. argumentList
58- . removingLast ( )
59- . replacing ( childAt: node. argumentList. count - 2 , with: node. argumentList. removingLast ( ) . last!. with ( \. trailingComma, nil ) )
57+ var liveViewArguments = LabeledExprListSyntax (
58+ node. argumentList
59+ . dropLast ( )
60+ )
61+ liveViewArguments = liveViewArguments. with (
62+ \. [ liveViewArguments. index ( liveViewArguments. startIndex, offsetBy: node. argumentList. count - 2 ) ] ,
63+ node. argumentList. dropLast ( ) . last!. with ( \. trailingComma, nil )
64+ )
6065
6166 return """
6267 { () -> AnyView in
@@ -69,13 +74,13 @@ extension LiveViewMacro: ExpressionMacro {
6974 """
7075 }
7176
72- private static func transformAddon( _ element: ArrayElementSyntax ) throws -> SimpleTypeIdentifierSyntax {
73- guard let registry = element. expression. as ( MemberAccessExprSyntax . self) ? . base? . as ( SpecializeExprSyntax . self) ,
74- let name = registry. expression. as ( IdentifierExprSyntax . self)
77+ private static func transformAddon( _ element: ArrayElementSyntax ) throws -> IdentifierTypeSyntax {
78+ guard let registry = element. expression. as ( MemberAccessExprSyntax . self) ? . base? . as ( GenericSpecializationExprSyntax . self) ,
79+ let name = registry. expression. as ( DeclReferenceExprSyntax . self)
7580 else { throw LiveViewMacroError . invalidAddonElement }
76- return SimpleTypeIdentifierSyntax (
77- name: name. identifier ,
78- genericArgumentClause: . init( . init( arguments: . init( [ . init( argumentType : SimpleTypeIdentifierSyntax ( name: . identifier( " Self " ) ) ) ] ) ) )
81+ return IdentifierTypeSyntax (
82+ name: name. baseName ,
83+ genericArgumentClause: . init( . init( arguments: . init( [ . init( argument : IdentifierTypeSyntax ( name: . identifier( " Self " ) ) ) ] ) ) )
7984 )
8085 }
8186}
0 commit comments