Skip to content

KotlinAnnotationsResolver

KotlinAnnotationsResolver matches declarations with their annotations and vice versa.

This service can produce both false positives and false negatives, since it might not be allowed to use full resolution to understand the true FqName of a used annotation.

The next statement should be true for any annotation:

declarationsByAnnotation(annotation).all { declaration ->
  annotation in annotationsOnDeclaration(declaration)
}

Functions

annotationsOnDeclaration

abstract fun annotationsOnDeclaration(declaration: KtAnnotated): Set<ClassId>

Returns an approximate set of annotation ClassIds which have been applied to declaration. The set may contain both false positives and false negatives.

Parameters

declarationsByAnnotation

abstract fun declarationsByAnnotation(annotationClassId: ClassId): Set<KtAnnotated>

Returns an approximate set of KtAnnotated declarations which have an annotation with the given annotationClassId applied to them. The set may contain both false positives and false negatives.