Hey guys, Does anybody know why this piece create ...
# ksp
a
Hey guys, Does anybody know why this piece create an infinite number of files?
Copy code
override fun process(resolver: Resolver): List<KSAnnotated> {
        val time = System.currentTimeMillis()
        logger.warn("Running $time")
        codeGenerator.createNewFile(
            dependencies = Dependencies.ALL_FILES,
            packageName = "sample.demo",
            fileName = "File_$time"
        ).close()

        return emptyList()
    }
e
when new files are created all processors are given them in order to process them for the next round. This continues until all processors don't write a file (or error out). You are creating a new file each time so there's always something new to process.
✔️ 1
a
So basically because I create a new file, there’s a new file to be scanned, which creates a new file and so on so forth?
e
yep
a
but doesn’t the processor run only once, for all the files?
process
runs once for every file ?
e
it runs once for all file per round. So round 1 would get the initial files, then round 2 would get the output of everything from round 1, etc.
you can't be given files that don't exist yet 😉
a
oooh so let’s say i have File1, File2. It runs first time for them, i create File3 and then runs for File3 only ?
e
yep
a
man, you’re of great help! thank you!
e
well specifically that's the value of resolver.newFiles()
a
Can you direct me to some resource where I can learn more ?
e
a
that was my main point of documentation too.
Ya, thank you again for your help
e
np!