Remove traces of old compiler plugin architecture
It was retired with the deprecation and subsequent removal of the old KDoc, and is now unused
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.cli.common;
|
package org.jetbrains.kotlin.cli.common;
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.util.Disposer;
|
import com.intellij.openapi.util.Disposer;
|
||||||
import com.intellij.openapi.util.SystemInfo;
|
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.common.messages.*;
|
||||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
|
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException;
|
import org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException;
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
|
||||||
import org.jetbrains.kotlin.config.Services;
|
import org.jetbrains.kotlin.config.Services;
|
||||||
import org.jetbrains.kotlin.progress.CompilationCanceledException;
|
import org.jetbrains.kotlin.progress.CompilationCanceledException;
|
||||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus;
|
import org.jetbrains.kotlin.progress.CompilationCanceledStatus;
|
||||||
@@ -57,18 +55,6 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private List<CompilerPlugin> compilerPlugins = Lists.newArrayList();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public List<CompilerPlugin> getCompilerPlugins() {
|
|
||||||
return compilerPlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCompilerPlugins(@NotNull List<CompilerPlugin> compilerPlugins) {
|
|
||||||
this.compilerPlugins = compilerPlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ExitCode exec(@NotNull PrintStream errStream, @NotNull String... args) {
|
public ExitCode exec(@NotNull PrintStream errStream, @NotNull String... args) {
|
||||||
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_RELATIVE_PATHS, args);
|
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_RELATIVE_PATHS, args);
|
||||||
@@ -95,7 +81,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
errStream.println(e.getMessage());
|
errStream.println(e.getMessage());
|
||||||
usage(errStream, false);
|
Usage.print(errStream, createArguments(), false);
|
||||||
}
|
}
|
||||||
catch (Throwable t) {
|
catch (Throwable t) {
|
||||||
errStream.println(messageRenderer.render(
|
errStream.println(messageRenderer.render(
|
||||||
@@ -127,21 +113,6 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
@NotNull
|
||||||
protected abstract A createArguments();
|
protected abstract A createArguments();
|
||||||
|
|
||||||
@@ -160,7 +131,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.help || arguments.extraHelp) {
|
if (arguments.help || arguments.extraHelp) {
|
||||||
usage(errStream, arguments.extraHelp);
|
Usage.print(errStream, createArguments(), arguments.extraHelp);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,9 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
|||||||
import org.jetbrains.kotlin.cli.jvm.compiler.CompilerJarLocator;
|
import org.jetbrains.kotlin.cli.jvm.compiler.CompilerJarLocator;
|
||||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey;
|
import org.jetbrains.kotlin.config.CompilerConfigurationKey;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CLIConfigurationKeys {
|
public class CLIConfigurationKeys {
|
||||||
public static final CompilerConfigurationKey<MessageCollector> MESSAGE_COLLECTOR_KEY =
|
public static final CompilerConfigurationKey<MessageCollector> MESSAGE_COLLECTOR_KEY =
|
||||||
CompilerConfigurationKey.create("message collector");
|
CompilerConfigurationKey.create("message collector");
|
||||||
public static final CompilerConfigurationKey<List<CompilerPlugin>> COMPILER_PLUGINS =
|
|
||||||
CompilerConfigurationKey.create("compiler plugins");
|
|
||||||
public static final CompilerConfigurationKey<Boolean> ALLOW_KOTLIN_PACKAGE =
|
public static final CompilerConfigurationKey<Boolean> ALLOW_KOTLIN_PACKAGE =
|
||||||
CompilerConfigurationKey.create("allow kotlin package");
|
CompilerConfigurationKey.create("allow kotlin package");
|
||||||
public static final CompilerConfigurationKey<Boolean> REPORT_PERF =
|
public static final CompilerConfigurationKey<Boolean> REPORT_PERF =
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -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<KtFile> files;
|
|
||||||
|
|
||||||
public CompilerPluginContext(Project project, BindingContext context, List<KtFile> files) {
|
|
||||||
this.project = project;
|
|
||||||
this.context = context;
|
|
||||||
this.files = files;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public BindingContext getContext() {
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public List<KtFile> getFiles() {
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public Project getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -45,8 +45,7 @@ import java.io.File
|
|||||||
import java.lang.management.ManagementFactory
|
import java.lang.management.ManagementFactory
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||||
|
|
||||||
override fun doExecute(arguments: K2JVMCompilerArguments, services: Services, messageCollector: MessageCollector, rootDisposable: Disposable): ExitCode {
|
override fun doExecute(arguments: K2JVMCompilerArguments, services: Services, messageCollector: MessageCollector, rootDisposable: Disposable): ExitCode {
|
||||||
val messageSeverityCollector = MessageSeverityCollector(messageCollector)
|
val messageSeverityCollector = MessageSeverityCollector(messageCollector)
|
||||||
val paths = if (arguments.kotlinHome != null)
|
val paths = if (arguments.kotlinHome != null)
|
||||||
@@ -141,8 +140,6 @@ open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
|
|
||||||
messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment", CompilerMessageLocation.NO_LOCATION)
|
messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment", CompilerMessageLocation.NO_LOCATION)
|
||||||
try {
|
try {
|
||||||
configureEnvironment(configuration, arguments)
|
|
||||||
|
|
||||||
val destination = arguments.destination
|
val destination = arguments.destination
|
||||||
|
|
||||||
if (arguments.module != null) {
|
if (arguments.module != null) {
|
||||||
|
|||||||
+1
-10
@@ -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.OutputFileCollection
|
||||||
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
|
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
|
||||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
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.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.common.messages.*
|
import org.jetbrains.kotlin.cli.common.messages.*
|
||||||
import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAll
|
import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAll
|
||||||
@@ -320,15 +319,7 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
|
|
||||||
K2JVMCompiler.reportPerf(environment.configuration, message)
|
K2JVMCompiler.reportPerf(environment.configuration, message)
|
||||||
|
|
||||||
val result = analyzerWithCompilerReport.analysisResult
|
return if (analyzerWithCompilerReport.hasErrors()) null else 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generate(
|
private fun generate(
|
||||||
|
|||||||
+1
-17
@@ -135,7 +135,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
|
|
||||||
MessageCollector messageCollector = new MavenPluginLogMessageCollector(getLog());
|
MessageCollector messageCollector = new MavenPluginLogMessageCollector(getLog());
|
||||||
|
|
||||||
ExitCode exitCode = executeCompiler(compiler, arguments, messageCollector);
|
ExitCode exitCode = compiler.exec(messageCollector, Services.EMPTY, arguments);
|
||||||
|
|
||||||
switch (exitCode) {
|
switch (exitCode) {
|
||||||
case COMPILATION_ERROR:
|
case COMPILATION_ERROR:
|
||||||
@@ -197,25 +197,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
@NotNull
|
@NotNull
|
||||||
protected abstract CLICompiler<A> createCompiler();
|
protected abstract CLICompiler<A> createCompiler();
|
||||||
|
|
||||||
/**
|
|
||||||
* Derived classes can create custom compiler argument implementations
|
|
||||||
* such as for KDoc
|
|
||||||
*/
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected abstract A createCompilerArguments();
|
protected abstract A createCompilerArguments();
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected ExitCode executeCompiler(
|
|
||||||
@NotNull CLICompiler<A> 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;
|
protected abstract void configureSpecificCompilerArguments(@NotNull A arguments) throws MojoExecutionException;
|
||||||
|
|
||||||
private void configureCompilerArguments(@NotNull A arguments, @NotNull CLICompiler<A> compiler) throws MojoExecutionException {
|
private void configureCompilerArguments(@NotNull A arguments, @NotNull CLICompiler<A> compiler) throws MojoExecutionException {
|
||||||
|
|||||||
-8
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.maven;
|
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.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
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.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user