Support package level annotations in Java

#KT-10942 In Progress
This commit is contained in:
Denis Zharkov
2017-07-02 15:17:46 +03:00
parent b7ead75947
commit 79e14f88e4
15 changed files with 222 additions and 21 deletions
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
import org.jetbrains.kotlin.load.java.lazy.resolveAnnotations
import org.jetbrains.kotlin.load.java.structure.JavaClass
import org.jetbrains.kotlin.load.java.structure.JavaPackage
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryPackageSourceElement
@@ -48,6 +49,11 @@ class LazyJavaPackageFragment(
onRecursiveCall = listOf()
)
private val packageAnnotations = c.resolveAnnotations(jPackage)
// Test only method
fun getPackageAnnotations() = packageAnnotations
internal fun getSubPackageFqNames(): List<FqName> = subPackages()
internal fun findClassifierByJavaClass(jClass: JavaClass): ClassDescriptor? = scope.javaScope.findClassifierByJavaClass(jClass)
@@ -63,6 +63,7 @@ fun JavaAnnotationOwner.buildLazyValueForMap() = lazy {
annotations.associateBy { it.classId?.asSingleFqName() }
}
interface JavaPackage : JavaElement, JavaAnnotationOwner {
val fqName: FqName
val subPackages: Collection<JavaPackage>