[SAM with receiver] Prepare module structure to K2 implementation

This commit is contained in:
Dmitriy Novozhilov
2022-06-22 13:22:47 +03:00
committed by teamcity
parent e54c6eeafc
commit ffc680f4a6
38 changed files with 209 additions and 136 deletions
@@ -223,7 +223,7 @@ fun main(args: Array<String>) {
}
}
testGroup("plugins/sam-with-receiver/sam-with-receiver-cli/test", "plugins/sam-with-receiver/sam-with-receiver-cli/testData") {
testGroup("plugins/sam-with-receiver/tests-gen", "plugins/sam-with-receiver/testData") {
testClass<AbstractSamWithReceiverTest> {
model("diagnostics")
}
@@ -0,0 +1,57 @@
description = "Kotlin SamWithReceiver Compiler Plugin"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
embedded(project(":kotlin-sam-with-receiver-compiler-plugin.common"))
embedded(project(":kotlin-sam-with-receiver-compiler-plugin.k1"))
embedded(project(":kotlin-sam-with-receiver-compiler-plugin.k2"))
embedded(project(":kotlin-sam-with-receiver-compiler-plugin.cli"))
testApi(project(":compiler:backend"))
testApi(project(":compiler:cli"))
testApi(project(":kotlin-sam-with-receiver-compiler-plugin.cli"))
testCompileOnly(project(":kotlin-compiler"))
testImplementation(project(":kotlin-scripting-jvm-host-unshaded"))
testApiJUnit5(vintageEngine = true)
testApi(projectTests(":compiler:tests-common-new"))
testApi(projectTests(":compiler:test-infrastructure"))
testApi(projectTests(":compiler:test-infrastructure-utils"))
testImplementation(projectTests(":compiler:tests-common"))
testImplementation(commonDependency("junit:junit"))
testCompileOnly(project(":kotlin-reflect-api"))
testRuntimeOnly(project(":kotlin-reflect"))
testRuntimeOnly(project(":core:descriptors.runtime"))
testRuntimeOnly(project(":compiler:fir:fir-serialization"))
testApi(intellijCore())
}
sourceSets {
"main" { none() }
"test" {
projectDefault()
generatedTestDir()
}
}
publish()
runtimeJar()
sourcesJar()
javadocJar()
testsJar()
projectTest(parallel = true) {
dependsOn(":dist")
workingDir = rootDir
useJUnitPlatform()
}
@@ -1,40 +0,0 @@
description = "Kotlin SamWithReceiver Compiler Plugin"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
compileOnly(project(":core:descriptors"))
compileOnly(project(":compiler:frontend"))
compileOnly(project(":compiler:frontend.java"))
compileOnly(project(":compiler:plugin-api"))
compileOnly(intellijCore())
testApi(project(":compiler:backend"))
testApi(project(":compiler:cli"))
testApi(projectTests(":compiler:tests-common"))
testApi(commonDependency("junit:junit"))
testCompileOnly(project(":kotlin-compiler"))
testCompileOnly(intellijCore())
testApi(project(":kotlin-scripting-jvm-host-unshaded"))
testRuntimeOnly(intellijCore())
}
sourceSets {
"main" { projectDefault() }
"test" { projectDefault() }
}
publish()
runtimeJar()
sourcesJar()
javadocJar()
testsJar()
projectTest(parallel = true) {
dependsOn(":dist")
workingDir = rootDir
}
@@ -0,0 +1,25 @@
description = "Kotlin SamWithReceiver Compiler Plugin (CLI)"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
api(project(":kotlin-sam-with-receiver-compiler-plugin.common"))
api(project(":kotlin-sam-with-receiver-compiler-plugin.k1"))
api(project(":kotlin-sam-with-receiver-compiler-plugin.k2"))
compileOnly(project(":compiler:util"))
compileOnly(project(":compiler:plugin-api"))
compileOnly(project(":compiler:fir:entrypoint"))
compileOnly(intellijCore())
}
sourceSets {
"main" { projectDefault() }
"test" { none() }
}
runtimeJar()
sourcesJar()
javadocJar()
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 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.
* Copyright 2010-2022 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.samWithReceiver
@@ -31,8 +20,7 @@ import org.jetbrains.kotlin.samWithReceiver.SamWithReceiverConfigurationKeys.ANN
import org.jetbrains.kotlin.samWithReceiver.SamWithReceiverConfigurationKeys.PRESET
object SamWithReceiverConfigurationKeys {
val ANNOTATION: CompilerConfigurationKey<List<String>> =
CompilerConfigurationKey.create("annotation qualified name")
val ANNOTATION: CompilerConfigurationKey<List<String>> = CompilerConfigurationKey.create("annotation qualified name")
val PRESET: CompilerConfigurationKey<List<String>> = CompilerConfigurationKey.create("annotation preset")
}
@@ -41,11 +29,15 @@ class SamWithReceiverCommandLineProcessor : CommandLineProcessor {
companion object {
val SUPPORTED_PRESETS = emptyMap<String, List<String>>()
val ANNOTATION_OPTION = CliOption("annotation", "<fqname>", "Annotation qualified names",
required = false, allowMultipleOccurrences = true)
val ANNOTATION_OPTION = CliOption(
"annotation", "<fqname>", "Annotation qualified names",
required = false, allowMultipleOccurrences = true
)
val PRESET_OPTION = CliOption("preset", "<name>", "Preset name (${SUPPORTED_PRESETS.keys.joinToString()})",
required = false, allowMultipleOccurrences = true)
val PRESET_OPTION = CliOption(
"preset", "<name>", "Preset name (${SUPPORTED_PRESETS.keys.joinToString()})",
required = false, allowMultipleOccurrences = true
)
val PLUGIN_ID = "org.jetbrains.kotlin.samWithReceiver"
}
@@ -72,10 +64,14 @@ class SamWithReceiverComponentRegistrar : ComponentRegistrar {
}
}
class CliSamWithReceiverComponentContributor(val annotations: List<String>): StorageComponentContainerContributor {
override fun registerModuleComponents(container: StorageComponentContainer, platform: TargetPlatform, moduleDescriptor: ModuleDescriptor) {
class CliSamWithReceiverComponentContributor(val annotations: List<String>) : StorageComponentContainerContributor {
override fun registerModuleComponents(
container: StorageComponentContainer,
platform: TargetPlatform,
moduleDescriptor: ModuleDescriptor
) {
if (!platform.isJvm()) return
container.useInstance(SamWithReceiverResolverExtension(annotations))
}
}
}
@@ -0,0 +1,20 @@
description = "Kotlin SamWithReceiver Compiler Plugin (Common)"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
compileOnly(project(":compiler:util"))
compileOnly(project(":core:compiler.common"))
}
sourceSets {
"main" { projectDefault() }
"test" { none() }
}
runtimeJar()
javadocJar()
sourcesJar()
@@ -0,0 +1,22 @@
description = "Kotlin SamWithReceiver Compiler Plugin (K1)"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
compileOnly(project(":compiler:frontend"))
compileOnly(project(":compiler:frontend.java"))
compileOnly(intellijCore())
}
sourceSets {
"main" { projectDefault() }
"test" { projectDefault() }
}
runtimeJar()
sourcesJar()
javadocJar()
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 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.
* Copyright 2010-2022 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.samWithReceiver
@@ -23,11 +12,11 @@ import org.jetbrains.kotlin.resolve.sam.SamWithReceiverResolver
import org.jetbrains.kotlin.psi.KtModifierListOwner
class SamWithReceiverResolverExtension(
private val annotations: List<String>
private val annotations: List<String>
) : SamWithReceiverResolver, AnnotationBasedExtension {
override fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?) = annotations
override fun shouldConvertFirstSamParameterToReceiver(function: FunctionDescriptor): Boolean {
return (function.containingDeclaration as? ClassDescriptor)?.hasSpecialAnnotation(null) ?: false
}
}
}
@@ -0,0 +1,27 @@
description = "Kotlin SamWithReceiver Compiler Plugin (K2)"
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
compileOnly(project(":compiler:fir:cones"))
compileOnly(project(":compiler:fir:tree"))
compileOnly(project(":compiler:fir:resolve"))
compileOnly(project(":compiler:fir:checkers"))
compileOnly(project(":compiler:ir.backend.common"))
compileOnly(project(":compiler:fir:entrypoint"))
compileOnly(intellijCore())
runtimeOnly(kotlinStdlib())
}
sourceSets {
"main" { projectDefault() }
"test" { none() }
}
runtimeJar()
sourcesJar()
javadocJar()
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 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.
* Copyright 2010-2022 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.samWithReceiver
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 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.
* Copyright 2010-2022 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.samWithReceiver
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 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.
* Copyright 2010-2022 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.samWithReceiver
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 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.
*/
@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script")
@TestDataPath("$PROJECT_ROOT")
@TestDataPath("/")
@RunWith(JUnit3RunnerWithInners.class)
public class SamWithReceiverScriptNewDefTestGenerated extends AbstractSamWithReceiverScriptNewDefTest {
private void runTest(String testDataFilePath) throws Exception {
@@ -30,6 +30,6 @@ public class SamWithReceiverScriptNewDefTestGenerated extends AbstractSamWithRec
@TestMetadata("samConversionSimple.kts")
public void testSamConversionSimple() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script/samConversionSimple.kts");
runTest("plugins/sam-with-receiver/testData/script/samConversionSimple.kts");
}
}
@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script")
@TestMetadata("plugins/sam-with-receiver/testData/script")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class SamWithReceiverScriptTestGenerated extends AbstractSamWithReceiverScriptTest {
@@ -26,11 +26,11 @@ public class SamWithReceiverScriptTestGenerated extends AbstractSamWithReceiverS
}
public void testAllFilesPresentInScript() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script"), Pattern.compile("^(.+)\\.kts$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/testData/script"), Pattern.compile("^(.+)\\.kts$"), null, true);
}
@TestMetadata("samConversionSimple.kts")
public void testSamConversionSimple() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script/samConversionSimple.kts");
runTest("plugins/sam-with-receiver/testData/script/samConversionSimple.kts");
}
}
@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics")
@TestMetadata("plugins/sam-with-receiver/testData/diagnostics")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class SamWithReceiverTestGenerated extends AbstractSamWithReceiverTest {
@@ -26,51 +26,51 @@ public class SamWithReceiverTestGenerated extends AbstractSamWithReceiverTest {
}
public void testAllFilesPresentInDiagnostics() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("noParameters.kt")
public void testNoParameters() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/noParameters.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/noParameters.kt");
}
@TestMetadata("noReturnType.kt")
public void testNoReturnType() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/noReturnType.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/noReturnType.kt");
}
@TestMetadata("samConversionNoParameters.kt")
public void testSamConversionNoParameters() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/samConversionNoParameters.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/samConversionNoParameters.kt");
}
@TestMetadata("samConversionSimple.kt")
public void testSamConversionSimple() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/samConversionSimple.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.kt");
}
@TestMetadata("samConversionSimpleWithoutAnnotation.kt")
public void testSamConversionSimpleWithoutAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt");
}
@TestMetadata("samWithAnnotation.kt")
public void testSamWithAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/samWithAnnotation.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.kt");
}
@TestMetadata("samWithoutAnnotation.kt")
public void testSamWithoutAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/samWithoutAnnotation.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.kt");
}
@TestMetadata("singleParameter.kt")
public void testSingleParameter() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/singleParameter.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/singleParameter.kt");
}
@TestMetadata("singleParameterWithoutAnnotation.kt")
public void testSingleParameterWithoutAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/sam-with-receiver-cli/testData/diagnostics/singleParameterWithoutAnnotation.kt");
runTest("plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.kt");
}
}
+12 -2
View File
@@ -206,7 +206,12 @@ include ":kotlin-noarg-compiler-plugin",
":kotlin-noarg-compiler-plugin.cli"
include ":kotlin-sam-with-receiver-compiler-plugin",
":kotlin-imports-dumper-compiler-plugin",
":kotlin-sam-with-receiver-compiler-plugin.common",
":kotlin-sam-with-receiver-compiler-plugin.k1",
":kotlin-sam-with-receiver-compiler-plugin.k2",
":kotlin-sam-with-receiver-compiler-plugin.cli"
include ":kotlin-imports-dumper-compiler-plugin",
":kotlin-script-runtime",
":plugins:fir-plugin-prototype",
":plugins:fir-plugin-prototype:plugin-annotations",
@@ -718,7 +723,12 @@ project(':kotlin-noarg-compiler-plugin.k2').projectDir = "$rootDir/plugins/noarg
project(':kotlin-noarg-compiler-plugin.backend').projectDir = "$rootDir/plugins/noarg/noarg.backend" as File
project(':kotlin-noarg-compiler-plugin.cli').projectDir = "$rootDir/plugins/noarg/noarg.cli" as File
project(':kotlin-sam-with-receiver-compiler-plugin').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver-cli" as File
project(':kotlin-sam-with-receiver-compiler-plugin').projectDir = "$rootDir/plugins/sam-with-receiver" as File
project(':kotlin-sam-with-receiver-compiler-plugin.common').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.common" as File
project(':kotlin-sam-with-receiver-compiler-plugin.k1').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.k1" as File
project(':kotlin-sam-with-receiver-compiler-plugin.k2').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.k2" as File
project(':kotlin-sam-with-receiver-compiler-plugin.cli').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver.cli" as File
project(':tools:kotlinp').projectDir = "$rootDir/libraries/tools/kotlinp" as File
project(':kotlin-project-model').projectDir = "$rootDir/libraries/tools/kotlin-project-model" as File
project(':kotlin-gradle-plugin-api').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugin-api" as File