Skip to content

Commit

Permalink
Make originalAnnotations lazy
Browse files Browse the repository at this point in the history
Otherwise all annotations are resolved unconditionally when we index
KSFiles.

(cherry picked from commit 1884e53)
  • Loading branch information
ting-yuan authored and KSP Auto Pick committed Jun 4, 2024
1 parent e34a635 commit 76bf45d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ abstract class AbstractKSDeclarationImpl(val ktDeclarationSymbol: KtDeclarationS
override val docString: String?
get() = ktDeclarationSymbol.toDocString()

internal val originalAnnotations = if (ktDeclarationSymbol.psi is KtElement || ktDeclarationSymbol.psi == null) {
ktDeclarationSymbol.annotations(this)
} else {
(ktDeclarationSymbol.psi as PsiJvmModifiersOwner)
.annotations.map { KSAnnotationJavaImpl.getCached(it, this) }.asSequence()
internal val originalAnnotations: Sequence<KSAnnotation> by lazy {
if (ktDeclarationSymbol.psi is KtElement || ktDeclarationSymbol.psi == null) {
ktDeclarationSymbol.annotations(this)
} else {
(ktDeclarationSymbol.psi as PsiJvmModifiersOwner)
.annotations.map { KSAnnotationJavaImpl.getCached(it, this) }.asSequence()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ abstract class KSPropertyAccessorImpl(
.plus(findAnnotationFromUseSiteTarget())
}

internal val originalAnnotations = ktPropertyAccessorSymbol.annotations(this)
internal val originalAnnotations: Sequence<KSAnnotation> by lazy {
ktPropertyAccessorSymbol.annotations(this)
}

override val location: Location by lazy {
ktPropertyAccessorSymbol.psi?.toLocation() ?: NonExistLocation
Expand Down

0 comments on commit 76bf45d

Please sign in to comment.