Add SourceElement to AnnotationDescriptor
Use KotlinSourceElement in the compiler for annotations resolved from PSI, introduce ReflectAnnotationSource for reflection
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin.reflect
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
|
||||
public class ReflectAnnotationSource(public val annotation: Annotation) : SourceElement
|
||||
+5
-3
@@ -99,7 +99,7 @@ private object ReflectClassStructure {
|
||||
for ((parameterIndex, annotations) in method.getParameterAnnotations().withIndex()) {
|
||||
for (annotation in annotations) {
|
||||
val annotationType = annotation.annotationType()
|
||||
visitor.visitParameterAnnotation(parameterIndex, annotationType.classId)?.let {
|
||||
visitor.visitParameterAnnotation(parameterIndex, annotationType.classId, ReflectAnnotationSource(annotation))?.let {
|
||||
processAnnotationArguments(it, annotation, annotationType)
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,9 @@ private object ReflectClassStructure {
|
||||
for ((parameterIndex, annotations) in parameterAnnotations.withIndex()) {
|
||||
for (annotation in annotations) {
|
||||
val annotationType = annotation.annotationType()
|
||||
visitor.visitParameterAnnotation(parameterIndex + shift, annotationType.classId)?.let {
|
||||
visitor.visitParameterAnnotation(
|
||||
parameterIndex + shift, annotationType.classId, ReflectAnnotationSource(annotation)
|
||||
)?.let {
|
||||
processAnnotationArguments(it, annotation, annotationType)
|
||||
}
|
||||
}
|
||||
@@ -155,7 +157,7 @@ private object ReflectClassStructure {
|
||||
|
||||
private fun processAnnotation(visitor: KotlinJvmBinaryClass.AnnotationVisitor, annotation: Annotation) {
|
||||
val annotationType = annotation.annotationType()
|
||||
visitor.visitAnnotation(annotationType.classId)?.let {
|
||||
visitor.visitAnnotation(annotationType.classId, ReflectAnnotationSource(annotation))?.let {
|
||||
processAnnotationArguments(it, annotation, annotationType)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user