com.google.javascript.jscomp.Compiler.replaceIncrementalSourceAst()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 JavaScript  
字(1.5k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中com.google.javascript.jscomp.Compiler.replaceIncrementalSourceAst()方法的一些代码示例,展示了Compiler.replaceIncrementalSourceAst()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Compiler.replaceIncrementalSourceAst()方法的具体详情如下:
包路径:com.google.javascript.jscomp.Compiler
类名称:Compiler
方法名:replaceIncrementalSourceAst

Compiler.replaceIncrementalSourceAst介绍

[英]Replace a source input dynamically. Intended for incremental re-compilation. If the new source input doesn't parse, then keep the old input in the AST and return false.
[中]动态替换源输入。用于增量重新编译。如果新的源输入没有解析,则将旧输入保留在AST中并返回false。

代码示例

代码示例来源:origin: com.google.javascript/closure-compiler

/**
 * Replaces one file in a hot-swap mode. The given JsAst should be made
 * from a new version of a file that already was present in the last compile
 * call. If the file is new, this will silently ignored.
 *
 * @param ast the ast of the file that is being replaced
 */
public void replaceScript(JsAst ast) {
 CompilerInput input = this.getInput(ast.getInputId());
 if (!replaceIncrementalSourceAst(ast)) {
  return;
 }
 Node originalRoot = checkNotNull(input.getAstRoot(this));
 processNewScript(ast, originalRoot);
}

代码示例来源:origin: org.scala-js/closure-compiler-java-6

/**
 * Replaces one file in a hot-swap mode. The given JsAst should be made
 * from a new version of a file that already was present in the last compile
 * call. If the file is new, this will silently ignored.
 *
 * @param ast the ast of the file that is being replaced
 */
public void replaceScript(JsAst ast) {
 CompilerInput input = this.getInput(ast.getInputId());
 if (!replaceIncrementalSourceAst(ast)) {
  return;
 }
 Node originalRoot = input.getAstRoot(this);
 processNewScript(ast, originalRoot);
}

相关文章

Compiler类方法