Skip to content

Commit

Permalink
Setup project with KotlinType operations API for plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
koperagen committed Nov 29, 2022
1 parent 09e8627 commit 63c3061
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ include("dataframe-excel")
include("core")
include("plugins:dataframe-introspection")
findProject(":plugins:dataframe-introspection")?.name = "dataframe-introspection"

include("type-api")
32 changes: 32 additions & 0 deletions type-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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>("test") {
useJUnitPlatform()
}

kotlinPublications {
publication {
publicationName.set("api")
artifactId.set("types-api")
description.set("Data processing in Kotlin")
packageName.set(artifactId)
}
}

2 changes: 2 additions & 0 deletions type-api/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = "type-api"

46 changes: 46 additions & 0 deletions type-api/src/main/kotlin/org/jetbrains/kotlinx/dataframe/Main.kt
Original file line number Diff line number Diff line change
@@ -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



0 comments on commit 63c3061

Please sign in to comment.