From 2af4239132dc11c513d0676146395aebd62f8e87 Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Mon, 2 Oct 2023 16:48:53 -0700 Subject: [PATCH] correction to ksp-examples with updated function signature --- docs/topics/ksp/ksp-examples.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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