[FIR-PLUGIN] Add prototype of allopen plugin for FIR compiler
This commit is contained in:
+2
-1
@@ -273,7 +273,8 @@ extra["compilerModules"] = arrayOf(
|
|||||||
":compiler:fir:java",
|
":compiler:fir:java",
|
||||||
":compiler:fir:jvm",
|
":compiler:fir:jvm",
|
||||||
":compiler:fir:checkers",
|
":compiler:fir:checkers",
|
||||||
":compiler:fir:analysis-tests"
|
":compiler:fir:analysis-tests",
|
||||||
|
":compiler:fir:plugins:allopen-plugin"
|
||||||
)
|
)
|
||||||
|
|
||||||
val coreLibProjects = listOfNotNull(
|
val coreLibProjects = listOfNotNull(
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ dependencies {
|
|||||||
testCompile(projectTests(":compiler:fir:raw-fir:light-tree2fir"))
|
testCompile(projectTests(":compiler:fir:raw-fir:light-tree2fir"))
|
||||||
testCompile(projectTests(":compiler:fir:fir2ir"))
|
testCompile(projectTests(":compiler:fir:fir2ir"))
|
||||||
testCompile(projectTests(":compiler:fir:analysis-tests"))
|
testCompile(projectTests(":compiler:fir:analysis-tests"))
|
||||||
|
testCompile(projectTests(":compiler:fir:plugins:allopen-plugin"))
|
||||||
testCompile(projectTests(":compiler:visualizer"))
|
testCompile(projectTests(":compiler:visualizer"))
|
||||||
testCompile(projectTests(":generators:test-generator"))
|
testCompile(projectTests(":generators:test-generator"))
|
||||||
testCompile(project(":compiler:ir.ir2cfg"))
|
testCompile(project(":compiler:ir.ir2cfg"))
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("jps-compatible")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile(project(":compiler:fir:cones"))
|
||||||
|
compile(project(":compiler:fir:tree"))
|
||||||
|
compile(project(":compiler:fir:resolve"))
|
||||||
|
compile(project(":compiler:frontend"))
|
||||||
|
|
||||||
|
compileOnly(project(":kotlin-reflect-api"))
|
||||||
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
||||||
|
|
||||||
|
testCompile(intellijDep())
|
||||||
|
|
||||||
|
testCompile(commonDep("junit:junit"))
|
||||||
|
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
|
||||||
|
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
|
||||||
|
testCompile(projectTests(":compiler:tests-common"))
|
||||||
|
testCompile(project(":compiler:fir:checkers"))
|
||||||
|
testCompile(projectTests(":compiler:fir:analysis-tests"))
|
||||||
|
testCompile(project(":compiler:frontend"))
|
||||||
|
|
||||||
|
testCompileOnly(project(":kotlin-reflect-api"))
|
||||||
|
testRuntime(project(":kotlin-reflect"))
|
||||||
|
testRuntime(project(":core:descriptors.runtime"))
|
||||||
|
|
||||||
|
Platform[192].orHigher {
|
||||||
|
testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
testRuntimeOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
"main" { projectDefault() }
|
||||||
|
"test" { projectDefault() }
|
||||||
|
}
|
||||||
|
|
||||||
|
projectTest(parallel = true) {
|
||||||
|
workingDir = rootDir
|
||||||
|
jvmArgs!!.removeIf { it.contains("-Xmx") }
|
||||||
|
maxHeapSize = "3g"
|
||||||
|
}
|
||||||
|
|
||||||
|
testsJar()
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2010-2020 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
org.jetbrains.kotlin.fir.allopen.FirAllOpenComponentRegistrar
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.kotlin.fir.allopen
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
||||||
|
import org.jetbrains.kotlin.fir.extensions.FirStatusTransformerExtension
|
||||||
|
import org.jetbrains.kotlin.fir.extensions.transform
|
||||||
|
|
||||||
|
class AllOpenStatusTransformer(session: FirSession) : FirStatusTransformerExtension(session) {
|
||||||
|
override fun transformStatus(declaration: FirDeclaration, status: FirDeclarationStatus): FirDeclarationStatus {
|
||||||
|
if (status.modality != null) return status
|
||||||
|
return status.transform(modality = Modality.OPEN)
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.kotlin.fir.allopen
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarExtension
|
||||||
|
|
||||||
|
class FirAllOpenComponentRegistrar : FirExtensionRegistrarExtension() {
|
||||||
|
override fun ExtensionRegistrarContext.configurePlugin() {
|
||||||
|
+::AllOpenStatusTransformer
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class A {
|
||||||
|
fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : A() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
FILE: simple.kt
|
||||||
|
public open class A : R|kotlin/Any| {
|
||||||
|
public constructor(): R|A| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public open fun foo(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public open class B : R|A| {
|
||||||
|
public constructor(): R|B| {
|
||||||
|
super<R|A|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public open override fun foo(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.kotlin.fir.allopen
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.AbstractFirDiagnosticsTest
|
||||||
|
import org.jetbrains.kotlin.fir.extensions.FirExtensionPointService
|
||||||
|
import org.jetbrains.kotlin.fir.extensions.registerExtensions
|
||||||
|
|
||||||
|
abstract class AbstractFirAllOpenDiagnosticTest : AbstractFirDiagnosticsTest() {
|
||||||
|
override fun registerFirExtensions(service: FirExtensionPointService) {
|
||||||
|
service.registerExtensions(FirAllOpenComponentRegistrar().configure())
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.kotlin.fir.allopen;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/fir/plugins/allopen-plugin/testData")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class FirAllOpenDiagnosticTestGenerated extends AbstractFirAllOpenDiagnosticTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTestData() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/plugins/allopen-plugin/testData"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
runTest("compiler/fir/plugins/allopen-plugin/testData/simple.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.codegen.defaultConstructor.AbstractDefaultArgumentsR
|
|||||||
import org.jetbrains.kotlin.codegen.flags.AbstractWriteFlagsTest
|
import org.jetbrains.kotlin.codegen.flags.AbstractWriteFlagsTest
|
||||||
import org.jetbrains.kotlin.codegen.ir.*
|
import org.jetbrains.kotlin.codegen.ir.*
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
|
import org.jetbrains.kotlin.fir.allopen.AbstractFirAllOpenDiagnosticTest
|
||||||
import org.jetbrains.kotlin.fir.builder.AbstractRawFirBuilderTestCase
|
import org.jetbrains.kotlin.fir.builder.AbstractRawFirBuilderTestCase
|
||||||
import org.jetbrains.kotlin.fir.lightTree.AbstractLightTree2FirConverterTestCase
|
import org.jetbrains.kotlin.fir.lightTree.AbstractLightTree2FirConverterTestCase
|
||||||
import org.jetbrains.kotlin.fir.java.AbstractFirOldFrontendLightClassesTest
|
import org.jetbrains.kotlin.fir.java.AbstractFirOldFrontendLightClassesTest
|
||||||
@@ -628,4 +629,10 @@ fun main(args: Array<String>) {
|
|||||||
model("uncommonCases/testFiles", testMethod = "doUncommonCasesTest")
|
model("uncommonCases/testFiles", testMethod = "doUncommonCasesTest")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testGroup("compiler/fir/plugins/allopen-plugin/tests", "compiler/fir/plugins/allopen-plugin/testData") {
|
||||||
|
testClass<AbstractFirAllOpenDiagnosticTest> {
|
||||||
|
model("")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ include ":kotlin-build-common",
|
|||||||
":compiler:fir:jvm",
|
":compiler:fir:jvm",
|
||||||
":compiler:fir:checkers",
|
":compiler:fir:checkers",
|
||||||
":compiler:fir:analysis-tests",
|
":compiler:fir:analysis-tests",
|
||||||
|
":compiler:fir:plugins:allopen-plugin",
|
||||||
":compiler:frontend",
|
":compiler:frontend",
|
||||||
":compiler:frontend.common",
|
":compiler:frontend.common",
|
||||||
":compiler:frontend.java",
|
":compiler:frontend.java",
|
||||||
|
|||||||
Reference in New Issue
Block a user