From 0d8088268af0ef539efc67fae95492d6ed37a280 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Mon, 9 Apr 2012 23:49:31 +0400 Subject: [PATCH] extract code to method --- .../org/jetbrains/jet/cli/KotlinCompiler.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java index 9e64a6e3b2d..fc3af75040f 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.cli; import com.google.common.base.Splitter; import com.google.common.collect.Iterables; import com.sampullara.cli.Args; +import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.compiler.CompileEnvironment; import org.jetbrains.jet.compiler.CompileEnvironmentException; import org.jetbrains.jet.compiler.CompilerPlugin; @@ -105,23 +106,7 @@ public class KotlinCompiler { errStream.println(messageRenderer.render(Severity.INFO, "Kotlin Compiler version " + CompilerVersion.VERSION, null, -1, -1)); } - CompilerSpecialMode mode; - if (arguments.mode == null) { - mode = CompilerSpecialMode.REGULAR; - } - else { - computeMode: - { - for (CompilerSpecialMode variant : CompilerSpecialMode.values()) { - if (arguments.mode.equalsIgnoreCase(variant.name().replaceAll("_", ""))) { - mode = variant; - break computeMode; - } - } - // TODO: report properly - throw new IllegalArgumentException("unknown compiler mode: " + arguments.mode); - } - } + CompilerSpecialMode mode = parseCompilerSpecialMode(arguments); File jdkHeadersJar; if (mode.includeJdkHeaders()) { @@ -175,6 +160,22 @@ public class KotlinCompiler { } } + @NotNull + private CompilerSpecialMode parseCompilerSpecialMode(@NotNull CompilerArguments arguments) { + if (arguments.mode == null) { + return CompilerSpecialMode.REGULAR; + } + else { + for (CompilerSpecialMode variant : CompilerSpecialMode.values()) { + if (arguments.mode.equalsIgnoreCase(variant.name().replaceAll("_", ""))) { + return variant; + } + } + } + // TODO: report properly + throw new IllegalArgumentException("unknown compiler mode: " + arguments.mode); + } + /** * Returns true if the arguments can be parsed correctly */