本文整理了Java中com.google.javascript.jscomp.Compiler.putCompilerInput()
方法的一些代码示例,展示了Compiler.putCompilerInput()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Compiler.putCompilerInput()
方法的具体详情如下:
包路径:com.google.javascript.jscomp.Compiler
类名称:Compiler
方法名:putCompilerInput
暂无
代码示例来源:origin: com.google.javascript/closure-compiler
private Node parseCodeHelper(SourceFile src) {
CompilerInput input = new CompilerInput(src);
putCompilerInput(input.getInputId(), input);
return checkNotNull(input.getAstRoot(this));
}
代码示例来源:origin: com.google.javascript/closure-compiler
CompilerInput newExternInput(String name, SyntheticExternsPosition pos) {
SourceAst ast = new SyntheticAst(name);
if (inputsById.containsKey(ast.getInputId())) {
throw new IllegalArgumentException("Conflicting externs name: " + name);
}
CompilerInput input = new CompilerInput(ast, true);
putCompilerInput(input.getInputId(), input);
if (pos == SyntheticExternsPosition.START) {
externsRoot.addChildToFront(checkNotNull(ast.getAstRoot(this)));
externs.add(0, input);
} else {
externsRoot.addChildToBack(checkNotNull(ast.getAstRoot(this)));
externs.add(input);
}
return input;
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
@Override
Node parseTestCode(String js) {
initCompilerOptionsIfTesting();
CompilerInput input = new CompilerInput(
SourceFile.fromCode("[testcode]", js));
if (inputsById == null) {
inputsById = new HashMap<InputId, CompilerInput>();
}
putCompilerInput(input.getInputId(), input);
return input.getAstRoot(this);
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
CompilerInput newExternInput(String name, SyntheticExternsPosition pos) {
SourceAst ast = new SyntheticAst(name);
if (inputsById.containsKey(ast.getInputId())) {
throw new IllegalArgumentException("Conflicting externs name: " + name);
}
CompilerInput input = new CompilerInput(ast, true);
putCompilerInput(input.getInputId(), input);
if (pos == SyntheticExternsPosition.START) {
externsRoot.addChildToFront(ast.getAstRoot(this));
externs.add(0, input);
} else {
externsRoot.addChildToBack(ast.getAstRoot(this));
externs.add(input);
}
return input;
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
@Override
Node parseSyntheticCode(String js) {
CompilerInput input = new CompilerInput(
SourceFile.fromCode(" [synthetic:" + (++syntheticCodeId) + "] ", js));
putCompilerInput(input.getInputId(), input);
return input.getAstRoot(this);
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
/**
* Creates a map to make looking up an input by name fast. Also checks for
* duplicate inputs.
*/
void initInputsByIdMap() {
inputsById = new HashMap<InputId, CompilerInput>();
for (CompilerInput input : externs) {
InputId id = input.getInputId();
CompilerInput previous = putCompilerInput(id, input);
if (previous != null) {
report(JSError.make(DUPLICATE_EXTERN_INPUT, input.getName()));
}
}
for (CompilerInput input : inputs) {
InputId id = input.getInputId();
CompilerInput previous = putCompilerInput(id, input);
if (previous != null) {
report(JSError.make(DUPLICATE_INPUT, input.getName()));
}
}
}
代码示例来源:origin: com.google.javascript/closure-compiler
/**
* Creates a map to make looking up an input by name fast. Also checks for
* duplicate inputs.
*/
void initInputsByIdMap() {
inputsById.clear();
for (CompilerInput input : externs) {
InputId id = input.getInputId();
CompilerInput previous = putCompilerInput(id, input);
if (previous != null) {
report(JSError.make(DUPLICATE_EXTERN_INPUT, input.getName()));
}
}
for (CompilerInput input : moduleGraph.getAllInputs()) {
InputId id = input.getInputId();
CompilerInput previous = putCompilerInput(id, input);
if (previous != null) {
report(JSError.make(DUPLICATE_INPUT, input.getName()));
}
}
}
代码示例来源:origin: com.google.javascript/closure-compiler
/**
* Add a new source input dynamically. Intended for incremental compilation.
* <p>
* If the new source input doesn't parse, it will not be added, and a false
* will be returned.
*
* @param ast the JS Source to add.
* @return true if the source was added successfully, false otherwise.
* @throws IllegalStateException if an input for this ast already exists.
*/
boolean addNewSourceAst(JsAst ast) {
CompilerInput oldInput = getInput(ast.getInputId());
if (oldInput != null) {
throw new IllegalStateException(
"Input already exists: " + ast.getInputId().getIdName());
}
Node newRoot = checkNotNull(ast.getAstRoot(this));
getRoot().getLastChild().addChildToBack(newRoot);
CompilerInput newInput = new CompilerInput(ast);
// TODO(tylerg): handle this for multiple modules at some point.
JSModule firstModule = Iterables.getFirst(getModules(), null);
if (firstModule.getName().equals(JSModule.STRONG_MODULE_NAME)) {
firstModule.add(newInput);
}
putCompilerInput(ast.getInputId(), newInput);
return true;
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
/**
* Add a new source input dynamically. Intended for incremental compilation.
* <p>
* If the new source input doesn't parse, it will not be added, and a false
* will be returned.
*
* @param ast the JS Source to add.
* @return true if the source was added successfully, false otherwise.
* @throws IllegalStateException if an input for this ast already exists.
*/
boolean addNewSourceAst(JsAst ast) {
CompilerInput oldInput = getInput(ast.getInputId());
if (oldInput != null) {
throw new IllegalStateException(
"Input already exists: " + ast.getInputId().getIdName());
}
Node newRoot = ast.getAstRoot(this);
if (newRoot == null) {
return false;
}
getRoot().getLastChild().addChildToBack(newRoot);
CompilerInput newInput = new CompilerInput(ast);
// TODO(tylerg): handle this for multiple modules at some point.
if (moduleGraph == null && !modules.isEmpty()) {
// singleton module
modules.get(0).add(newInput);
}
putCompilerInput(ast.getInputId(), newInput);
return true;
}
代码示例来源:origin: com.google.javascript/closure-compiler
/**
* 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.
*
* @return Whether the new AST was attached successfully.
*/
boolean replaceIncrementalSourceAst(JsAst ast) {
CompilerInput oldInput = getInput(ast.getInputId());
checkNotNull(oldInput, "No input to replace: %s", ast.getInputId().getIdName());
Node newRoot = checkNotNull(ast.getAstRoot(this));
Node oldRoot = oldInput.getAstRoot(this);
oldRoot.replaceWith(newRoot);
CompilerInput newInput = new CompilerInput(ast);
putCompilerInput(ast.getInputId(), newInput);
JSModule module = oldInput.getModule();
if (module != null) {
module.addAfter(newInput, oldInput);
module.remove(oldInput);
}
// Verify the input id is set properly.
checkState(newInput.getInputId().equals(oldInput.getInputId()));
InputId inputIdOnAst = newInput.getAstRoot(this).getInputId();
checkState(newInput.getInputId().equals(inputIdOnAst));
return true;
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
putCompilerInput(ast.getInputId(), newInput);
内容来源于网络,如有侵权,请联系作者删除!