Skip to content

Commit

Permalink
AA: Handle AnnotationTarget.VALUE_PARAMETER for property declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed Nov 29, 2022
1 parent 318914a commit 7d8cace
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ class KSPropertyDeclarationImpl private constructor(internal val ktPropertySymbo
ktPropertySymbol.annotations.asSequence()
.filter { !it.isUseSiteTargetAnnotation() }
.map { KSAnnotationImpl.getCached(it) }
.filterNot { valueParameterAnnotation ->
valueParameterAnnotation.annotationType.resolve().declaration.annotations.any { metaAnnotation ->
metaAnnotation.annotationType.resolve().declaration.qualifiedName
?.asString() == "kotlin.annotation.Target" &&
(metaAnnotation.arguments.singleOrNull()?.value as? ArrayList<*>)?.any {
(it as? KSClassDeclaration)?.qualifiedName
?.asString() == "kotlin.annotation.AnnotationTarget.VALUE_PARAMETER"
} ?: false
}
}
}

override val getter: KSPropertyGetter? by lazy {
Expand Down Expand Up @@ -99,7 +109,8 @@ internal fun KtAnnotationApplication.isUseSiteTargetAnnotation(): Boolean {
return this.useSiteTarget?.let {
it == AnnotationUseSiteTarget.PROPERTY_GETTER ||
it == AnnotationUseSiteTarget.PROPERTY_SETTER ||
it == AnnotationUseSiteTarget.SETTER_PARAMETER
it == AnnotationUseSiteTarget.SETTER_PARAMETER ||
it == AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
} ?: false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class KSValueArgumentImpl private constructor(
private fun KtAnnotationValue.toValue(): Any? = when (this) {
is KtArrayAnnotationValue -> this.values.map { it.toValue() }
is KtAnnotationApplicationValue -> KSAnnotationImpl.getCached(this.annotationValue)
// TODO: Enum entry should return a type, use declaration as a placeholder.
is KtEnumEntryAnnotationValue -> this.callableId?.classId?.let {
analyze {
it.toKtClassSymbol()?.let {
Expand Down

0 comments on commit 7d8cace

Please sign in to comment.