Search in sources :

Example 1 with LazyAnnotationsContextImpl

use of org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl in project kotlin by JetBrains.

the class AnnotationResolverImpl method resolveAnnotationEntries.

@NotNull
@Override
public Annotations resolveAnnotationEntries(@NotNull LexicalScope scope, @NotNull List<KtAnnotationEntry> annotationEntryElements, @NotNull BindingTrace trace, boolean shouldResolveArguments) {
    if (annotationEntryElements.isEmpty())
        return Annotations.Companion.getEMPTY();
    List<AnnotationWithTarget> result = new ArrayList<AnnotationWithTarget>(0);
    for (KtAnnotationEntry entryElement : annotationEntryElements) {
        AnnotationDescriptor descriptor = trace.get(BindingContext.ANNOTATION, entryElement);
        if (descriptor == null) {
            descriptor = new LazyAnnotationDescriptor(new LazyAnnotationsContextImpl(this, storageManager, trace, scope), entryElement);
        }
        if (shouldResolveArguments) {
            ForceResolveUtil.forceResolveAllContents(descriptor);
        }
        KtAnnotationUseSiteTarget target = entryElement.getUseSiteTarget();
        if (target != null) {
            result.add(new AnnotationWithTarget(descriptor, target.getAnnotationUseSiteTarget()));
        } else {
            result.add(new AnnotationWithTarget(descriptor, null));
        }
    }
    return AnnotationsImpl.create(result);
}
Also used : LazyAnnotationDescriptor(org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor) LazyAnnotationDescriptor(org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor) ArrayList(java.util.ArrayList) LazyAnnotationsContextImpl(org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with LazyAnnotationsContextImpl

use of org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl in project kotlin by JetBrains.

the class ResolveSession method createAnnotations.

private LazyAnnotations createAnnotations(KtFile file, List<KtAnnotationEntry> annotationEntries) {
    LexicalScope scope = fileScopeProvider.getFileResolutionScope(file);
    LazyAnnotationsContextImpl lazyAnnotationContext = new LazyAnnotationsContextImpl(annotationResolver, storageManager, trace, scope);
    return new LazyAnnotations(lazyAnnotationContext, annotationEntries);
}
Also used : LexicalScope(org.jetbrains.kotlin.resolve.scopes.LexicalScope) LazyAnnotations(org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotations) LazyAnnotationsContextImpl(org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl)

Aggregations

LazyAnnotationsContextImpl (org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl)2 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 LazyAnnotationDescriptor (org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor)1 LazyAnnotations (org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotations)1 LexicalScope (org.jetbrains.kotlin.resolve.scopes.LexicalScope)1