Minor. Renamed and cleaned CompilerServices -> Services.

This commit is contained in:
Evgeny Gerashchenko
2014-08-20 13:45:52 +04:00
parent 69c31c00db
commit 487f381287
9 changed files with 33 additions and 35 deletions
@@ -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
) {
@@ -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()
}
}