本文整理汇总了Java中com.google.javascript.jscomp.SourceFile.clearCachedSource方法的典型用法代码示例。如果您正苦于以下问题:Java SourceFile.clearCachedSource方法的具体用法?Java SourceFile.clearCachedSource怎么用?Java SourceFile.clearCachedSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.jscomp.SourceFile
的用法示例。
在下文中一共展示了SourceFile.clearCachedSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSources
import com.google.javascript.jscomp.SourceFile; //导入方法依赖的package包/类
/**
* 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 = Maps.newHashMap();
JsFileParser jsParser = new JsFileParser(errorManager);
for (SourceFile file : srcs) {
String closureRelativePath =
PathUtil.makeRelative(
closurePathAbs, PathUtil.makeAbsolute(file.getName()));
logger.fine("Closure-relative path: " + closureRelativePath);
if (InclusionStrategy.WHEN_IN_SRCS == mergeStrategy ||
!preparsedFiles.contains(closureRelativePath)) {
DependencyInfo depInfo =
jsParser.parseFile(
file.getName(), closureRelativePath,
file.getCode());
// Kick the source out of memory.
file.clearCachedSource();
parsedFiles.put(closureRelativePath, depInfo);
}
}
return parsedFiles;
}
示例2: parseSources
import com.google.javascript.jscomp.SourceFile; //导入方法依赖的package包/类
/**
* 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.<SourceFile>of(), ImmutableList.<SourceFile>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;
}