Search in sources :

Example 1 with KotlinRetention

use of org.jetbrains.kotlin.descriptors.annotations.KotlinRetention in project kotlin by JetBrains.

the class ExpressionVisitor method visitAnnotatedExpression.

@Override
public JsNode visitAnnotatedExpression(@NotNull KtAnnotatedExpression expression, TranslationContext context) {
    for (KtAnnotationEntry entry : expression.getAnnotationEntries()) {
        AnnotationDescriptor descriptor = context.bindingContext().get(BindingContext.ANNOTATION, entry);
        if (descriptor == null)
            continue;
        ClassifierDescriptor classifierDescriptor = descriptor.getType().getConstructor().getDeclarationDescriptor();
        if (classifierDescriptor == null)
            continue;
        KotlinRetention retention = DescriptorUtilsKt.getAnnotationRetention(classifierDescriptor);
        if (retention == KotlinRetention.SOURCE) {
            KtExpression baseExpression = expression.getBaseExpression();
            if (baseExpression == null)
                continue;
            return baseExpression.accept(this, context);
        }
    }
    return super.visitAnnotatedExpression(expression, context);
}
Also used : AnnotationDescriptor(org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor) KotlinRetention(org.jetbrains.kotlin.descriptors.annotations.KotlinRetention)

Aggregations

AnnotationDescriptor (org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor)1 KotlinRetention (org.jetbrains.kotlin.descriptors.annotations.KotlinRetention)1