Skip to content

Commit

Permalink
Return KSClassDeclarationEnumEntryImpl for enum entry annotation values.
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed May 15, 2024
1 parent 51c8e7b commit c59f7bb
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 @@ -89,7 +89,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 c59f7bb

Please sign in to comment.