Minor. Renamed and cleaned CompilerServices -> Services.
This commit is contained in:
@@ -26,7 +26,7 @@ import org.jetbrains.jet.cli.js.K2JSCompiler
|
||||
import java.io.File
|
||||
import org.apache.tools.ant.BuildException
|
||||
import org.jetbrains.jet.cli.common.ExitCode
|
||||
import org.jetbrains.jet.config.CompilerServices
|
||||
import org.jetbrains.jet.config.Services
|
||||
|
||||
/**
|
||||
* Kotlin JavaScript compiler Ant task.
|
||||
@@ -90,7 +90,7 @@ public class Kotlin2JsCompilerTask : Task() {
|
||||
log("Compiling ${arguments.freeArgs} => [${arguments.outputFile}]");
|
||||
|
||||
val compiler = K2JSCompiler()
|
||||
val exitCode = compiler.exec(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR, CompilerServices.empty, arguments)
|
||||
val exitCode = compiler.exec(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR, Services.EMPTY, arguments)
|
||||
|
||||
if (exitCode != ExitCode.OK) {
|
||||
throw BuildException("Compilation finished with exit code $exitCode")
|
||||
|
||||
@@ -27,12 +27,10 @@ import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.messages.*;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.cli.common.ExitCode.*;
|
||||
|
||||
@@ -51,12 +49,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
|
||||
@NotNull
|
||||
public ExitCode exec(@NotNull PrintStream errStream, @NotNull String... args) {
|
||||
return exec(errStream, new CompilerServices.Builder().build(), MessageRenderer.PLAIN_WITH_RELATIVE_PATH, args);
|
||||
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_WITH_RELATIVE_PATH, args);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration") // Used via reflection in CompilerRunnerUtil#invokeExecMethod
|
||||
@NotNull
|
||||
public ExitCode execAndOutputHtml(@NotNull PrintStream errStream, @NotNull CompilerServices services, @NotNull String... args) {
|
||||
public ExitCode execAndOutputHtml(@NotNull PrintStream errStream, @NotNull Services services, @NotNull String... args) {
|
||||
return exec(errStream, services, MessageRenderer.TAGS, args);
|
||||
}
|
||||
|
||||
@@ -102,7 +100,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
@NotNull
|
||||
private ExitCode exec(
|
||||
@NotNull PrintStream errStream,
|
||||
@NotNull CompilerServices services,
|
||||
@NotNull Services services,
|
||||
@NotNull MessageRenderer messageRenderer,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
@@ -135,7 +133,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull CompilerServices services, @NotNull A arguments) {
|
||||
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
|
||||
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
||||
try {
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
@@ -161,7 +159,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
@NotNull
|
||||
protected abstract ExitCode doExecute(
|
||||
@NotNull A arguments,
|
||||
@NotNull CompilerServices services,
|
||||
@NotNull Services services,
|
||||
@NotNull MessageCollector messageCollector,
|
||||
@NotNull Disposable rootDisposable
|
||||
);
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.jetbrains.jet.cli.common.output.outputUtils.OutputUtilsPackage;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.analyze.AnalyzerFacadeForJS;
|
||||
import org.jetbrains.k2js.config.*;
|
||||
@@ -74,7 +74,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
@Override
|
||||
protected ExitCode doExecute(
|
||||
@NotNull K2JSCompilerArguments arguments,
|
||||
@NotNull CompilerServices services,
|
||||
@NotNull Services services,
|
||||
@NotNull MessageCollector messageCollector,
|
||||
@NotNull Disposable rootDisposable
|
||||
) {
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.jet.cli.jvm.repl.ReplFromTerminal;
|
||||
import org.jetbrains.jet.codegen.CompilationException;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.IncrementalCacheProvider;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
@@ -59,7 +59,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
@NotNull
|
||||
protected ExitCode doExecute(
|
||||
@NotNull K2JVMCompilerArguments arguments,
|
||||
@NotNull CompilerServices services,
|
||||
@NotNull Services services,
|
||||
@NotNull MessageCollector messageCollector,
|
||||
@NotNull Disposable rootDisposable
|
||||
) {
|
||||
|
||||
+8
-8
@@ -18,13 +18,18 @@ package org.jetbrains.jet.config
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
public class CompilerServices private(private val map: Map<Class<*>, Any>) {
|
||||
public class Services private(private val map: Map<Class<*>, Any>) {
|
||||
class object {
|
||||
public val EMPTY: Services = Builder().build()
|
||||
}
|
||||
|
||||
public fun <T> get(interfaceClass: Class<T>): T {
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
return map.get(interfaceClass) as T
|
||||
}
|
||||
|
||||
public class Builder {
|
||||
|
||||
private val map = HashMap<Class<*>, Any>()
|
||||
|
||||
public fun <T> register(interfaceClass: Class<T>, implementation: T): Builder {
|
||||
@@ -32,13 +37,8 @@ public class CompilerServices private(private val map: Map<Class<*>, Any>) {
|
||||
return this
|
||||
}
|
||||
|
||||
public fun build(): CompilerServices {
|
||||
return CompilerServices(map)
|
||||
public fun build(): Services {
|
||||
return Services(map)
|
||||
}
|
||||
}
|
||||
|
||||
public class object {
|
||||
public val empty: CompilerServices
|
||||
get() = Builder().build()
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.compiler.runner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
import org.jetbrains.jet.preloading.ClassCondition;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
@@ -36,7 +36,7 @@ public final class CompilerEnvironment {
|
||||
@Nullable File outputDir,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@NotNull ClassCondition classesToLoadByParent,
|
||||
@NotNull CompilerServices compilerServices
|
||||
@NotNull Services compilerServices
|
||||
) {
|
||||
return new CompilerEnvironment(kotlinPaths, outputDir, parentClassLoader, classesToLoadByParent, compilerServices);
|
||||
}
|
||||
@@ -47,17 +47,17 @@ public final class CompilerEnvironment {
|
||||
private final File output;
|
||||
@Nullable
|
||||
private final ClassLoader parentClassLoader;
|
||||
@Nullable
|
||||
@NotNull
|
||||
private final ClassCondition classesToLoadByParent;
|
||||
@NotNull
|
||||
private final CompilerServices services;
|
||||
private final Services services;
|
||||
|
||||
private CompilerEnvironment(
|
||||
@NotNull KotlinPaths kotlinPaths,
|
||||
@Nullable File output,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@NotNull ClassCondition classesToLoadByParent,
|
||||
@NotNull CompilerServices services
|
||||
@NotNull Services services
|
||||
) {
|
||||
this.kotlinPaths = kotlinPaths;
|
||||
this.output = output;
|
||||
@@ -86,7 +86,7 @@ public final class CompilerEnvironment {
|
||||
return parentClassLoader;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public ClassCondition getClassesToLoadByParent() {
|
||||
return classesToLoadByParent;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public final class CompilerEnvironment {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CompilerServices getServices() {
|
||||
public Services getServices() {
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.compiler.runner.CompilerEnvironment;
|
||||
import org.jetbrains.jet.compiler.runner.CompilerRunnerConstants;
|
||||
import org.jetbrains.jet.compiler.runner.OutputItemsCollectorImpl;
|
||||
import org.jetbrains.jet.compiler.runner.SimpleOutputItem;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.jps.JpsKotlinCompilerSettings;
|
||||
import org.jetbrains.jet.jps.incremental.*;
|
||||
@@ -128,7 +128,7 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
||||
incrementalCaches.put(target, dataManager.getStorage(target, IncrementalCacheStorageProvider.INSTANCE$));
|
||||
}
|
||||
|
||||
CompilerServices compilerServices = new CompilerServices.Builder()
|
||||
Services compilerServices = new Services.Builder()
|
||||
.register(IncrementalCacheProvider.class, new IncrementalCacheProviderImpl(incrementalCaches))
|
||||
.build();
|
||||
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.doc.KDocConfig
|
||||
import java.util.concurrent.Callable
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.jet.config.CompilerServices
|
||||
import org.jetbrains.jet.config.Services
|
||||
|
||||
public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
@@ -123,7 +123,7 @@ public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
val messageCollector = GradleMessageCollector(getLogger())
|
||||
getLogger().debug("Calling compiler")
|
||||
val exitCode = compiler.exec(messageCollector, CompilerServices.empty, args)
|
||||
val exitCode = compiler.exec(messageCollector, Services.EMPTY, args)
|
||||
|
||||
when (exitCode) {
|
||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details")
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -260,7 +260,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
||||
@NotNull CommonCompilerArguments arguments,
|
||||
@NotNull MessageCollector messageCollector
|
||||
) {
|
||||
return compiler.exec(messageCollector, CompilerServices.OBJECT$.getEmpty(), arguments);
|
||||
return compiler.exec(messageCollector, Services.EMPTY, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user