Skip to content

Commit

Permalink
Adapt to KSP2 API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FooIbar committed May 22, 2024
1 parent 11b06ea commit b3c047f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,13 @@ fun KSValueParameter.toParameter(
)
}

fun KSType.toGenVisibility(): Visibility {
fun Any.toGenVisibility(): Visibility {
val declaration = if (this is KSType) {
declaration
} else {
// KSP 2
this as KSClassDeclaration
}
return when (val visibility = declaration.simpleName.asString()) {
"PUBLIC" -> Visibility.PUBLIC
"INTERNAL" -> Visibility.INTERNAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ internal class KspToCodeGenDestinationsMapper(
}

private fun KSAnnotation.getDestinationVisibility(): Visibility? {
return findArgumentValue<KSType>("visibility")?.toGenVisibility()
return findArgumentValue<Any>("visibility")?.toGenVisibility()
}

private fun KSAnnotation.prepareRoute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class KspToCodeGenNavGraphsMapper(
val navGraphAnnotationNameArg = navGraphAnnotation
.findArgumentValue<String>(DESTINATION_ANNOTATION_ROUTE_ARGUMENT)
val navGraphVisibility = navGraphAnnotation
.findArgumentValue<KSType>("visibility")!!
.findArgumentValue<Any>("visibility")!!
.toGenVisibility()
val navGraphDefaultTransitions = navGraphAnnotation
.findArgumentValue<KSType>("defaultTransitions")
Expand Down

0 comments on commit b3c047f

Please sign in to comment.