From 5dabde23e6e6dec1135c14c223d324150a96963a Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Wed, 7 Apr 2021 13:44:26 -0700 Subject: [PATCH] * Add getDeclarationsFromPackage to entry points in incremental document. * Reorganized getDeclarationsFromPackage implementation. --- .../google/devtools/ksp/processing/impl/ResolverImpl.kt | 8 ++++---- docs/incremental.md | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt index 18ef9a93c3..e477a818f9 100644 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt +++ b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt @@ -598,11 +598,11 @@ class ResolverImpl( @KspExperimental override fun getDeclarationsFromPackage(packageName: String): Sequence { - module.getPackage(FqName(packageName)).memberScope - val res = (module as ModuleDescriptorImpl).packageFragmentProvider.packageFragments(FqName(packageName)) - .flatMap{ it.getMemberScope().getContributedDescriptors() } + val noPackageFilter = DescriptorKindFilter.ALL.withoutKinds(DescriptorKindFilter.PACKAGES_MASK) + return module.getPackage(FqName(packageName)) + .memberScope.getContributedDescriptors(noPackageFilter) .mapNotNull { (it as? MemberDescriptor)?.toKSDeclaration() } - return res.asSequence() + .asSequence() } override fun getTypeArgument(typeRef: KSTypeReference, variance: Variance): KSTypeArgument { diff --git a/docs/incremental.md b/docs/incremental.md index 231a5de2e3..f77706357b 100644 --- a/docs/incremental.md +++ b/docs/incremental.md @@ -13,6 +13,7 @@ words, a processor needs to associate an output with the sources of the correspo * `Resolver.getAllFiles` * `Resolver.getSymbolsWithAnnotation` * `Resolver.getClassDeclarationByName` +* `Resolver.getDeclarationsFromPackage` Currently, only changes in Kotlin and Java sources are tracked. Changes to the classpath, namely to other modules or libraries, trigger a full re-processing of all sources.