Extract reusable functionality from K2JVMCompiler, K2JVMCompilerArguments, CompilerEnvironmentConfiguration.

This commit is contained in:
pTalanov
2012-04-26 13:43:04 +04:00
parent 98bd8bc90a
commit cdfa0678cf
13 changed files with 323 additions and 151 deletions
@@ -20,7 +20,7 @@ fun main(args: Array<String?>): Unit {
*/
class KDocCompiler() : K2JVMCompiler() {
protected override fun configureEnvironment(configuration : CompileEnvironmentConfiguration?, arguments : K2JVMCompilerArguments?) {
protected override fun configureEnvironment(configuration : CompileEnvironmentConfiguration, arguments : K2JVMCompilerArguments) {
super.configureEnvironment(configuration, arguments)
val coreEnvironment = configuration?.getEnvironment()
if (coreEnvironment != null) {
@@ -38,11 +38,11 @@ class KDocCompiler() : K2JVMCompiler() {
}
}
protected override fun createArguments() : K2JVMCompilerArguments? {
protected override fun createArguments() : K2JVMCompilerArguments {
return KDocArguments()
}
protected override fun usage(target : PrintStream?) {
protected override fun usage(target : PrintStream) {
target?.println("Usage: KDocCompiler -docOutput <docOutputDir> [-output <outputDir>|-jar <jarFileName>] [-stdlib <path to runtime.jar>] [-src <filename or dirname>|-module <module file>] [-includeRuntime]");
}
}
@@ -7,20 +7,18 @@ import org.jetbrains.jet.cli.common.CompilerPluginContext
*/
class HtmlCompilerPlugin: CompilerPlugin {
public override fun processFiles(context: CompilerPluginContext?) {
if (context != null) {
val bindingContext = context.getContext()
val files = context.getFiles()
if (bindingContext != null && files != null) {
if (files != null && bindingContext != null) {
for (file in files) {
if (file != null) {
val visitor = HtmlKotlinVisitor()
file.accept(visitor)
}
}
}
}
}
public override fun processFiles(context: CompilerPluginContext) {
val bindingContext = context.getContext()
val files = context.getFiles()
if (bindingContext != null && files != null) {
if (files != null && bindingContext != null) {
for (file in files) {
if (file != null) {
val visitor = HtmlKotlinVisitor()
file.accept(visitor)
}
}
}
}
}
}
@@ -10,16 +10,14 @@ abstract class KModelCompilerPlugin: CompilerPlugin {
public open var config: KDocConfig = KDocConfig()
public override fun processFiles(context: CompilerPluginContext?) {
if (context != null) {
val bindingContext = context.getContext()
val sources = context.getFiles()
if (bindingContext != null && sources != null) {
val model = KModel(bindingContext, config)
model.load(sources)
public override fun processFiles(context: CompilerPluginContext) {
val bindingContext = context.getContext()
val sources = context.getFiles()
if (bindingContext != null && sources != null) {
val model = KModel(bindingContext, config)
model.load(sources)
processModel(model)
}
processModel(model)
}
}