Skip to content

Commit

Permalink
Return KSClassDeclarationEnumEntryImpl for enum entry annotation values.
Browse files Browse the repository at this point in the history
(cherry picked from commit c59f7bb)
  • Loading branch information
neetopia committed May 17, 2024
1 parent 78dea60 commit 0c5a4f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.devtools.ksp.common.KSObjectCache
import com.google.devtools.ksp.common.impl.KSNameImpl
import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.impl.ResolverAAImpl
import com.google.devtools.ksp.impl.symbol.kotlin.KSClassDeclarationEnumEntryImpl
import com.google.devtools.ksp.impl.symbol.kotlin.KSErrorType
import com.google.devtools.ksp.impl.symbol.kotlin.KSValueArgumentImpl
import com.google.devtools.ksp.impl.symbol.kotlin.analyze
Expand Down Expand Up @@ -202,10 +203,7 @@ fun calcValue(value: PsiAnnotationMemberValue?): Any? {
}?.declarations?.find {
it is KSClassDeclaration && it.classKind == ClassKind.ENUM_ENTRY &&
it.simpleName.asString() == result.name
}?.let { (it as KSClassDeclaration).asStarProjectedType() }
?.let {
return it
}
} as? KSClassDeclarationEnumEntryImpl
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ class KSClassDeclarationEnumEntryImpl private constructor(private val ktEnumEntr
ktEnumEntrySymbol.psi.toLocation()
}

override val parent: KSNode? by lazy {
override val parent: KSNode by lazy {
analyze {
(ktEnumEntrySymbol.getContainingSymbol() as? KtNamedClassOrObjectSymbol)
?.let { KSClassDeclarationImpl.getCached(it) }
(ktEnumEntrySymbol.getContainingSymbol() as KtNamedClassOrObjectSymbol)
.let { KSClassDeclarationImpl.getCached(it) }
}
}

Expand Down
4 changes: 2 additions & 2 deletions kotlin-analysis-api/testData/annotationValue/java.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
// Array
// @Foo
// @Suppress
// RGB
// JavaEnum
// G
// ONE
// 31
// [warning1, warning 2]
// END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class KSPAATest : AbstractKSPAATest() {
runTest("../kotlin-analysis-api/testData/annotationValue/java.kt")
}

@Disabled
@TestMetadata("annotationValue_kt.kt")
@Test
fun testAnnotationValue_kt() {
Expand Down

0 comments on commit 0c5a4f0

Please sign in to comment.