From 15f7295645fc32d3d9ae501b480a29b11b5cc505 Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Tue, 3 Oct 2023 05:39:32 +0000 Subject: [PATCH] fix: correction to ksp-examples with updated function signature (#3806) --- 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