use of com.google.javascript.jscomp.LoggerErrorManager in project closure-compiler by google.
the class DependencyFile method loadGraph.
/**
* Loads the dependency graph.
*/
private void loadGraph() throws ServiceException {
dependencies.clear();
logger.info("Loading dependency graph");
// Parse the deps.js file.
ErrorManager errorManager = new LoggerErrorManager(logger);
DepsFileRegexParser parser = new DepsFileRegexParser(errorManager);
List<DependencyInfo> depInfos = parser.parseFile(getName(), getContent());
// Ensure the parse succeeded.
if (!parser.didParseSucceed()) {
throw new ServiceException("Problem parsing " + getName() + ". See logs for details.");
}
// Incorporate the dependencies into our maps.
for (DependencyInfo depInfo : depInfos) {
for (String provide : depInfo.getProvides()) {
DependencyInfo existing = dependencies.get(provide);
if (existing != null && !existing.equals(depInfo)) {
throw new ServiceException("Duplicate provide of " + provide + ". Was provided by " + existing.getPathRelativeToClosureBase() + " and " + depInfo.getPathRelativeToClosureBase());
}
dependencies.put(provide, depInfo);
}
}
List<String> provides = new ArrayList<>();
provides.add(CLOSURE_BASE_PROVIDE);
// Add implicit base.js entry.
dependencies.put(CLOSURE_BASE_PROVIDE, SimpleDependencyInfo.builder(CLOSURE_BASE, CLOSURE_BASE).setProvides(provides).build());
errorManager.generateReport();
logger.info("Dependencies loaded");
}
use of com.google.javascript.jscomp.LoggerErrorManager in project closure-compiler by google.
the class DefaultDependencyResolver method parseRequires.
/**
* Parses a block of code for goog.require statements and extracts the required symbols.
*/
private static Collection<String> parseRequires(String code, boolean addClosureBase) {
ErrorManager errorManager = new LoggerErrorManager(logger);
JsFileRegexParser parser = new JsFileRegexParser(errorManager);
DependencyInfo deps = parser.parseFile("<unknown path>", "<unknown path>", code);
List<String> requires = new ArrayList<>();
if (addClosureBase) {
requires.add(CLOSURE_BASE_PROVIDE);
}
requires.addAll(deps.getRequiredSymbols());
errorManager.generateReport();
return requires;
}
Aggregations