Skip to content

Commit

Permalink
correction to ksp-examples with updated function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed Oct 2, 2023
1 parent 2d52822 commit 2af4239
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions docs/topics/ksp/ksp-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Get all member functions

```kotlin
fun KSClassDeclaration.getDeclaredFunctions(): List<KSFunctionDeclaration> =
fun KSClassDeclaration.getDeclaredFunctions(): Sequence<KSFunctionDeclaration> =
declarations.filterIsInstance<KSFunctionDeclaration>()
```

Expand Down Expand Up @@ -31,14 +31,13 @@ fun KSTypeAlias.findActualType(): KSClassDeclaration {

```kotlin
// @file:kotlin.Suppress("Example1", "Example2")
fun KSFile.suppressedNames(): List<String> {
val ignoredNames = mutableListOf<String>()
annotations.filter {
it.shortName.asString() == "Suppress" && it.annotationType.resolve()?.declaration?.qualifiedName?.asString() == "kotlin.Suppress"
}.forEach {
val argValues: List<String> = it.arguments.flatMap { it.value }
ignoredNames.addAll(argValues)
fun KSFile.suppressedNames(): Sequence<String> = annotations
.filter {
it.shortName.asString() == "Suppress" &&
it.annotationType.resolve().declaration.qualifiedName?.asString() == "kotlin.Suppress"
}.flatMap {
it.arguments.flatMap {
(it.value as Array<String>).toList()
}
}
return ignoredNames
}
```

0 comments on commit 2af4239

Please sign in to comment.