diff --git a/core/build.gradle.kts b/core/build.gradle.kts index c308a017ae..6f861e0bad 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -26,37 +26,6 @@ repositories { maven(jupyterApiTCRepo) } -val introspect by sourceSets.creating { - withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { - kotlin.srcDir("src/main/kotlin") - compileClasspath += sourceSets.main.get().output - runtimeClasspath += sourceSets.main.get().output - } -} - -val introspectImplementation by configurations.getting { - extendsFrom(configurations.implementation.get()) -} - -val introspectCompileOnly by configurations.getting { - extendsFrom(configurations.compileOnly.get()) -} -//val introspect by sourceSets.creating { -// withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) { -// kotlin.srcDir("src/main/kotlin") -// compileClasspath += sourceSets.main.get().output -// runtimeClasspath += sourceSets.main.get().output -// } -//} -// -//val introspectImplementation by configurations.getting { -// extendsFrom(configurations.implementation.get()) -//} -// -//val introspectCompileOnly by configurations.getting { -// extendsFrom(configurations.compileOnly.get()) -//} - dependencies { api(libs.kotlin.reflect) implementation(libs.kotlin.stdlib) @@ -77,8 +46,6 @@ dependencies { testImplementation(libs.jsoup) testImplementation(kotlin("compiler-embeddable")) -// val kotlinCompilerPluginClasspathIntrospect by configurations.getting -// kotlinCompilerPluginClasspathIntrospect(project(":plugins:dataframe-introspection")) } kotlin.sourceSets { diff --git a/plugins/dataframe-introspection/README.md b/plugins/dataframe-introspection/README.md deleted file mode 100644 index e8e29210c4..0000000000 --- a/plugins/dataframe-introspection/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## DataFrame introspection - -Purpose of this plugin is to help with prototyping of the "extensible dataframes" compiler plugin: automate related tasks, validate assumptions, examine DataFrame API structure using IR diff --git a/plugins/dataframe-introspection/build.gradle.kts b/plugins/dataframe-introspection/build.gradle.kts deleted file mode 100644 index 0054bff500..0000000000 --- a/plugins/dataframe-introspection/build.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - kotlin("jvm") -} - -group = "org.jetbrains.kotlinx" - -repositories { - mavenCentral() - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap") -} - -dependencies { -// implementation(project(":")) -// implementation(kotlin("compiler-embeddable")) - - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") -} - -tasks.getByName("test") { - useJUnitPlatform() -} diff --git a/plugins/dataframe-introspection/src/main/kotlin/Fir.kt b/plugins/dataframe-introspection/src/main/kotlin/Fir.kt deleted file mode 100644 index 310501de61..0000000000 --- a/plugins/dataframe-introspection/src/main/kotlin/Fir.kt +++ /dev/null @@ -1,52 +0,0 @@ -import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker -import org.jetbrains.kotlin.fir.analysis.extensions.FirAdditionalCheckersExtension -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar -import org.jetbrains.kotlin.fir.psi -import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import org.jetbrains.kotlinx.dataframe.api.toDataFrame -import java.util.concurrent.atomic.AtomicBoolean - -class MyFirExtensionRegistrar(val functions: MutableList) : FirExtensionRegistrar() { - - override fun ExtensionRegistrarContext.configurePlugin() { - +{ session: FirSession -> FunctionCollector(session, functions) } - } -} - -class FunctionCollector(session: FirSession, val functions: MutableList) : FirAdditionalCheckersExtension(session) { - - override val declarationCheckers: DeclarationCheckers = object : DeclarationCheckers() { - override val functionCheckers: Set - get() = setOf(NoopChecker(functions)) - } - - internal class NoopChecker(val functions: MutableList) : FirFunctionChecker() { - override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { - functions.add(declaration) - } - } -} - -class FunctionSaver(val functions: MutableList) : IrGenerationExtension { - private val done = AtomicBoolean(false) - override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { - if (done.getAndSet(true)) { - functions.forEach { - it.returnTypeRef.psi - } - val df = functions.toDataFrame { - properties(maxDepth = 2) { -// exclude() - } - } - } - - } -} diff --git a/plugins/dataframe-introspection/src/main/kotlin/Main.kt b/plugins/dataframe-introspection/src/main/kotlin/Main.kt deleted file mode 100644 index 10bb75f1f2..0000000000 --- a/plugins/dataframe-introspection/src/main/kotlin/Main.kt +++ /dev/null @@ -1,136 +0,0 @@ -import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.backend.common.ir.isTopLevel -import org.jetbrains.kotlin.com.intellij.mock.MockProject -import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.util.render -import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid -import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlinx.dataframe.AnyFrame -import org.jetbrains.kotlinx.dataframe.DataColumn -import org.jetbrains.kotlinx.dataframe.api.dataFrameOf -import org.jetbrains.kotlinx.dataframe.api.dfsOf -import org.jetbrains.kotlinx.dataframe.api.map -import org.jetbrains.kotlinx.dataframe.api.remove -import org.jetbrains.kotlinx.dataframe.api.replace -import org.jetbrains.kotlinx.dataframe.api.schema -import org.jetbrains.kotlinx.dataframe.api.toDataFrame -import org.jetbrains.kotlinx.dataframe.api.update -import org.jetbrains.kotlinx.dataframe.api.valueCounts -import org.jetbrains.kotlinx.dataframe.api.with -import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup -import org.jetbrains.kotlinx.dataframe.io.toCsv -import org.jetbrains.kotlinx.dataframe.io.writeJson -import java.io.File - -class MyComponentRegistrar : ComponentRegistrar { - - override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) { -// val functions = mutableListOf() -// FirExtensionRegistrar.registerExtension(project, MyFirExtensionRegistrar(functions)) -// IrGenerationExtension.registerExtension(project, FunctionSaver(functions)) -// IrGenerationExtension.registerExtension(project, FunctionVisitor()) - } -} - -class FunctionVisitor : IrGenerationExtension { - - override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { - val functions = mutableListOf() - val classes = mutableListOf() - - val visitor = object : IrElementVisitorVoid { - override fun visitElement(element: IrElement) { - element.acceptChildrenVoid(this) - } - - override fun visitFunction(declaration: IrFunction) { - functions.add(declaration) - } - - override fun visitClass(declaration: IrClass) { - classes += declaration - } - } - moduleFragment.files.forEach { - visitor.visitFile(it) - } - val root: File = TODO("setup env variable to point output dir for the plugin") - functions - .toDataFrame { - properties(maxDepth = 2) { - preserve(Name::class) - preserve(IrType::class) - exclude(IrFunction::returnType) - } - add("isTopLevel") { it.isTopLevel } - add("returnType") { - (it.returnType as? IrSimpleType) - } - } - .also { File(root, "IrType").writeText(it[IrFunction::returnType].map { it::class }.valueCounts().toCsv()) } - .remove { - dfs { it.name in setOf("descriptor", "startOffset", "endOffset", "factory") } - } - .update { dfsOf() }.with { - it.remove { dfs { it.name in setOf("descriptor", "startOffset", "endOffset", "factory") } } - } - .replace { dfsOf() }.with { col -> - col.nameColumnGroup() - } -// .replace { dfsOf() }.with { col -> -// col.map { -//// it?.classFqName?.asString() -// it?.render() -// } -// } - .update { dfsOf() }.with { - it.replace { dfsOf() }.with { col -> - col.map { - it?.render() - } - } - } - .also { File(root, "functions_schema").writeText(it.schema().toString()) } - .writeJson(File(root, "functions")) - - -// classes -// .toDataFrame { -// properties(maxDepth = 2) { -// preserve(Name::class) -// include(IrClass::properties) { it?.toList() } -// include(IrClass::functions) { it?.toList() } -// include(IrClass::primaryConstructor) -// } -// } -// .remove { -// dfs { it.name in setOf("descriptor", "startOffset", "endOffset", "factory") } -// } -// .update { dfsOf() }.with { -// it.remove { dfs { it.name in setOf("descriptor", "startOffset", "endOffset", "factory") } } -// } -// .replace { dfsOf() }.with { -// it.nameColumnGroup() -// } -// .also { File(root, "classes_schema").writeText(it.schema().toString()) } -// .writeJson(File(root, "classes")) - } - - private fun DataColumn.nameColumnGroup(): ColumnGroup { - val col1 = map { it.identifierOrNullIfSpecial }.rename("identifier") - val col2 = map { it.asString() }.rename("name") - val col3 = map { it.isSpecial }.rename("isSpecial") - return DataColumn.createColumnGroup(name(), dataFrameOf(col1, col2, col3)) - } -} - - diff --git a/plugins/dataframe-introspection/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar b/plugins/dataframe-introspection/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar deleted file mode 100644 index 592f2838a5..0000000000 --- a/plugins/dataframe-introspection/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar +++ /dev/null @@ -1 +0,0 @@ -MyComponentRegistrar diff --git a/settings.gradle.kts b/settings.gradle.kts index 457ae7818e..648322ba5d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,7 +39,5 @@ plugins { } include("dataframe-excel") include("core") -//include("plugins:dataframe-introspection") -//findProject(":plugins:dataframe-introspection")?.name = "dataframe-introspection" //includeBuild("plugins/extensible-dataframes") //findProject(":plugins:extensible-dataframes")?.name = "extensible-dataframes"