K2JSCompiler and K2JSTranslator fixes (mostly codestyle)

This commit is contained in:
pTalanov
2012-06-01 15:19:47 +04:00
parent 23db5d7fc8
commit cbcee10618
2 changed files with 17 additions and 17 deletions
@@ -89,13 +89,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments, K2JSCompile
environmentForJS.getSourceFiles().addAll(sourceFiles);
if (arguments.isVerbose()) {
Iterable<String> fileNames = Iterables.transform(environmentForJS.getSourceFiles(), new Function<JetFile, String>() {
@Override
public String apply(@Nullable JetFile file) {
return file.getName();
}
});
System.out.println("Compiling source files: " + Joiner.on(", ").join(fileNames));
reportCompiledSourcesList(messageCollector, environmentForJS);
}
String outputFile = arguments.outputFile;
@@ -109,6 +103,19 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments, K2JSCompile
return translateAndGenerateOutputFile(mainCallParameters, messageCollector, environmentForJS, config, outputFile);
}
private static void reportCompiledSourcesList(@NotNull PrintingMessageCollector messageCollector,
@NotNull JetCoreEnvironment environmentForJS) {
Iterable<String> fileNames = Iterables.transform(environmentForJS.getSourceFiles(), new Function<JetFile, String>() {
@Override
public String apply(@Nullable JetFile file) {
assert file != null;
return file.getName();
}
});
messageCollector.report(CompilerMessageSeverity.LOGGING, "Compiling source files: " + Joiner.on(", ").join(fileNames),
CompilerMessageLocation.NO_LOCATION);
}
@NotNull
private static ExitCode translateAndGenerateOutputFile(@NotNull MainCallParameters mainCall,
@NotNull PrintingMessageCollector messageCollector,
@@ -121,7 +128,6 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments, K2JSCompile
CompilerMessageLocation.NO_LOCATION);
// TODO we should report the exception nicely to the collector so it can report
// for example inside a mvn plugin we need to see the stack trace
e.printStackTrace();
return ExitCode.INTERNAL_ERROR;
}
return ExitCode.OK;
@@ -45,16 +45,10 @@ import static org.jetbrains.k2js.facade.FacadeUtils.writeCodeToFile;
*/
public final class K2JSTranslator {
public static void translateWithCallToMainAndSaveToFile(@NotNull List<JetFile> files,
public static void translateWithMainCallParametersAndSaveToFile(@NotNull MainCallParameters mainCall,
@NotNull List<JetFile> files,
@NotNull String outputPath,
@NotNull Config config) throws Exception {
translateWithMainCallParametersAndSaveToFile(MainCallParameters.mainWithoutArguments(), files, outputPath, config);
}
public static void translateWithMainCallParametersAndSaveToFile(MainCallParameters mainCall,
List<JetFile> files,
String outputPath,
Config config) throws TranslationException, IOException {
@NotNull Config config) throws TranslationException, IOException {
K2JSTranslator translator = new K2JSTranslator(config);
String programCode = translator.generateProgramCode(files, mainCall) + "\n";
writeCodeToFile(outputPath, programCode);