[K/JS] Create JavaScript Simple Object plugin that helps create typed JS objects

This commit is contained in:
Artem Kobzar
2024-01-10 16:30:02 +00:00
committed by Space Team
parent 45b8f99107
commit 300702a7e7
46 changed files with 1841 additions and 2 deletions
@@ -0,0 +1,31 @@
description = "Kotlin JavaScript Object Compiler Plugin (CLI)"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
compileOnly(project(":compiler:util"))
compileOnly(project(":compiler:cli"))
compileOnly(project(":compiler:plugin-api"))
compileOnly(project(":compiler:fir:entrypoint"))
compileOnly(project(":compiler:ir.backend.common"))
implementation(project(":plugins:jso:compiler-plugin:jso.common"))
implementation(project(":plugins:jso:compiler-plugin:jso.backend"))
implementation(project(":plugins:jso:compiler-plugin:jso.k2"))
compileOnly(intellijCore())
}
optInToExperimentalCompilerApi()
sourceSets {
"main" { projectDefault() }
"test" { none() }
}
runtimeJar()
sourcesJar()
javadocJar()
@@ -0,0 +1,17 @@
#
# Copyright 2010-2023 JetBrains s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.jetbrains.kotlinx.jso.compiler.cli.JsObjectComponentRegistrar
@@ -0,0 +1,28 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlinx.jso.compiler.cli
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter
import org.jetbrains.kotlinx.jso.compiler.backend.JsObjectLoweringExtension
import org.jetbrains.kotlinx.jso.compiler.fir.JsObjectExtensionRegistrar
class JsObjectComponentRegistrar : CompilerPluginRegistrar() {
override val supportsK2: Boolean get() = true
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
Companion.registerExtensions(this)
}
companion object {
fun registerExtensions(extensionStorage: ExtensionStorage) = with(extensionStorage) {
FirExtensionRegistrarAdapter.registerExtension(JsObjectExtensionRegistrar())
IrGenerationExtension.registerExtension(JsObjectLoweringExtension())
}
}
}