Search in sources :

Example 31 with SourceFile

use of com.google.javascript.jscomp.SourceFile in project ow by vtst.

the class DefaultExternsProvider method loadExterns.

/**
 * @return The default externs, as a list of AST factories.
 * @throws IOException
 */
private static List<JSExtern> loadExterns() throws IOException {
    List<SourceFile> sourceFiles = getAsSourceFiles();
    ArrayList<JSExtern> externs = new ArrayList<JSExtern>(sourceFiles.size());
    for (SourceFile sourceFile : sourceFiles) externs.add(new JSExtern(sourceFile));
    return externs;
}
Also used : JSExtern(net.vtst.ow.closure.compiler.deps.JSExtern) ArrayList(java.util.ArrayList) SourceFile(com.google.javascript.jscomp.SourceFile)

Example 32 with SourceFile

use of com.google.javascript.jscomp.SourceFile in project AngularBeans by bessemHmidi.

the class ClosureCompiler method compile.

public String compile(String code) {
    Compiler compiler = new Compiler();
    compiler.disableThreads();
    SourceFile extern = SourceFile.fromCode("externs.js", "function alert(x) {}");
    SourceFile input = SourceFile.fromCode("input.js", code);
    compiler.compile(extern, input, options);
    return compiler.toSource();
}
Also used : Compiler(com.google.javascript.jscomp.Compiler) SourceFile(com.google.javascript.jscomp.SourceFile)

Aggregations

SourceFile (com.google.javascript.jscomp.SourceFile)32 Compiler (com.google.javascript.jscomp.Compiler)9 CompilerOptions (com.google.javascript.jscomp.CompilerOptions)7 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 Result (com.google.javascript.jscomp.Result)3 StaticSourceFile (com.google.javascript.rhino.StaticSourceFile)3 EntryPoint (com.google.gwt.core.client.EntryPoint)2 LazyParsedDependencyInfo (com.google.javascript.jscomp.LazyParsedDependencyInfo)2 SourceMapInput (com.google.javascript.jscomp.SourceMapInput)2 ParserRunner (com.google.javascript.jscomp.parsing.ParserRunner)2 Node (com.google.javascript.rhino.Node)2 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 JSExtern (net.vtst.ow.closure.compiler.deps.JSExtern)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ErrorManager (com.google.javascript.jscomp.ErrorManager)1 JsAst (com.google.javascript.jscomp.JsAst)1 Config (com.google.javascript.jscomp.parsing.Config)1 Comment (com.google.javascript.jscomp.parsing.parser.trees.Comment)1