Skip to content

Commit

Permalink
A bit of documentation and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed May 30, 2022
1 parent 66031d9 commit 2e038d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/main/kotlin/api/AsmMetadataLoading.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ fun ClassNode.isDefaultImpls(metadata: KotlinClassMetadata?) = isInner() && name

fun ClassNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) =
findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible)
fun MethodNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) =
findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible)
fun FieldNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) =
findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible)

operator fun AnnotationNode.get(key: String): Any? = values.annotationValue(key)

private fun List<Any>.annotationValue(key: String): Any? {
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/api/KotlinMetadataSignature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package kotlinx.validation.api

import kotlinx.metadata.jvm.*
import kotlinx.validation.*
import org.objectweb.asm.Opcodes
import org.objectweb.asm.*
import org.objectweb.asm.tree.*

@ExternalApi // Only name is part of the API, nothing else is used by stdlib
Expand Down Expand Up @@ -94,6 +94,12 @@ internal fun MethodNode.alternateDefaultSignature(className: String): JvmMethodS
}

fun MethodNode.toMethodBinarySignature(
/*
* Extra annotations are:
* * Annotations from the original method for synthetic `$default` method
* * Annotations from getter, setter or field for synthetic `$annotation` method
* * Annotations from a field for getter and setter
*/
extraAnnotations: List<AnnotationNode>,
alternateDefaultSignature: JvmMethodSignature?
): MethodBinarySignature {
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/api/KotlinSignaturesLoading.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public fun Sequence<InputStream>.loadApiFromJvmClasses(visibilityFilter: (String
val annotationHolders =
mVisibility?.members?.get(JvmMethodSignature(it.name, it.desc))?.propertyAnnotation
val foundAnnotations = ArrayList<AnnotationNode>()
foundAnnotations += fields.annotationsFor(annotationHolders?.field)
foundAnnotations += methods.annotationsFor(annotationHolders?.method)
if (annotationHolders != null) {
foundAnnotations += fields.annotationsFor(annotationHolders.field)
foundAnnotations += methods.annotationsFor(annotationHolders.method)
}

/**
* For synthetic $default methods, pull the annotations from the corresponding method
Expand Down

0 comments on commit 2e038d6

Please sign in to comment.