Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to KSP2 API changes #643

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adapt to KSP2 API changes
  • Loading branch information
FooIbar committed May 22, 2024
commit b3c047f31878bc6a250f702579d07c362f574ce0
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