All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.dataframe.ksp.DataFrameSymbolProcessor.kt Maven / Gradle / Ivy

There is a newer version: 1727
Show newest version
package org.jetbrains.dataframe.ksp

import com.google.devtools.ksp.processing.KSPLogger
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.symbol.KSAnnotated

class DataFrameSymbolProcessor(
    private val codeGenerator: com.google.devtools.ksp.processing.CodeGenerator,
    private val logger: KSPLogger,
    private val resolutionDir: String?,
) : SymbolProcessor {

    override fun process(resolver: Resolver): List {
        val extensionsGenerator = ExtensionsGenerator(resolver, codeGenerator, logger)
        val (validDataSchemas, invalidDataSchemas) = extensionsGenerator.resolveDataSchemaDeclarations()
        validDataSchemas.forEach {
            val file = it.origin.containingFile ?: return@forEach
            extensionsGenerator.generateExtensions(file, it.origin, it.properties)
        }

        val dataSchemaGenerator = DataSchemaGenerator(resolver, resolutionDir, logger, codeGenerator)
        val importStatements = dataSchemaGenerator.resolveImportStatements()
        importStatements.forEach { importStatement ->
            dataSchemaGenerator.generateDataSchema(importStatement)
        }

        // by returning invalidDataSchemas we defer the processing of incomplete DataSchema declarations
        // for example when DataSchema declaration references another one generated by @file:ImportDataSchema
        return invalidDataSchemas
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy