diff --git a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java index 85ffe896d88888521353adb7321440898bdb3886..c88a483958c70bbad48192c58f1c3193db9700a7 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java @@ -20,12 +20,14 @@ import com.google.common.base.Predicates; import com.intellij.openapi.Disposable; import com.intellij.psi.PsiFile; import jet.Function0; -import jet.modules.Module; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.ExitCode; -import org.jetbrains.jet.cli.common.messages.*; +import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport; +import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity; +import org.jetbrains.jet.cli.common.messages.MessageRenderer; +import org.jetbrains.jet.cli.common.messages.PrintingMessageCollector; import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.lang.psi.JetFile; @@ -34,7 +36,6 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; import org.jetbrains.k2js.analyze.AnalyzerFacadeForJS; import org.jetbrains.k2js.config.Config; -import java.io.File; import java.io.PrintStream; import java.util.Collections; import java.util.List; @@ -61,37 +62,36 @@ public class K2JSCompiler extends CLICompiler modules = CompileEnvironmentUtil - .loadModuleScript(arguments.module, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR); - for (Module module : modules) { - Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable(); - final JetCoreEnvironment environmentForJS = JetCoreEnvironment.getCoreEnvironmentForJS(rootDisposable); - CompileEnvironmentUtil.addSourcesFromModuleToEnvironment(environmentForJS, module, directory); - AnalyzerWithCompilerReport analyzerWithCompilerReport = - new AnalyzerWithCompilerReport(messageCollector); - final List sources = environmentForJS.getSourceFiles(); - analyzerWithCompilerReport.analyzeAndReport(new Function0() { - @Override - public AnalyzeExhaust invoke() { - BindingContext context = AnalyzerFacadeForJS - .analyzeFiles(sources, Predicates.alwaysTrue(), new Config(environmentForJS.getProject()) { - @NotNull - @Override - protected List generateLibFiles() { - return Collections.emptyList(); - } - }); - return AnalyzeExhaust.success(context, JetStandardLibrary.getInstance()); - } - }, sources); + if (arguments.srcdir == null) { + stream.print(renderer.render(CompilerMessageSeverity.ERROR, "Specify sources location via -srcdir", NO_LOCATION)); + return ExitCode.INTERNAL_ERROR; } + Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable(); + final JetCoreEnvironment environmentForJS = JetCoreEnvironment.getCoreEnvironmentForJS(rootDisposable); + environmentForJS.addSources(arguments.srcdir); + AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(messageCollector); + final List sources = environmentForJS.getSourceFiles(); + analyzerWithCompilerReport.analyzeAndReport(new Function0() { + @Override + public AnalyzeExhaust invoke() { + BindingContext context = AnalyzerFacadeForJS + .analyzeFiles(sources, Predicates.alwaysTrue(), new Config(environmentForJS.getProject()) { + @NotNull + @Override + protected List generateLibFiles() { + return Collections.emptyList(); + } + }); + return AnalyzeExhaust.success(context, JetStandardLibrary.getInstance()); + } + }, sources); + stream.print(renderer.render(CompilerMessageSeverity.ERROR, "Greeting", NO_LOCATION)); return ExitCode.OK; } diff --git a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompilerArguments.java b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompilerArguments.java index 36314959e0e63f29c053bd3b1e975d06d4292d6f..75f0855d8648f6c5a60508c134184a5c71b31af4 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompilerArguments.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompilerArguments.java @@ -23,12 +23,15 @@ import org.jetbrains.jet.cli.common.CompilerArguments; * @author Pavel Talanov */ public class K2JSCompilerArguments extends CompilerArguments { - @Argument(value = "output", description = "output directory") + @Argument(value = "output", description = "Output directory") public String outputDir; - @Argument(value = "module", description = "module to compile") + @Argument(value = "module", description = "Module to compile") public String module; + @Argument(value = "srcdir", description = "Sources directory") + public String srcdir; + @Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag") public boolean tags;