diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java index ff48a4ce816..63569e6f4cc 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.cli.common; import com.google.common.base.Predicates; -import com.google.common.collect.Lists; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; @@ -32,7 +31,6 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.kotlin.cli.common.messages.*; import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler; import org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException; -import org.jetbrains.kotlin.config.CompilerConfiguration; import org.jetbrains.kotlin.config.Services; import org.jetbrains.kotlin.progress.CompilationCanceledException; import org.jetbrains.kotlin.progress.CompilationCanceledStatus; @@ -57,18 +55,6 @@ public abstract class CLICompiler { } } - @NotNull - private List compilerPlugins = Lists.newArrayList(); - - @NotNull - public List getCompilerPlugins() { - return compilerPlugins; - } - - public void setCompilerPlugins(@NotNull List compilerPlugins) { - this.compilerPlugins = compilerPlugins; - } - @NotNull public ExitCode exec(@NotNull PrintStream errStream, @NotNull String... args) { return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_RELATIVE_PATHS, args); @@ -95,7 +81,7 @@ public abstract class CLICompiler { } catch (IllegalArgumentException e) { errStream.println(e.getMessage()); - usage(errStream, false); + Usage.print(errStream, createArguments(), false); } catch (Throwable t) { errStream.println(messageRenderer.render( @@ -127,21 +113,6 @@ public abstract class CLICompiler { } } - /** - * Allow derived classes to add additional command line arguments - */ - protected void usage(@NotNull PrintStream target, boolean extraHelp) { - Usage.print(target, createArguments(), extraHelp); - } - - /** - * Strategy method to configure the environment, allowing compiler - * based tools to customise their own plugins - */ - protected void configureEnvironment(@NotNull CompilerConfiguration configuration, @NotNull A arguments) { - configuration.addAll(CLIConfigurationKeys.COMPILER_PLUGINS, compilerPlugins); - } - @NotNull protected abstract A createArguments(); @@ -160,7 +131,7 @@ public abstract class CLICompiler { } if (arguments.help || arguments.extraHelp) { - usage(errStream, arguments.extraHelp); + Usage.print(errStream, createArguments(), arguments.extraHelp); return OK; } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java index 10e68063f31..e893850e100 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLIConfigurationKeys.java @@ -20,13 +20,9 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector; import org.jetbrains.kotlin.cli.jvm.compiler.CompilerJarLocator; import org.jetbrains.kotlin.config.CompilerConfigurationKey; -import java.util.List; - public class CLIConfigurationKeys { public static final CompilerConfigurationKey MESSAGE_COLLECTOR_KEY = CompilerConfigurationKey.create("message collector"); - public static final CompilerConfigurationKey> COMPILER_PLUGINS = - CompilerConfigurationKey.create("compiler plugins"); public static final CompilerConfigurationKey ALLOW_KOTLIN_PACKAGE = CompilerConfigurationKey.create("allow kotlin package"); public static final CompilerConfigurationKey REPORT_PERF = diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CompilerPlugin.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CompilerPlugin.java deleted file mode 100644 index e584c801bd5..00000000000 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CompilerPlugin.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2015 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.cli.common; - -import org.jetbrains.annotations.NotNull; - -/** - * A simple interface for compiler plugins to run after the compiler has finished such as for things like - * generating documentation or code generation etc - */ -public interface CompilerPlugin { - void processFiles(@NotNull CompilerPluginContext context); -} diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CompilerPluginContext.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CompilerPluginContext.java deleted file mode 100644 index d27f9464742..00000000000 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CompilerPluginContext.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2010-2015 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.cli.common; - -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.psi.KtFile; -import org.jetbrains.kotlin.resolve.BindingContext; - -import java.util.List; - -/** - * Represents the context of available state in which a {@link CompilerPlugin} runs such as - * the {@link Project}, the {@link BindingContext} and the underlying {@link KtFile} files. - */ -public class CompilerPluginContext { - @NotNull - private final Project project; - //TODO: should we in fact store AnalysisResult here? - @NotNull - private final BindingContext context; - @NotNull - private final List files; - - public CompilerPluginContext(Project project, BindingContext context, List files) { - this.project = project; - this.context = context; - this.files = files; - } - - @NotNull - public BindingContext getContext() { - return context; - } - - @NotNull - public List getFiles() { - return files; - } - - @NotNull - public Project getProject() { - return project; - } -} diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 49cc2a7e9fb..bc6cd15b6fa 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -45,8 +45,7 @@ import java.io.File import java.lang.management.ManagementFactory import java.util.concurrent.TimeUnit -open class K2JVMCompiler : CLICompiler() { - +class K2JVMCompiler : CLICompiler() { override fun doExecute(arguments: K2JVMCompilerArguments, services: Services, messageCollector: MessageCollector, rootDisposable: Disposable): ExitCode { val messageSeverityCollector = MessageSeverityCollector(messageCollector) val paths = if (arguments.kotlinHome != null) @@ -141,8 +140,6 @@ open class K2JVMCompiler : CLICompiler() { messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment", CompilerMessageLocation.NO_LOCATION) try { - configureEnvironment(configuration, arguments) - val destination = arguments.destination if (arguments.module != null) { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt index 741e979d0d8..bf2b832090f 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.asJava.FilteredJvmDiagnostics import org.jetbrains.kotlin.backend.common.output.OutputFileCollection import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys -import org.jetbrains.kotlin.cli.common.CompilerPluginContext import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.messages.* import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAll @@ -320,15 +319,7 @@ object KotlinToJVMBytecodeCompiler { K2JVMCompiler.reportPerf(environment.configuration, message) - val result = analyzerWithCompilerReport.analysisResult - - val context = CompilerPluginContext(environment.project, result.bindingContext, - environment.getSourceFiles()) - for (plugin in environment.configuration.getList(CLIConfigurationKeys.COMPILER_PLUGINS)) { - plugin.processFiles(context) - } - - return if (analyzerWithCompilerReport.hasErrors()) null else result + return if (analyzerWithCompilerReport.hasErrors()) null else analyzerWithCompilerReport.analysisResult } private fun generate( diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java index 7c3028a083f..fb42191f8e1 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java @@ -135,7 +135,7 @@ public abstract class KotlinCompileMojoBase e MessageCollector messageCollector = new MavenPluginLogMessageCollector(getLog()); - ExitCode exitCode = executeCompiler(compiler, arguments, messageCollector); + ExitCode exitCode = compiler.exec(messageCollector, Services.EMPTY, arguments); switch (exitCode) { case COMPILATION_ERROR: @@ -197,25 +197,9 @@ public abstract class KotlinCompileMojoBase e @NotNull protected abstract CLICompiler createCompiler(); - /** - * Derived classes can create custom compiler argument implementations - * such as for KDoc - */ @NotNull protected abstract A createCompilerArguments(); - @NotNull - protected ExitCode executeCompiler( - @NotNull CLICompiler compiler, - @NotNull A arguments, - @NotNull MessageCollector messageCollector - ) { - return compiler.exec(messageCollector, Services.EMPTY, arguments); - } - - /** - * Derived classes can register custom plugins or configurations - */ protected abstract void configureSpecificCompilerArguments(@NotNull A arguments) throws MojoExecutionException; private void configureCompilerArguments(@NotNull A arguments, @NotNull CLICompiler compiler) throws MojoExecutionException { diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java index 3b7756aeac8..fd282a008f7 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java @@ -16,9 +16,6 @@ package org.jetbrains.kotlin.maven; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -27,12 +24,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments; -import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments; -import org.jetbrains.kotlin.cli.js.K2JSCompiler; -import org.jetbrains.kotlin.utils.LibraryUtils; -import java.io.File; -import java.util.ArrayList; import java.util.List; /**