diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 68568c9df8b..42efecdeb79 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -15,7 +15,8 @@ import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidIrBoxTest import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest -import org.jetbrains.kotlin.fir.plugin.AbstractFirAllOpenDiagnosticTest +import org.jetbrains.kotlin.fir.plugin.runners.AbstractFir2IrAllOpenTest +import org.jetbrains.kotlin.fir.plugin.runners.AbstractFirAllOpenDiagnosticTest import org.jetbrains.kotlin.generators.TestGroup import org.jetbrains.kotlin.generators.generateTestGroupSuiteWithJUnit5 import org.jetbrains.kotlin.generators.impl.generateTestGroupSuite @@ -373,6 +374,10 @@ fun main(args: Array) { testClass { model("diagnostics") } + + testClass { + model("fir2ir") + } } } } diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt new file mode 100644 index 00000000000..a728526ca76 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt @@ -0,0 +1,68 @@ +FILE fqName: fileName:/classWithGeneratedMembersAndNestedClass.kt + CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any] + annotations: + C + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo + CONSTRUCTOR visibility:public <> () returnType:.Foo [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' + CLASS CLASS name:MyNested modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo.MyNested + CONSTRUCTOR visibility:public <> () returnType:.Foo.MyNested [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyNested modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:materialize visibility:public modality:FINAL <> () returnType:.Foo [fake_override] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Bar + CONSTRUCTOR visibility:public <> () returnType:.Bar [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test_1 visibility:public modality:FINAL <> (foo:.Foo) returnType:kotlin.Unit + VALUE_PARAMETER name:foo index:0 type:.Foo + BLOCK_BODY + VAR name:foo2 type:.Foo [val] + CALL 'public final fun materialize (): .Foo declared in ' type=.Foo origin=null + VAR name:nested type:.Foo.Nested [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Foo.Nested' type=.Foo.Nested origin=null diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.txt new file mode 100644 index 00000000000..cbf88da1cfc --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.txt @@ -0,0 +1,29 @@ +FILE: classWithGeneratedMembersAndNestedClass.kt + @R|org/jetbrains/kotlin/fir/plugin/C|() public final class Foo : R|kotlin/Any| { + public constructor(): R|Foo| { + super() + } + + public final class MyNested : R|kotlin/Any| { + public constructor(): R|Foo.MyNested| { + super() + } + + } + + public final fun materialize(): R|Foo| + + public final class Nested : R|kotlin/Any| { + } + + } + public final class Bar : R|kotlin/Any| { + public constructor(): R|Bar| { + super() + } + + } + public final fun test_1(foo: R|Foo|): R|kotlin/Unit| { + lval foo2: R|Foo| = R|/foo|.R|/Foo.materialize|() + lval nested: R|Foo.Nested| = Q|Foo|.R|/Foo.Nested|() + } diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.kt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.kt new file mode 100644 index 00000000000..aece15d0723 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.kt @@ -0,0 +1,13 @@ +import org.jetbrains.kotlin.fir.plugin.C + +@C +class Foo { + class MyNested +} + +class Bar + +fun test_1(foo: Foo) { + val foo2: Foo = foo.materialize() + val nested = Foo.Nested() +} diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt new file mode 100644 index 00000000000..339e2cd6c92 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt @@ -0,0 +1,63 @@ +FILE fqName:bar fileName:/generatedClassWithMembersAndNestedClasses.kt + CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any] + annotations: + B + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:bar.Foo + CONSTRUCTOR visibility:public <> () returnType:bar.Foo [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:foo visibility:public modality:FINAL <> ($this:bar.Foo) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:bar.Foo + BLOCK_BODY + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any] + annotations: + B + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:bar.Bar + CONSTRUCTOR visibility:public <> () returnType:bar.Bar [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:bar visibility:public modality:FINAL <> ($this:bar.Bar) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:bar.Bar + BLOCK_BODY + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:testConstructor visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:generatedClass type:foo.AllOpenGenerated [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in foo.AllOpenGenerated' type=foo.AllOpenGenerated origin=null + FUN name:testNestedClasses visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:nestedFoo type:foo.AllOpenGenerated.NestedFoo [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in foo.AllOpenGenerated.NestedFoo' type=foo.AllOpenGenerated.NestedFoo origin=null + CALL 'public final fun foo (): kotlin.Unit declared in bar.Foo' type=kotlin.Unit origin=null + $this: CALL 'public final fun materialize (): bar.Foo declared in foo' type=bar.Foo origin=null + VAR name:nestedBar type:foo.AllOpenGenerated.NestedBar [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in foo.AllOpenGenerated.NestedBar' type=foo.AllOpenGenerated.NestedBar origin=null + CALL 'public final fun bar (): kotlin.Unit declared in bar.Bar' type=kotlin.Unit origin=null + $this: CALL 'public final fun materialize (): bar.Foo declared in foo' type=bar.Bar origin=null diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.txt new file mode 100644 index 00000000000..39cda0f2c06 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.txt @@ -0,0 +1,45 @@ +FILE: generatedClassWithMembersAndNestedClasses.kt + package bar + + @R|org/jetbrains/kotlin/fir/plugin/B|() public final class Foo : R|kotlin/Any| { + public constructor(): R|bar/Foo| { + super() + } + + public final fun foo(): R|kotlin/Unit| { + } + + } + @R|org/jetbrains/kotlin/fir/plugin/B|() public final class Bar : R|kotlin/Any| { + public constructor(): R|bar/Bar| { + super() + } + + public final fun bar(): R|kotlin/Unit| { + } + + } + public final fun testConstructor(): R|kotlin/Unit| { + lval generatedClass: R|foo/AllOpenGenerated| = R|foo/AllOpenGenerated|() + } + public final fun testNestedClasses(): R|kotlin/Unit| { + lval nestedFoo: R|foo/AllOpenGenerated.NestedFoo| = Q|foo/AllOpenGenerated|.R|foo/AllOpenGenerated.NestedFoo|() + R|/nestedFoo|.R|foo/AllOpenGenerated.NestedFoo.materialize|().R|bar/Foo.foo|() + lval nestedBar: R|foo/AllOpenGenerated.NestedBar| = Q|foo/AllOpenGenerated|.R|foo/AllOpenGenerated.NestedBar|() + R|/nestedBar|.R|foo/AllOpenGenerated.NestedBar.materialize|().R|bar/Bar.bar|() + } +FILE: ### GENERATED DECLARATIONS ### + package foo + + public final class AllOpenGenerated : R|kotlin/Any| { + public final class NestedFoo : R|kotlin/Any| { + public final fun materialize(): R|bar/Foo| + + } + + public final class NestedBar : R|kotlin/Any| { + public final fun materialize(): R|bar/Bar| + + } + + } diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.kt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.kt new file mode 100644 index 00000000000..f708b5a9ae9 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.kt @@ -0,0 +1,27 @@ +package bar + +import foo.AllOpenGenerated +import org.jetbrains.kotlin.fir.plugin.B + +@B +class Foo { + fun foo() {} +} + +@B +class Bar { + fun bar() {} +} + +fun testConstructor() { + val generatedClass: AllOpenGenerated = AllOpenGenerated() +} + +fun testNestedClasses() { + val nestedFoo = AllOpenGenerated.NestedFoo() + nestedFoo.materialize().foo() + + val nestedBar = AllOpenGenerated.NestedBar() + nestedBar.materialize().bar() +} + diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt new file mode 100644 index 00000000000..0e16cf0ff85 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt @@ -0,0 +1,33 @@ +FILE fqName:foo fileName:/topLevelCallables.kt + CLASS CLASS name:MySuperClass modality:FINAL visibility:public superTypes:[kotlin.Any] + annotations: + A + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.MySuperClass + CONSTRUCTOR visibility:public <> () returnType:foo.MySuperClass [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MySuperClass modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:test visibility:public modality:FINAL <> ($this:foo.MySuperClass) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:foo.MySuperClass + BLOCK_BODY + VAR name:s type:kotlin.String [val] + CALL 'public final fun dummyMySuperClass (value: foo.MySuperClass): kotlin.String declared in foo' type=kotlin.String origin=null + value: GET_VAR ': foo.MySuperClass declared in foo.MySuperClass.test' type=foo.MySuperClass origin=null + CALL 'public final fun takeString (s: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=null + s: GET_VAR 'val s: kotlin.String [val] declared in foo.MySuperClass.test' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:takeString visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.txt new file mode 100644 index 00000000000..b3cddfe51ba --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.txt @@ -0,0 +1,20 @@ +FILE: topLevelCallables.kt + package foo + + @R|org/jetbrains/kotlin/fir/plugin/A|() public final class MySuperClass : R|kotlin/Any| { + public constructor(): R|foo/MySuperClass| { + super() + } + + public final fun test(): R|kotlin/Unit| { + lval s: R|kotlin/String| = R|foo/dummyMySuperClass|(this@R|foo/MySuperClass|) + R|foo/takeString|(R|/s|) + } + + } + public final fun takeString(s: R|kotlin/String|): R|kotlin/Unit| { + } +FILE: ### GENERATED DECLARATIONS ### + package foo + + public final fun dummyMySuperClass(value: R|foo/MySuperClass|): R|kotlin/String| diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.kt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.kt new file mode 100644 index 00000000000..f7a7286203f --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.kt @@ -0,0 +1,13 @@ +package foo + +import org.jetbrains.kotlin.fir.plugin.A + +@A +class MySuperClass { + fun test() { + val s = dummyMySuperClass(this) + takeString(s) + } +} + +fun takeString(s: String) {} diff --git a/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/runners/Fir2IrAllOpenTestGenerated.java b/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/runners/Fir2IrAllOpenTestGenerated.java new file mode 100644 index 00000000000..7dcd497176f --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/runners/Fir2IrAllOpenTestGenerated.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2021 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.plugin.runners; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("plugins/fir/fir-plugin-prototype/testData/fir2ir") +@TestDataPath("$PROJECT_ROOT") +public class Fir2IrAllOpenTestGenerated extends AbstractFir2IrAllOpenTest { + @Test + public void testAllFilesPresentInFir2ir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/fir2ir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen") + @TestDataPath("$PROJECT_ROOT") + public class MemberGen { + @Test + public void testAllFilesPresentInMemberGen() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("classWithGeneratedMembersAndNestedClass.kt") + public void testClassWithGeneratedMembersAndNestedClass() throws Exception { + runTest("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.kt"); + } + + @Test + @TestMetadata("generatedClassWithMembersAndNestedClasses.kt") + public void testGeneratedClassWithMembersAndNestedClasses() throws Exception { + runTest("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.kt"); + } + + @Test + @TestMetadata("topLevelCallables.kt") + public void testTopLevelCallables() throws Exception { + runTest("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.kt"); + } + } +} diff --git a/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/FirAllOpenDiagnosticTestGenerated.java b/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/runners/FirAllOpenDiagnosticTestGenerated.java similarity index 99% rename from plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/FirAllOpenDiagnosticTestGenerated.java rename to plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/runners/FirAllOpenDiagnosticTestGenerated.java index 443d43d8175..27819d82c3a 100644 --- a/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/FirAllOpenDiagnosticTestGenerated.java +++ b/plugins/fir/fir-plugin-prototype/tests-gen/org/jetbrains/kotlin/fir/plugin/runners/FirAllOpenDiagnosticTestGenerated.java @@ -3,7 +3,7 @@ * 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.plugin; +package org.jetbrains.kotlin.fir.plugin.runners; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.util.KtTestUtil; diff --git a/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/AbstractFirAllOpenDiagnosticTest.kt b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/AbstractFirAllOpenDiagnosticTest.kt deleted file mode 100644 index ff896752b5e..00000000000 --- a/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/AbstractFirAllOpenDiagnosticTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.plugin - -import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.test.Constructor -import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder -import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES -import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_DUMP -import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade -import org.jetbrains.kotlin.test.model.TestModule -import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest -import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration -import org.jetbrains.kotlin.test.services.EnvironmentConfigurator -import org.jetbrains.kotlin.test.services.TestServices -import org.jetbrains.kotlin.test.services.assertions -import java.io.File - -abstract class AbstractFirAllOpenDiagnosticTest : AbstractKotlinCompilerTest() { - override fun TestConfigurationBuilder.configuration() { - baseFirDiagnosticTestConfiguration(frontendFacade = facade) - defaultDirectives { - +ENABLE_PLUGIN_PHASES - +FIR_DUMP - } - - useConfigurators(::PluginAnnotationsProvider) - } - - private val facade: Constructor - get() = { testServices -> - FirFrontendFacade(testServices) { - it.registerExtensions(FirAllOpenComponentRegistrar().configure()) - } - } - - class PluginAnnotationsProvider(testServices: TestServices) : EnvironmentConfigurator(testServices) { - companion object { - const val ANNOTATIONS_JAR = - "plugins/fir/fir-plugin-prototype/plugin-annotations/build/libs/plugin-annotations-1.6.255-SNAPSHOT.jar" - } - - override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) { - val jar = File(ANNOTATIONS_JAR) - testServices.assertions.assertTrue(jar.exists()) { "Jar with annotations does not exist. Please run :plugins:fir:fir-plugin-prototype:plugin-annotations:jar" } - configuration.addJvmClasspathRoot(jar) - } - } -} diff --git a/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/AbstractFir2IrAllOpenTest.kt b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/AbstractFir2IrAllOpenTest.kt new file mode 100644 index 00000000000..14efc103140 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/AbstractFir2IrAllOpenTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2021 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.plugin.runners + +import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler +import org.jetbrains.kotlin.test.backend.handlers.IrTreeVerifierHandler +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.builders.fir2IrStep +import org.jetbrains.kotlin.test.builders.irHandlersStep +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR +import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest + +open class AbstractFir2IrAllOpenTest : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) { + override fun TestConfigurationBuilder.configuration() { + defaultDirectives { + +DUMP_IR + } + + commonFirWithPluginFrontendConfiguration() + fir2IrStep() + irHandlersStep { + useHandlers( + ::IrTextDumpHandler, + ::IrTreeVerifierHandler, + ) + } + } +} diff --git a/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/AbstractFirAllOpenDiagnosticTest.kt b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/AbstractFirAllOpenDiagnosticTest.kt new file mode 100644 index 00000000000..8134a94f46a --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/AbstractFirAllOpenDiagnosticTest.kt @@ -0,0 +1,15 @@ +/* + * Copyright 2010-2021 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.plugin.runners + +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest + +abstract class AbstractFirAllOpenDiagnosticTest : AbstractKotlinCompilerTest() { + override fun TestConfigurationBuilder.configuration() { + commonFirWithPluginFrontendConfiguration() + } +} diff --git a/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/commonPluginTestConfiguration.kt b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/commonPluginTestConfiguration.kt new file mode 100644 index 00000000000..3a5c32768d7 --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/runners/commonPluginTestConfiguration.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2021 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.plugin.runners + +import org.jetbrains.kotlin.fir.plugin.FirAllOpenComponentRegistrar +import org.jetbrains.kotlin.fir.plugin.services.PluginAnnotationsProvider +import org.jetbrains.kotlin.test.Constructor +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_DUMP +import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade +import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration + +fun TestConfigurationBuilder.commonFirWithPluginFrontendConfiguration() { + baseFirDiagnosticTestConfiguration(frontendFacade = FirFrontendFacadeWithPlugin) + + defaultDirectives { + +ENABLE_PLUGIN_PHASES + +FIR_DUMP + } + + useConfigurators(::PluginAnnotationsProvider) +} + +val FirFrontendFacadeWithPlugin: Constructor + get() = { testServices -> + FirFrontendFacade(testServices) { + it.registerExtensions(FirAllOpenComponentRegistrar().configure()) + } + } diff --git a/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/services/PluginAnnotationsProvider.kt b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/services/PluginAnnotationsProvider.kt new file mode 100644 index 00000000000..d53994554ba --- /dev/null +++ b/plugins/fir/fir-plugin-prototype/tests/org/jetbrains/kotlin/fir/plugin/services/PluginAnnotationsProvider.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2021 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.plugin.services + +import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.EnvironmentConfigurator +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.assertions +import java.io.File + +class PluginAnnotationsProvider(testServices: TestServices) : EnvironmentConfigurator(testServices) { + companion object { + const val ANNOTATIONS_JAR = + "plugins/fir/fir-plugin-prototype/plugin-annotations/build/libs/plugin-annotations-1.6.255-SNAPSHOT.jar" + } + + override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) { + val jar = File(ANNOTATIONS_JAR) + testServices.assertions.assertTrue(jar.exists()) { "Jar with annotations does not exist. Please run :plugins:fir:fir-plugin-prototype:plugin-annotations:jar" } + configuration.addJvmClasspathRoot(jar) + } +}