@@ -60,7 +60,7 @@ class DataCompatProcessor(
60
60
// for default values.
61
61
val classToDefaultValuesMap =
62
62
mutableMapOf<KSClassDeclaration , MutableMap <String , String ?>>()
63
- val imports = ArrayList < String >()
63
+
64
64
val symbolsWithDefaultAnnotation =
65
65
resolver.getSymbolsWithAnnotation(Default ::class .qualifiedName!! , true )
66
66
symbolsWithDefaultAnnotation.forEach { annotatedProperty ->
@@ -76,16 +76,13 @@ class DataCompatProcessor(
76
76
val defaultValue = defaultAnnotationsParams?.first()
77
77
defaultValueMap[annotatedProperty.name!! .getShortName()] =
78
78
defaultValue?.value as ? String?
79
- defaultAnnotationsParams?.getOrNull(1 )?.value?.let {
80
- imports.addAll(it as ArrayList <String >)
81
- }
82
79
classToDefaultValuesMap[parentClass] = defaultValueMap
83
80
}
84
81
}
85
82
86
83
val unableToProcess = dataCompatAnnotated.filterNot { it.validate() }
87
84
dataCompatAnnotated.filter { it is KSClassDeclaration && it.validate() }
88
- .forEach { it.accept(Visitor (classToDefaultValuesMap, imports ), Unit ) }
85
+ .forEach { it.accept(Visitor (classToDefaultValuesMap), Unit ) }
89
86
return unableToProcess.toList()
90
87
}
91
88
@@ -102,7 +99,6 @@ class DataCompatProcessor(
102
99
103
100
private inner class Visitor (
104
101
private val defaultValuesMap : Map <KSClassDeclaration , MutableMap <String , String ?>>,
105
- private val imports : List <String >
106
102
) : KSVisitorVoid() {
107
103
108
104
@Suppress(" LongMethod" , " MaxLineLength" , " ComplexMethod" )
@@ -118,6 +114,10 @@ class DataCompatProcessor(
118
114
val classKdoc = classDeclaration.docString
119
115
val packageName = classDeclaration.packageName.asString()
120
116
117
+ val imports = ArrayList <String >()
118
+ classDeclaration.annotations.firstOrNull {
119
+ it.annotationType.resolve().toString() == DataCompat ::class .simpleName
120
+ }?.arguments?.firstOrNull()?.value?.let { imports.addAll(it as ArrayList <String >) }
121
121
val otherAnnotations = classDeclaration.annotations
122
122
.filter { it.annotationType.resolve().toString() != DataCompat ::class .simpleName }
123
123
val implementedInterfaces = classDeclaration
0 commit comments