File tree 2 files changed +13
-2
lines changed
Sources/XCTestParametrizedMacroMacros
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,17 @@ struct MacroDeclarationHelper {
8
8
self . declaration = declaration
9
9
}
10
10
11
+
12
+ /// Returns 'TokenSyntax' representing name of the input parameter.
13
+ var inputParamName : TokenSyntax ? {
14
+ declaration. signature. input. parameterList. first? . secondName
15
+ }
16
+
17
+ /// Returns 'TypeSyntax' representing type of the input object.
18
+ var inputParamType : TypeSyntax ? {
19
+ declaration. signature. input. parameterList. first? . type
20
+ }
21
+
11
22
var firstAttribute : AttributeSyntax ? {
12
23
return declaration. attributes. first? . as ( AttributeSyntax . self)
13
24
}
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ public struct ParametrizeMacro: PeerMacro {
18
18
let macroDeclarationHelper = MacroDeclarationHelper ( declaration)
19
19
20
20
let funcName = declaration. identifier
21
- guard let inputParamName = declaration . signature . input . parameterList . first ? . secondName ? . text else {
21
+ guard let inputParamName = macroDeclarationHelper . inputParamName ? . text else {
22
22
throw ParametrizeMacroError . functionInputParamSecondNameMissing
23
23
}
24
24
25
- guard let inputParamType = declaration . signature . input . parameterList . first ? . type else {
25
+ guard let inputParamType = macroDeclarationHelper . inputParamType else {
26
26
throw ParametrizeMacroError . functionInputParamTypeMissing
27
27
}
28
28
You can’t perform that action at this time.
0 commit comments