Minor refactoring in deprecationUtil.kt

Split getDeclaredDeprecatedAnnotation into two methods for clarity
This commit is contained in:
Alexander Udalov
2016-12-14 14:22:37 +03:00
parent 122c631fcf
commit 82703d9cfd
@@ -136,7 +136,7 @@ private fun deprecationByOverridden(root: CallableMemberDescriptor): Deprecation
}
private fun DeclarationDescriptor.getDeprecationByAnnotation(): DeprecatedByAnnotation? {
val ownAnnotation = getDeclaredDeprecatedAnnotation(AnnotationUseSiteTarget.getAssociatedUseSiteTarget(this))
val ownAnnotation = getDeclaredDeprecatedAnnotation(AnnotationUseSiteTarget.getAssociatedUseSiteTarget(this), true)
if (ownAnnotation != null)
return DeprecatedByAnnotation(ownAnnotation, this)
@@ -168,12 +168,16 @@ private fun DeclarationDescriptor.getDeprecationByAnnotation(): DeprecatedByAnno
return null
}
private fun DeclarationDescriptor.getDeclaredDeprecatedAnnotation(): AnnotationDescriptor? {
return annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: annotations.findAnnotation(JAVA_DEPRECATED)
}
private fun DeclarationDescriptor.getDeclaredDeprecatedAnnotation(
target: AnnotationUseSiteTarget? = null,
findAnnotationsWithoutTarget: Boolean = true
target: AnnotationUseSiteTarget?,
findAnnotationsWithoutTarget: Boolean
): AnnotationDescriptor? {
if (findAnnotationsWithoutTarget) {
val annotations = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: annotations.findAnnotation(JAVA_DEPRECATED)
val annotations = getDeclaredDeprecatedAnnotation()
if (annotations != null) return annotations
}