@@ -109,9 +109,9 @@ class AnnotationProcessor {
109
109
)
110
110
111
111
classAnnotationsDescriptors.add(classDescriptor)
112
- println (" Class: ${classDescriptor.name} " )
112
+ println (" Class: ${classDescriptor.name} , Annotations: ${classDescriptor.annotations} " )
113
113
classDescriptor.methods.forEach { method ->
114
- println (" Method: ${method.name} , Annotations: ${method.annotations} , Parameters: ${method.parameters} " )
114
+ println (" Method: ${method.name} , Annotations: ${method.annotations} ,Annotation Parameters: ${method.parameters} " )
115
115
}
116
116
}
117
117
@@ -124,17 +124,37 @@ class AnnotationProcessor {
124
124
parameters[name] = formatAnnotationValue(value)
125
125
}
126
126
}
127
- return AnnotationData (annotationNode.desc.removePrefix( " L " ).removeSuffix( " ; " ).replace( ' / ' , ' . ' ), parameters)
127
+ return AnnotationData (formatDescriptor( annotationNode.desc), parameters)
128
128
}
129
129
130
130
private fun formatAnnotationValue (value : Any? ): Any? {
131
131
return when (value) {
132
- is List <* > -> value.map { formatAnnotationValue(it) }
133
- is Array <* > -> value.map { formatAnnotationValue(it) }
132
+ is List <* > -> value.flatMap {
133
+ val formattedValue = formatAnnotationValue(it)
134
+ if (formattedValue is List <* >) {
135
+ formattedValue
136
+ } else {
137
+ listOf (formattedValue)
138
+ }
139
+ }
140
+ is Array <* > -> value.flatMap {
141
+ val formattedValue = formatAnnotationValue(it)
142
+ if (formattedValue is List <* >) {
143
+ formattedValue
144
+ } else {
145
+ listOf (formattedValue)
146
+ }
147
+ }
134
148
is TypePath -> value.toString()
135
149
is AnnotationNode -> formatAnnotationNode(value)
136
- is Type -> value.className
137
- is String -> value.replace(" \" " , " \\\" " )
150
+ is Type -> value.className.replace(' /' , ' .' )
151
+ is String -> {
152
+ if (value.startsWith(" L" ) && value.endsWith(" ;" )) {
153
+ formatDescriptor(value)
154
+ } else {
155
+ value
156
+ }
157
+ }
138
158
is ByteArray -> value.toList()
139
159
is CharArray -> value.map { it.toString() }
140
160
is ShortArray -> value.toList()
@@ -148,7 +168,7 @@ class AnnotationProcessor {
148
168
}
149
169
150
170
private fun formatAnnotationNode (annotationNode : AnnotationNode ): String {
151
- val sb = StringBuilder (" @${annotationNode.desc} (" )
171
+ val sb = StringBuilder (" @${formatDescriptor( annotationNode.desc) } (" )
152
172
annotationNode.values?.let { values ->
153
173
for (i in values.indices step 2 ) {
154
174
val name = values[i]
@@ -163,6 +183,10 @@ class AnnotationProcessor {
163
183
return sb.toString()
164
184
}
165
185
186
+ private fun formatDescriptor (descriptor : String ): String {
187
+ return descriptor.removePrefix(" L" ).removeSuffix(" ;" ).replace(' /' , ' .' )
188
+ }
189
+
166
190
private fun getVisibility (access : Int ): Visibility {
167
191
return when {
168
192
(access and Opcodes .ACC_PUBLIC ) != 0 -> Visibility .PUBLIC
0 commit comments