diff --git a/docs/topics/ksp/ksp-examples.md b/docs/topics/ksp/ksp-examples.md index 41b6e33e602..83ee768d23c 100644 --- a/docs/topics/ksp/ksp-examples.md +++ b/docs/topics/ksp/ksp-examples.md @@ -3,7 +3,7 @@ ## Get all member functions ```kotlin -fun KSClassDeclaration.getDeclaredFunctions(): List = +fun KSClassDeclaration.getDeclaredFunctions(): Sequence = declarations.filterIsInstance() ``` @@ -31,14 +31,13 @@ fun KSTypeAlias.findActualType(): KSClassDeclaration { ```kotlin // @file:kotlin.Suppress("Example1", "Example2") -fun KSFile.suppressedNames(): List { - val ignoredNames = mutableListOf() - annotations.filter { - it.shortName.asString() == "Suppress" && it.annotationType.resolve()?.declaration?.qualifiedName?.asString() == "kotlin.Suppress" - }.forEach { - val argValues: List = it.arguments.flatMap { it.value } - ignoredNames.addAll(argValues) +fun KSFile.suppressedNames(): Sequence = annotations + .filter { + it.shortName.asString() == "Suppress" && + it.annotationType.resolve().declaration.qualifiedName?.asString() == "kotlin.Suppress" + }.flatMap { + it.arguments.flatMap { + (it.value as Array).toList() + } } - return ignoredNames -} ``` \ No newline at end of file