@@ -5,7 +5,12 @@ import com.google.devtools.ksp.processing.CodeGenerator
5
5
import com.google.devtools.ksp.processing.KSPLogger
6
6
import com.google.devtools.ksp.processing.Resolver
7
7
import com.google.devtools.ksp.processing.SymbolProcessor
8
- import com.google.devtools.ksp.symbol.*
8
+ import com.google.devtools.ksp.symbol.ClassKind
9
+ import com.google.devtools.ksp.symbol.KSAnnotated
10
+ import com.google.devtools.ksp.symbol.KSClassDeclaration
11
+ import com.google.devtools.ksp.symbol.KSPropertyDeclaration
12
+ import com.google.devtools.ksp.symbol.KSVisitorVoid
13
+ import com.google.devtools.ksp.symbol.Modifier
9
14
import com.google.devtools.ksp.validate
10
15
import com.squareup.kotlinpoet.ANY
11
16
import com.squareup.kotlinpoet.AnnotationSpec
@@ -46,7 +51,8 @@ class DataCompatProcessor(
46
51
}
47
52
48
53
val unableToProcess = annotated.filterNot { it.validate() }
49
- annotated.filter { it is KSClassDeclaration && it.validate() }.forEach { it.accept(Visitor (), Unit ) }
54
+ annotated.filter { it is KSClassDeclaration && it.validate() }
55
+ .forEach { it.accept(Visitor (), Unit ) }
50
56
return unableToProcess.toList()
51
57
}
52
58
@@ -60,7 +66,8 @@ class DataCompatProcessor(
60
66
61
67
// Cleanup class name by dropping Data part
62
68
// TODO make this part more flexible with providing name inside the annotation
63
- val className = classDeclaration.simpleName.asString().dropLast(CLASS_NAME_DROP_LAST_CHARACTERS )
69
+ val className =
70
+ classDeclaration.simpleName.asString().dropLast(CLASS_NAME_DROP_LAST_CHARACTERS )
64
71
val classKdoc = classDeclaration.docString
65
72
val packageName = classDeclaration.packageName.asString()
66
73
@@ -206,19 +213,24 @@ class DataCompatProcessor(
206
213
207
214
var kDocProperty = kdocPropertyList
208
215
.filter { it.startsWith(" $propertyName " ) }
209
- .joinToString { it.substringAfter(" $propertyName " )
210
- .lowercase(Locale .getDefault()) }
216
+ .joinToString {
217
+ it.substringAfter(" $propertyName " ).lowercase(Locale .getDefault())
218
+ }
211
219
212
220
if (kDocProperty.isEmpty()) {
213
221
kDocProperty = propertyName
214
222
}
215
223
216
224
builderBuilder.addFunction(
217
- FunSpec .builder(" set${propertyName.replaceFirstChar {
218
- if (it.isLowerCase()) it.titlecase(
219
- Locale .getDefault()
220
- ) else it.toString()
221
- }} " )
225
+ FunSpec .builder(
226
+ " set${
227
+ propertyName.replaceFirstChar {
228
+ if (it.isLowerCase()) it.titlecase(
229
+ Locale .getDefault()
230
+ ) else it.toString()
231
+ }
232
+ } "
233
+ )
222
234
.addKdoc(
223
235
"""
224
236
|Set $kDocProperty
@@ -271,10 +283,12 @@ class DataCompatProcessor(
271
283
|
272
284
|This is a concrete implementation of the builder design pattern.
273
285
|
274
- |${kdocPropertyList.joinToString(
275
- prefix = " $KDOC_PROPERTY_ANNOTATION " ,
276
- separator = " \n $KDOC_PROPERTY_ANNOTATION "
277
- )}
286
+ |${
287
+ kdocPropertyList.joinToString(
288
+ prefix = " $KDOC_PROPERTY_ANNOTATION " ,
289
+ separator = " \n $KDOC_PROPERTY_ANNOTATION "
290
+ )
291
+ }
278
292
""" .trimMargin()
279
293
)
280
294
builderBuilder.addFunction(buildFunction.build())
0 commit comments