Last active
July 15, 2021 18:55
-
-
Save Morfly/13bae6e82c7ba76537dc036589134a30 to your computer and use it in GitHub Desktop.
KSP, function processor, process function complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FunctionProcessor(...) : SymbolProcessor { | |
override fun process(resolver: Resolver): List<KSAnnotated> { | |
val symbols = resolver | |
.getSymbolsWithAnnotation("com.morfly.Function") | |
.filterIsInstance<KSClassDeclaration>() | |
if (!symbols.iterator().hasNext()) return emptyList() | |
val file: OutputStream = codeGenerator.createNewFile( | |
dependencies = Dependencies(false), | |
packageName = "com.morfly", | |
fileName = "GeneratedFunctions" | |
) | |
file += "package com.morfly\n" | |
symbols.forEach { it.accept(Visitor(file), Unit) } | |
file.close() | |
val unableToProcess = symbols.filterNot { it.validate() }.toList() | |
return unableToProcess | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment