From 58f408e173ff38e3fd83084ff0e63be6f5d20056 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 27 Sep 2016 18:05:12 +0300 Subject: [PATCH] Allopen: Add allopen compiler plugin --- .idea/modules.xml | 1 + build.xml | 27 ++++++++- plugins/allopen/allopen.iml | 13 +++++ plugins/allopen/src/AllOpenPlugin.kt | 58 +++++++++++++++++++ ...otlin.compiler.plugin.CommandLineProcessor | 1 + ....kotlin.compiler.plugin.ComponentRegistrar | 1 + 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 plugins/allopen/allopen.iml create mode 100644 plugins/allopen/src/AllOpenPlugin.kt create mode 100644 plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor create mode 100644 plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar diff --git a/.idea/modules.xml b/.idea/modules.xml index 7be217f18b4..27f12a3cb19 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + diff --git a/build.xml b/build.xml index 74e4a20b81f..427843676c3 100644 --- a/build.xml +++ b/build.xml @@ -819,6 +819,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -1227,11 +1250,11 @@ depends="builtins,stdlib,kotlin-test,core,reflection,pack-runtime,pack-runtime-sources,script-runtime,mock-runtime-for-test"/> + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/allopen/src/AllOpenPlugin.kt b/plugins/allopen/src/AllOpenPlugin.kt new file mode 100644 index 00000000000..d5af5b3c891 --- /dev/null +++ b/plugins/allopen/src/AllOpenPlugin.kt @@ -0,0 +1,58 @@ +/* + * 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. + */ + +package org.jetbrains.kotlin.allopen + +import com.intellij.mock.MockProject +import org.jetbrains.kotlin.compiler.plugin.CliOption +import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException +import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor +import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.config.CompilerConfigurationKey + +object AllOpenConfigurationKeys { + val ANNOTATION: CompilerConfigurationKey> = + CompilerConfigurationKey.create("annotation qualified name") +} + +class AllOpenCommandLineProcessor : CommandLineProcessor { + companion object { + val ANNOTATION_OPTION = CliOption("annotation", "", "Annotation qualified names", + required = false, allowMultipleOccurrences = true) + } + + override val pluginId = "org.jetbrains.kotlin.allopen" + override val pluginOptions = listOf(ANNOTATION_OPTION) + + override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) = when (option) { + ANNOTATION_OPTION -> { + val paths = configuration.getList(AllOpenConfigurationKeys.ANNOTATION).toMutableList() + paths.add(value) + configuration.put(AllOpenConfigurationKeys.ANNOTATION, paths) + } + else -> throw CliOptionProcessingException("Unknown option: ${option.name}") + } +} + +class AllOpenComponentRegistrar : ComponentRegistrar { + override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) { + val annotations = configuration.get(AllOpenConfigurationKeys.ANNOTATION) ?: return + if (annotations.isEmpty()) return + + //TODO + } +} \ No newline at end of file diff --git a/plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor b/plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor new file mode 100644 index 00000000000..31c13bcb5bf --- /dev/null +++ b/plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor @@ -0,0 +1 @@ +org.jetbrains.kotlin.allopen.AllOpenCommandLineProcessor \ No newline at end of file diff --git a/plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar b/plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar new file mode 100644 index 00000000000..a6b5025d0dc --- /dev/null +++ b/plugins/allopen/src/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar @@ -0,0 +1 @@ +org.jetbrains.kotlin.allopen.AllOpenComponentRegistrar \ No newline at end of file