From 63c30614d65311b83260007a1fc70f4c3ead9793 Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Wed, 24 Aug 2022 15:25:04 +0300 Subject: [PATCH] Setup project with KotlinType operations API for plugin --- core/build.gradle.kts | 1 + settings.gradle.kts | 2 +- type-api/build.gradle.kts | 32 +++++++++++++ type-api/settings.gradle.kts | 2 + .../org/jetbrains/kotlinx/dataframe/Main.kt | 46 +++++++++++++++++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 type-api/build.gradle.kts create mode 100644 type-api/settings.gradle.kts create mode 100644 type-api/src/main/kotlin/org/jetbrains/kotlinx/dataframe/Main.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 83cedf6063..ba950d3806 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -45,6 +45,7 @@ dependencies { implementation(libs.kotlin.stdlib.jdk8) // TODO: check if all compiler tests run pass with implementation api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0-RC") + api(project(":type-api")) api(libs.commonsCsv) implementation(libs.klaxon) diff --git a/settings.gradle.kts b/settings.gradle.kts index 79f8d5a5b6..b4a63339e4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,4 +35,4 @@ include("dataframe-excel") include("core") include("plugins:dataframe-introspection") findProject(":plugins:dataframe-introspection")?.name = "dataframe-introspection" - +include("type-api") diff --git a/type-api/build.gradle.kts b/type-api/build.gradle.kts new file mode 100644 index 0000000000..960aa36c07 --- /dev/null +++ b/type-api/build.gradle.kts @@ -0,0 +1,32 @@ +plugins { + kotlin("jvm") version "1.7.10" + id("java") + kotlin("libs.publisher") version "0.0.60-dev-30" +} + +group = "org.jetbrains.kotlinx.dataframe" +version = "0.9.0-dev" + +repositories { + mavenCentral() +} + +dependencies { + compileOnly(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() +} + +kotlinPublications { + publication { + publicationName.set("api") + artifactId.set("types-api") + description.set("Data processing in Kotlin") + packageName.set(artifactId) + } +} + diff --git a/type-api/settings.gradle.kts b/type-api/settings.gradle.kts new file mode 100644 index 0000000000..88d478bfd2 --- /dev/null +++ b/type-api/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "type-api" + diff --git a/type-api/src/main/kotlin/org/jetbrains/kotlinx/dataframe/Main.kt b/type-api/src/main/kotlin/org/jetbrains/kotlinx/dataframe/Main.kt new file mode 100644 index 0000000000..357769cf16 --- /dev/null +++ b/type-api/src/main/kotlin/org/jetbrains/kotlinx/dataframe/Main.kt @@ -0,0 +1,46 @@ +package org.jetbrains.kotlinx.dataframe + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +val DF_CLASS_ID: ClassId + get() = ClassId.topLevel(FqName.fromSegments(listOf("org", "jetbrains", "kotlinx", "dataframe", "DataFrame"))) + +val COLUM_GROUP_CLASS_ID: ClassId + get() = ClassId(FqName("org.jetbrains.kotlinx.dataframe.columns"), Name.identifier("ColumnGroup")) + +class KotlinTypeFacade(private val session: FirSession) { + + val anyDataFrame = ConeClassLikeTypeImpl( + ConeClassLikeLookupTagImpl(DF_CLASS_ID), + typeArguments = arrayOf(session.builtinTypes.anyType.type), + isNullable = false + ).wrap() + + fun Marker.toColumnGroup() = ConeClassLikeTypeImpl( + ConeClassLikeLookupTagImpl(COLUM_GROUP_CLASS_ID), + typeArguments = arrayOf(type.typeArguments[0]), + isNullable = false + ).wrap() + +} + +class Marker(internal val type: ConeKotlinType) { + override fun toString(): String { + return "Marker(type=$type)" + } +} + +class LazyMarker(internal val factory: (FirSession) -> ConeKotlinType) + +fun ConeKotlinType.wrap(): Marker = Marker(this) + +//fun ConeKotlinType + + +