@@ -2,6 +2,7 @@ package dev.programadorthi.routing.ksp
2
2
3
3
import com.google.devtools.ksp.KspExperimental
4
4
import com.google.devtools.ksp.getAnnotationsByType
5
+ import com.google.devtools.ksp.getClassDeclarationByName
5
6
import com.google.devtools.ksp.getVisibility
6
7
import com.google.devtools.ksp.processing.CodeGenerator
7
8
import com.google.devtools.ksp.processing.Dependencies
@@ -86,12 +87,32 @@ private class RoutingProcessor(
86
87
.firstOrNull()
87
88
?.value
88
89
? : paramName
90
+ val paramType = param.type.resolve()
91
+ if (routeAnnotation.path.contains(" {$customName ...}" )) {
92
+ val listDeclaration = checkNotNull(resolver.getClassDeclarationByName<List <* >>()) {
93
+ " Class declaration not found to List<String>?"
94
+ }
95
+ check(paramType.declaration == listDeclaration) {
96
+ " Tailcard parameter must be a List<String>?"
97
+ }
98
+ val genericArgument = checkNotNull(param.type.element?.typeArguments?.firstOrNull()?.type?.resolve()) {
99
+ " No <String> type found at tailcard parameter"
100
+ }
101
+ check(genericArgument == resolver.builtIns.stringType) {
102
+ " Tailcard list items type must be non nullable String"
103
+ }
104
+ check(paramType.isMarkedNullable) {
105
+ " Tailcard list must be nullable as List<String>?"
106
+ }
107
+ parameters + = """ $paramName = %M.parameters.getAll("$customName ")"""
108
+ continue
109
+ }
110
+
89
111
val isOptional = routeAnnotation.path.contains(" {$customName ?}" )
90
112
val isRequired = routeAnnotation.path.contains(" {$customName }" )
91
113
check(isOptional || isRequired) {
92
114
" '$qualifiedName ' has parameter '$paramName ' that is not declared as path parameter {$customName }"
93
115
}
94
- val paramType = param.type.resolve()
95
116
val parsed = """ $paramName = %M.parameters["$customName "]"""
96
117
parameters + = when {
97
118
isOptional -> optionalParse(paramType, resolver, parsed)
0 commit comments