Java源码示例:com.google.javascript.jscomp.MessageFormatter
示例1
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;
}
示例2
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;
}
示例3
public GentsErrorManager(PrintStream stream, MessageFormatter formatter, boolean debug) {
super(formatter, stream);
this.debug = debug;
}
示例4
ClutzErrorManager(PrintStream stream, MessageFormatter formatter, boolean debug) {
super(formatter, stream);
this.debug = debug;
}
示例5
public AntErrorManager(MessageFormatter formatter, Task task) {
this.formatter = formatter;
this.task = task;
}