@@ -7,7 +7,6 @@ import com.google.devtools.ksp.getVisibility
7
7
import com.google.devtools.ksp.processing.CodeGenerator
8
8
import com.google.devtools.ksp.processing.Dependencies
9
9
import com.google.devtools.ksp.processing.KSBuiltIns
10
- import com.google.devtools.ksp.processing.KSPLogger
11
10
import com.google.devtools.ksp.processing.Resolver
12
11
import com.google.devtools.ksp.processing.SymbolProcessor
13
12
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
@@ -31,16 +30,12 @@ import dev.programadorthi.routing.annotation.Route
31
30
32
31
public class RoutingProcessorProvider : SymbolProcessorProvider {
33
32
override fun create (environment : SymbolProcessorEnvironment ): SymbolProcessor {
34
- return RoutingProcessor (
35
- codeGenerator = environment.codeGenerator,
36
- logger = environment.logger
37
- )
33
+ return RoutingProcessor (codeGenerator = environment.codeGenerator)
38
34
}
39
35
}
40
36
41
37
private class RoutingProcessor (
42
38
private val codeGenerator : CodeGenerator ,
43
- private val logger : KSPLogger
44
39
) : SymbolProcessor {
45
40
private var invoked = false
46
41
@@ -99,11 +94,23 @@ private class RoutingProcessor(
99
94
if (isRegexRoute) {
100
95
if (routeAnnotation.method.isBlank()) {
101
96
configureSpec
102
- .beginControlFlow(" %M(path = %T(%S))" , handle, Regex ::class , routeAnnotation.regex)
97
+ .beginControlFlow(
98
+ " %M(path = %T(%S))" ,
99
+ handle,
100
+ Regex ::class ,
101
+ routeAnnotation.regex
102
+ )
103
103
} else {
104
- val template = """ %M(path = %T(%S), method = %M(value = "${routeAnnotation.method} "))"""
104
+ val template =
105
+ """ %M(path = %T(%S), method = %M(value = "${routeAnnotation.method} "))"""
105
106
configureSpec
106
- .beginControlFlow(template, handle, Regex ::class , routeAnnotation.regex, routeMethod)
107
+ .beginControlFlow(
108
+ template,
109
+ handle,
110
+ Regex ::class ,
111
+ routeAnnotation.regex,
112
+ routeMethod
113
+ )
107
114
}
108
115
} else {
109
116
val named = when {
@@ -114,7 +121,8 @@ private class RoutingProcessor(
114
121
configureSpec
115
122
.beginControlFlow(" %M(path = %S, $named )" , handle, routeAnnotation.path)
116
123
} else {
117
- val template = """ %M(path = %S, $named , method = %M(value = "${routeAnnotation.method} "))"""
124
+ val template =
125
+ """ %M(path = %S, $named , method = %M(value = "${routeAnnotation.method} "))"""
118
126
configureSpec
119
127
.beginControlFlow(template, handle, routeAnnotation.path, routeMethod)
120
128
}
@@ -206,7 +214,14 @@ private class RoutingProcessor(
206
214
else -> resolver.builtIns.requiredParse(type.resolve())
207
215
}
208
216
when {
209
- hasZeroOrOneParameter -> builder.add(PATH_TEMPLATE , paramName, call, customName, literal)
217
+ hasZeroOrOneParameter -> builder.add(
218
+ PATH_TEMPLATE ,
219
+ paramName,
220
+ call,
221
+ customName,
222
+ literal
223
+ )
224
+
210
225
else -> builder.addStatement(PATH_TEMPLATE , paramName, call, customName, " $literal ," )
211
226
}
212
227
}
@@ -233,9 +248,10 @@ private class RoutingProcessor(
233
248
check(paramType.declaration == listDeclaration) {
234
249
" TailCard parameter must be a List<String>?"
235
250
}
236
- val genericArgument = checkNotNull(type.element?.typeArguments?.firstOrNull()?.type?.resolve()) {
237
- " No <String> type found at tailcard parameter"
238
- }
251
+ val genericArgument =
252
+ checkNotNull(type.element?.typeArguments?.firstOrNull()?.type?.resolve()) {
253
+ " No <String> type found at tailcard parameter"
254
+ }
239
255
check(genericArgument == resolver.builtIns.stringType) {
240
256
" TailCard list item type must be non nullable String"
241
257
}
@@ -318,7 +334,8 @@ private class RoutingProcessor(
318
334
private val routeMethod = MemberName (" dev.programadorthi.routing.core" , " RouteMethod" )
319
335
private val call = MemberName (" dev.programadorthi.routing.core.application" , " call" )
320
336
private val receive = MemberName (" dev.programadorthi.routing.core.application" , " receive" )
321
- private val receiveNullable = MemberName (" dev.programadorthi.routing.core.application" , " receiveNullable" )
337
+ private val receiveNullable =
338
+ MemberName (" dev.programadorthi.routing.core.application" , " receiveNullable" )
322
339
323
340
private const val BODY_TEMPLATE = " %L = %M.%M()%L"
324
341
private const val FUN_INVOKE_END = " )"
0 commit comments