com.google.javascript.jscomp.MessageFormatter Java Examples

The following examples show how to use com.google.javascript.jscomp.MessageFormatter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClosureCompiler.java    From caja with Apache License 2.0 5 votes vote down vote up
public static String build(Task task, List<File> inputs) {
  List<SourceFile> externs;
  try {
    externs = CommandLineRunner.getDefaultExterns();
  } catch (IOException e) {
    throw new BuildException(e);
  }

  List<SourceFile> jsInputs = new ArrayList<SourceFile>();
  for (File f : inputs) {
    jsInputs.add(SourceFile.fromFile(f));
  }

  CompilerOptions options = new CompilerOptions();
  CompilationLevel.ADVANCED_OPTIMIZATIONS
      .setOptionsForCompilationLevel(options);
  WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
  for (DiagnosticGroup dg : diagnosticGroups) {
    options.setWarningLevel(dg, CheckLevel.ERROR);
  }

  options.setCodingConvention(new GoogleCodingConvention());

  Compiler compiler = new Compiler();
  MessageFormatter formatter =
      options.errorFormat.toFormatter(compiler, false);
  AntErrorManager errorManager = new AntErrorManager(formatter, task);
  compiler.setErrorManager(errorManager);

  Result r = compiler.compile(externs, jsInputs, options);
  if (!r.success) {
    return null;
  }

  String wrapped = "(function(){" + compiler.toSource() + "})();\n";
  return wrapped;
}
 
Example #2
Source File: CompileTask.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private Compiler createCompiler(CompilerOptions options) {
  Compiler compiler = new Compiler();
  MessageFormatter formatter =
      options.errorFormat.toFormatter(compiler, false);
  AntErrorManager errorManager = new AntErrorManager(formatter, this);
  compiler.setErrorManager(errorManager);
  return compiler;
}
 
Example #3
Source File: GentsErrorManager.java    From clutz with MIT License 4 votes vote down vote up
public GentsErrorManager(PrintStream stream, MessageFormatter formatter, boolean debug) {
  super(formatter, stream);
  this.debug = debug;
}
 
Example #4
Source File: ClutzErrorManager.java    From clutz with MIT License 4 votes vote down vote up
ClutzErrorManager(PrintStream stream, MessageFormatter formatter, boolean debug) {
  super(formatter, stream);
  this.debug = debug;
}
 
Example #5
Source File: AntErrorManager.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public AntErrorManager(MessageFormatter formatter, Task task) {
  this.formatter = formatter;
  this.task = task;
}