diff --git a/build.gradle.kts b/build.gradle.kts index fc158934a40..069707557c9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -273,7 +273,8 @@ extra["compilerModules"] = arrayOf( ":compiler:fir:java", ":compiler:fir:jvm", ":compiler:fir:checkers", - ":compiler:fir:analysis-tests" + ":compiler:fir:analysis-tests", + ":compiler:fir:plugins:allopen-plugin" ) val coreLibProjects = listOfNotNull( diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index ba115e786e8..da35eab16b7 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -46,6 +46,7 @@ dependencies { testCompile(projectTests(":compiler:fir:raw-fir:light-tree2fir")) testCompile(projectTests(":compiler:fir:fir2ir")) testCompile(projectTests(":compiler:fir:analysis-tests")) + testCompile(projectTests(":compiler:fir:plugins:allopen-plugin")) testCompile(projectTests(":compiler:visualizer")) testCompile(projectTests(":generators:test-generator")) testCompile(project(":compiler:ir.ir2cfg")) diff --git a/compiler/fir/plugins/allopen-plugin/build.gradle.kts b/compiler/fir/plugins/allopen-plugin/build.gradle.kts new file mode 100644 index 00000000000..6a1c36f8e68 --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/build.gradle.kts @@ -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() diff --git a/compiler/fir/plugins/allopen-plugin/resources/META-INF/services/org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarExtension b/compiler/fir/plugins/allopen-plugin/resources/META-INF/services/org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarExtension new file mode 100644 index 00000000000..e73e69a227f --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/resources/META-INF/services/org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarExtension @@ -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 \ No newline at end of file diff --git a/compiler/fir/plugins/allopen-plugin/src/org/jetbrains/kotlin/fir/allopen/AllOpenStatusTransformer.kt b/compiler/fir/plugins/allopen-plugin/src/org/jetbrains/kotlin/fir/allopen/AllOpenStatusTransformer.kt new file mode 100644 index 00000000000..5edc52f686f --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/src/org/jetbrains/kotlin/fir/allopen/AllOpenStatusTransformer.kt @@ -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) + } +} \ No newline at end of file diff --git a/compiler/fir/plugins/allopen-plugin/src/org/jetbrains/kotlin/fir/allopen/FirAllOpenComponentRegistrar.kt b/compiler/fir/plugins/allopen-plugin/src/org/jetbrains/kotlin/fir/allopen/FirAllOpenComponentRegistrar.kt new file mode 100644 index 00000000000..12c025bc1ea --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/src/org/jetbrains/kotlin/fir/allopen/FirAllOpenComponentRegistrar.kt @@ -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 + } +} \ No newline at end of file diff --git a/compiler/fir/plugins/allopen-plugin/testData/simple.kt b/compiler/fir/plugins/allopen-plugin/testData/simple.kt new file mode 100644 index 00000000000..937bd90c2bc --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/testData/simple.kt @@ -0,0 +1,11 @@ +class A { + fun foo() { + + } +} + +class B : A() { + override fun foo() { + + } +} \ No newline at end of file diff --git a/compiler/fir/plugins/allopen-plugin/testData/simple.txt b/compiler/fir/plugins/allopen-plugin/testData/simple.txt new file mode 100644 index 00000000000..d210cb2d98e --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/testData/simple.txt @@ -0,0 +1,19 @@ +FILE: simple.kt + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public open fun foo(): R|kotlin/Unit| { + } + + } + public open class B : R|A| { + public constructor(): R|B| { + super() + } + + public open override fun foo(): R|kotlin/Unit| { + } + + } diff --git a/compiler/fir/plugins/allopen-plugin/tests/org/jetbrains/kotlin/fir/allopen/AbstractFirAllOpenDiagnosticTest.kt b/compiler/fir/plugins/allopen-plugin/tests/org/jetbrains/kotlin/fir/allopen/AbstractFirAllOpenDiagnosticTest.kt new file mode 100644 index 00000000000..0112ed32065 --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/tests/org/jetbrains/kotlin/fir/allopen/AbstractFirAllOpenDiagnosticTest.kt @@ -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()) + } +} \ No newline at end of file diff --git a/compiler/fir/plugins/allopen-plugin/tests/org/jetbrains/kotlin/fir/allopen/FirAllOpenDiagnosticTestGenerated.java b/compiler/fir/plugins/allopen-plugin/tests/org/jetbrains/kotlin/fir/allopen/FirAllOpenDiagnosticTestGenerated.java new file mode 100644 index 00000000000..a94aef59aa2 --- /dev/null +++ b/compiler/fir/plugins/allopen-plugin/tests/org/jetbrains/kotlin/fir/allopen/FirAllOpenDiagnosticTestGenerated.java @@ -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"); + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index 7e1f72c1259..a1789fa0a47 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.codegen.defaultConstructor.AbstractDefaultArgumentsR import org.jetbrains.kotlin.codegen.flags.AbstractWriteFlagsTest import org.jetbrains.kotlin.codegen.ir.* import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.allopen.AbstractFirAllOpenDiagnosticTest import org.jetbrains.kotlin.fir.builder.AbstractRawFirBuilderTestCase import org.jetbrains.kotlin.fir.lightTree.AbstractLightTree2FirConverterTestCase import org.jetbrains.kotlin.fir.java.AbstractFirOldFrontendLightClassesTest @@ -628,4 +629,10 @@ fun main(args: Array) { model("uncommonCases/testFiles", testMethod = "doUncommonCasesTest") } } + + testGroup("compiler/fir/plugins/allopen-plugin/tests", "compiler/fir/plugins/allopen-plugin/testData") { + testClass { + model("") + } + } } diff --git a/settings.gradle b/settings.gradle index 2c69605fde3..d974343356e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -96,6 +96,7 @@ include ":kotlin-build-common", ":compiler:fir:jvm", ":compiler:fir:checkers", ":compiler:fir:analysis-tests", + ":compiler:fir:plugins:allopen-plugin", ":compiler:frontend", ":compiler:frontend.common", ":compiler:frontend.java",