use of com.google.javascript.jscomp.LazyParsedDependencyInfo in project closure-compiler by google.
the class DepsGenerator method parseSources.
/**
* Parses all source files for dependency information.
* @param preparsedFiles A set of closure-relative paths.
* Files in this set are not parsed if they are encountered in srcs.
* @return Returns a map of closure-relative paths -> DependencyInfo for the
* newly parsed files.
* @throws IOException Occurs upon an IO error.
*/
private Map<String, DependencyInfo> parseSources(Set<String> preparsedFiles) throws IOException {
Map<String, DependencyInfo> parsedFiles = new LinkedHashMap<>();
JsFileParser jsParser = new JsFileParser(errorManager).setModuleLoader(loader);
Compiler compiler = new Compiler();
compiler.init(ImmutableList.of(), ImmutableList.of(), new CompilerOptions());
for (SourceFile file : srcs) {
String closureRelativePath = PathUtil.makeRelative(closurePathAbs, PathUtil.makeAbsolute(file.getName()));
if (logger.isLoggable(Level.FINE)) {
logger.fine("Closure-relative path: " + closureRelativePath);
}
if (InclusionStrategy.WHEN_IN_SRCS == mergeStrategy || !preparsedFiles.contains(closureRelativePath)) {
DependencyInfo depInfo = jsParser.parseFile(file.getName(), closureRelativePath, file.getCode());
depInfo = new LazyParsedDependencyInfo(depInfo, new JsAst(file), compiler);
// Kick the source out of memory.
file.clearCachedSource();
parsedFiles.put(closureRelativePath, depInfo);
}
}
return parsedFiles;
}
Aggregations