• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InputId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.javascript.rhino.InputId的典型用法代码示例。如果您正苦于以下问题:Java InputId类的具体用法?Java InputId怎么用?Java InputId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InputId类属于com.google.javascript.rhino包,在下文中一共展示了InputId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateGlobalVarReferences

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
/**
 * Updates the internal reference map based on the provided parameters. If
 * {@code scriptRoot} is not SCRIPT, it basically replaces the internal map
 * with the new one, otherwise it replaces all the information associated to
 * the given script.
 *
 * @param refMapPatch The reference map result of a
 *     {@link ReferenceCollectingCallback} pass which might be collected from
 *     the whole AST or just a sub-tree associated to a SCRIPT node.
 * @param root AST sub-tree root on which reference collection was done.
 */
void updateGlobalVarReferences(Map<Var, ReferenceCollection>
    refMapPatch, Node root) {
  if (refMap == null || !root.isScript()) {
    resetGlobalVarReferences(refMapPatch);
    return;
  }

  InputId inputId = root.getInputId();
  Preconditions.checkNotNull(inputId);
  // Note there are two assumptions here (i) the order of compiler inputs
  // has not changed and (ii) all references are in the order they appear
  // in AST (this is enforced in ReferenceCollectionCallback).
  removeScriptReferences(inputId);
  for (Entry<Var, ReferenceCollection> entry : refMapPatch.entrySet()) {
    Var var = entry.getKey();
    if (var.isGlobal()) {
      replaceReferences(var.getName(), inputId, entry.getValue());
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:GlobalVarReferenceMap.java


示例2: removeScriptReferences

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private void removeScriptReferences(InputId inputId) {
  Preconditions.checkNotNull(inputId);

  if (!inputOrder.containsKey(inputId)) {
    return; // Input did not exist when last computed, so skip
  }
  // TODO(bashir): If this is too slow it is not too difficult to make it
  // faster with keeping an index for variables accessed in sourceName.
  for (ReferenceCollection collection : refMap.values()) {
    if (collection == null) {
      continue;
    }
    List<Reference> oldRefs = collection.references;
    SourceRefRange range = findSourceRefRange(oldRefs, inputId);
    List<Reference> newRefs = Lists.newArrayList(range.refsBefore());
    newRefs.addAll(range.refsAfter());
    collection.references = newRefs;
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:GlobalVarReferenceMap.java


示例3: replaceReferences

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private void replaceReferences(String varName, InputId inputId,
    ReferenceCollection newSourceCollection) {
  ReferenceCollection combined = new ReferenceCollection();
  List<Reference> combinedRefs = combined.references;
  ReferenceCollection oldCollection = refMap.get(varName);
  refMap.put(varName, combined);
  if (oldCollection == null) {
    combinedRefs.addAll(newSourceCollection.references);
    return;
  }
  // otherwise replace previous references that are from sourceName
  SourceRefRange range = findSourceRefRange(oldCollection.references,
    inputId);
  combinedRefs.addAll(range.refsBefore());
  combinedRefs.addAll(newSourceCollection.references);
  combinedRefs.addAll(range.refsAfter());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:GlobalVarReferenceMap.java


示例4: findSourceRefRange

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
/**
 * Finds the range of references associated to {@code sourceName}. Note that
 * even if there is no sourceName references the returned information can be
 * used to decide where to insert new sourceName refs.
 */
private SourceRefRange findSourceRefRange(List<Reference> refList,
    InputId inputId) {
  Preconditions.checkNotNull(inputId);

  // TODO(bashir): We can do binary search here, but since this is fast enough
  // right now, we just do a linear search for simplicity.
  int lastBefore = -1;
  int firstAfter = refList.size();
  int index = 0;

  Preconditions.checkState(inputOrder.containsKey(inputId), inputId.getIdName());
  int sourceInputOrder = inputOrder.get(inputId);
  for (Reference ref : refList) {
    Preconditions.checkNotNull(ref.getInputId());
    int order = inputOrder.get(ref.getInputId());
    if (order < sourceInputOrder) {
      lastBefore = index;
    } else if (order > sourceInputOrder) {
      firstAfter = index;
      break;
    }
    index++;
  }
  return new SourceRefRange(refList, lastBefore, firstAfter);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:GlobalVarReferenceMap.java


示例5: computeLiveness

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private static LiveVariablesAnalysis computeLiveness(String src) {
  Compiler compiler = new Compiler();
  CompilerOptions options = new CompilerOptions();
  options.setCodingConvention(new GoogleCodingConvention());
  compiler.initOptions(options);
  src = "function _FUNCTION(param1, param2){" + src + "}";
  Node n = compiler.parseTestCode(src).removeFirstChild();
  Node script = new Node(Token.SCRIPT, n);
  script.setInputId(new InputId("test"));
  assertEquals(0, compiler.getErrorCount());
  Scope scope = new SyntacticScopeCreator(compiler).createScope(
      n, Scope.createGlobalScope(script));
  ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false, true);
  cfa.process(null, n);
  ControlFlowGraph<Node> cfg = cfa.getCfg();
  LiveVariablesAnalysis analysis =
      new LiveVariablesAnalysis(cfg, scope, compiler);
  analysis.analyze();
  return analysis;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:LiveVariableAnalysisTest.java


示例6: parseAndTypeCheckWithScope

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private TypeCheckResult parseAndTypeCheckWithScope(
    String externs, String js) {
  compiler.init(
      Lists.newArrayList(SourceFile.fromCode("[externs]", externs)),
      Lists.newArrayList(SourceFile.fromCode("[testcode]", js)),
      compiler.getOptions());

  Node n = compiler.getInput(new InputId("[testcode]")).getAstRoot(compiler);
  Node externsNode = compiler.getInput(new InputId("[externs]"))
      .getAstRoot(compiler);
  Node externAndJsRoot = new Node(Token.BLOCK, externsNode, n);
  externAndJsRoot.setIsSyntheticBlock(true);

  assertEquals("parsing error: " +
      Joiner.on(", ").join(compiler.getErrors()),
      0, compiler.getErrorCount());

  Scope s = makeTypeCheck().processForTesting(externsNode, n);
  return new TypeCheckResult(n, s);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:LooseTypeCheckTest.java


示例7: parse

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
Node parse(String js, boolean checkTypes) {
  Compiler compiler = new Compiler();
  CompilerOptions options = new CompilerOptions();
  options.setTrustedStrings(trustedStrings);

  // Allow getters and setters.
  options.setLanguageIn(LanguageMode.ECMASCRIPT5);
  compiler.initOptions(options);
  Node n = compiler.parseTestCode(js);

  if (checkTypes) {
    DefaultPassConfig passConfig = new DefaultPassConfig(null);
    CompilerPass typeResolver = passConfig.resolveTypes.create(compiler);
    Node externs = new Node(Token.SCRIPT);
    externs.setInputId(new InputId("externs"));
    Node externAndJsRoot = new Node(Token.BLOCK, externs, n);
    externAndJsRoot.setIsSyntheticBlock(true);
    typeResolver.process(externs, n);
    CompilerPass inferTypes = passConfig.inferTypes.create(compiler);
    inferTypes.process(externs, n);
  }

  checkUnexpectedErrorsOrWarnings(compiler, 0);
  return n;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:CodePrinterTest.java


示例8: getSourceFileByName

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
@Override
SourceFile getSourceFileByName(String sourceName) {
  // Here we assume that the source name is the input name, this
  // is true of JavaScript parsed from source.
  if (sourceName != null) {
    CompilerInput input = inputsById.get(new InputId(sourceName));
    if (input != null) {
      return input.getSourceFile();
    }
    // Alternatively, the sourceName might have been reverse-mapped by
    // an input source-map, so let's look in our sourcemap original sources.
    return sourceMapOriginalSources.get(sourceName);
  }

  return null;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:Compiler.java


示例9: updateGlobalVarReferences

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
/**
 * Updates the internal reference map based on the provided parameters. If
 * {@code scriptRoot} is not SCRIPT, it basically replaces the internal map
 * with the new one, otherwise it replaces all the information associated to
 * the given script.
 *
 * @param refMapPatch The reference map result of a
 *     {@link ReferenceCollectingCallback} pass which might be collected from
 *     the whole AST or just a sub-tree associated to a SCRIPT node.
 * @param root AST sub-tree root on which reference collection was done.
 */
void updateGlobalVarReferences(Map<Var, ReferenceCollection>
    refMapPatch, Node root) {
  if (refMap == null || !root.isScript()) {
    resetGlobalVarReferences(refMapPatch);
    return;
  }

  InputId inputId = root.getInputId();
  checkNotNull(inputId);
  // Note there are two assumptions here (i) the order of compiler inputs
  // has not changed and (ii) all references are in the order they appear
  // in AST (this is enforced in ReferenceCollectionCallback).
  removeScriptReferences(inputId);
  for (Entry<Var, ReferenceCollection> entry : refMapPatch.entrySet()) {
    Var var = entry.getKey();
    if (var.isGlobal()) {
      replaceReferences(var.getName(), inputId, entry.getValue());
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:32,代码来源:GlobalVarReferenceMap.java


示例10: removeScriptReferences

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private void removeScriptReferences(InputId inputId) {
  checkNotNull(inputId);

  if (!inputOrder.containsKey(inputId)) {
    return; // Input did not exist when last computed, so skip
  }
  // TODO(bashir): If this is too slow it is not too difficult to make it
  // faster with keeping an index for variables accessed in sourceName.
  for (ReferenceCollection collection : refMap.values()) {
    if (collection == null) {
      continue;
    }
    List<Reference> oldRefs = collection.references;
    SourceRefRange range = findSourceRefRange(oldRefs, inputId);
    List<Reference> newRefs = new ArrayList<>(range.refsBefore());
    newRefs.addAll(range.refsAfter());
    collection.references = newRefs;
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:20,代码来源:GlobalVarReferenceMap.java


示例11: findSourceRefRange

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
/**
 * Finds the range of references associated to {@code sourceName}. Note that
 * even if there is no sourceName references the returned information can be
 * used to decide where to insert new sourceName refs.
 */
private SourceRefRange findSourceRefRange(List<Reference> refList,
    InputId inputId) {
  checkNotNull(inputId);

  // TODO(bashir): We can do binary search here, but since this is fast enough
  // right now, we just do a linear search for simplicity.
  int lastBefore = -1;
  int firstAfter = refList.size();
  int index = 0;

  checkState(inputOrder.containsKey(inputId), inputId.getIdName());
  int sourceInputOrder = inputOrder.get(inputId);
  for (Reference ref : refList) {
    checkNotNull(ref.getInputId());
    int order = inputOrder.get(ref.getInputId());
    if (order < sourceInputOrder) {
      lastBefore = index;
    } else if (order > sourceInputOrder) {
      firstAfter = index;
      break;
    }
    index++;
  }
  return new SourceRefRange(refList, lastBefore, firstAfter);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:31,代码来源:GlobalVarReferenceMap.java


示例12: testInferWithModules

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
public void testInferWithModules() {
  CompilerOptions options = getOptions();
  Compiler compiler = new Compiler();
  List<SourceFile> inputs = ImmutableList.of(
      SourceFile.fromCode("in", ""));

  Result result = compiler.compile(EXTVAR_EXTERNS, inputs, options);
  assertTrue(result.success);

  CompilerInput oldInput = compiler.getInput(new InputId("in"));
  JSModule myModule = oldInput.getModule();
  assertThat(myModule.getInputs()).hasSize(1);

  SourceFile newSource = SourceFile.fromCode("in", "var x;");
  JsAst ast = new JsAst(newSource);
  compiler.replaceScript(ast);

  assertThat(myModule.getInputs()).hasSize(1);
  assertThat(myModule.getInputs()).doesNotContain(oldInput);
  assertThat(myModule.getInputs()).containsExactly(compiler.getInput(new InputId("in")));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:22,代码来源:SimpleReplaceScriptTest.java


示例13: generate

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
@Override
public Node generate(int budget, Set<Type> types) {
  int numElements = generateLength(budget - 1);
  Node script;
  if (numElements > 0) {
    SourceElementFuzzer[] fuzzers = new SourceElementFuzzer[numElements];
    Arrays.fill(
        fuzzers,
        new SourceElementFuzzer(context));
    Node[] elements = distribute(budget - 1, fuzzers);
    script = new Node(Token.SCRIPT, elements);
  } else {
    script = new Node(Token.SCRIPT);
  }

  InputId inputId = new InputId("fuzzedInput");
  script.setInputId(inputId);
  script.setSourceFileForTesting(inputId.getIdName());
  return script;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:21,代码来源:ScriptFuzzer.java


示例14: parseAndTypeCheck

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private NewTypeInference parseAndTypeCheck(String externs, String js) {
  setUp();
  compiler.init(
      Lists.newArrayList(SourceFile.fromCode("[externs]", externs)),
      Lists.newArrayList(SourceFile.fromCode("[testcode]", js)),
      compiler.getOptions());

  Node externsRoot =
      compiler.getInput(new InputId("[externs]")).getAstRoot(compiler);
  Node astRoot =
      compiler.getInput(new InputId("[testcode]")).getAstRoot(compiler);

  assertEquals("parsing error: " +
      Joiner.on(", ").join(compiler.getErrors()),
      0, compiler.getErrorCount());
  assertEquals("parsing warning: " +
      Joiner.on(", ").join(compiler.getWarnings()),
      0, compiler.getWarningCount());

  GlobalTypeInfo symbolTable = new GlobalTypeInfo(compiler);
  symbolTable.process(externsRoot, astRoot);
  compiler.setSymbolTable(symbolTable);
  NewTypeInference typeInf = new NewTypeInference(compiler);
  typeInf.process(externsRoot, astRoot);
  return typeInf;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:27,代码来源:NewTypeInferenceTest.java


示例15: parse

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
Node parse(String js, boolean checkTypes) {
  Compiler compiler = new Compiler();
  lastCompiler = compiler;
  CompilerOptions options = new CompilerOptions();
  options.setTrustedStrings(trustedStrings);

  // Allow getters and setters.
  options.setLanguageIn(languageMode);
  compiler.initOptions(options);
  Node n = compiler.parseTestCode(js);

  if (checkTypes) {
    DefaultPassConfig passConfig = new DefaultPassConfig(null);
    CompilerPass typeResolver = passConfig.resolveTypes.create(compiler);
    Node externs = new Node(Token.SCRIPT);
    externs.setInputId(new InputId("externs"));
    Node externAndJsRoot = new Node(Token.BLOCK, externs, n);
    externAndJsRoot.setIsSyntheticBlock(true);
    typeResolver.process(externs, n);
    CompilerPass inferTypes = passConfig.inferTypes.create(compiler);
    inferTypes.process(externs, n);
  }

  checkUnexpectedErrorsOrWarnings(compiler, 0);
  return n;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:27,代码来源:CodePrinterTest.java


示例16: parse

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
Node parse(String js, boolean checkTypes) {
  Compiler compiler = new Compiler();
  lastCompiler = compiler;
  CompilerOptions options = new CompilerOptions();
  options.setTrustedStrings(trustedStrings);

  // Allow getters and setters.
  options.setLanguageIn(LanguageMode.ECMASCRIPT5);
  compiler.initOptions(options);
  Node n = compiler.parseTestCode(js);

  if (checkTypes) {
    DefaultPassConfig passConfig = new DefaultPassConfig(null);
    CompilerPass typeResolver = passConfig.resolveTypes.create(compiler);
    Node externs = new Node(Token.SCRIPT);
    externs.setInputId(new InputId("externs"));
    Node externAndJsRoot = new Node(Token.BLOCK, externs, n);
    externAndJsRoot.setIsSyntheticBlock(true);
    typeResolver.process(externs, n);
    CompilerPass inferTypes = passConfig.inferTypes.create(compiler);
    inferTypes.process(externs, n);
  }

  checkUnexpectedErrorsOrWarnings(compiler, 0);
  return n;
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:27,代码来源:CodePrinterTest.java


示例17: getInputId

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
/**
 * @param n The node.
 * @return The InputId property on the node or its ancestors.
 */
public static InputId getInputId(Node n) {
  while (n != null && !n.isScript()) {
    n = n.getParent();
  }

  return (n != null && n.isScript()) ? n.getInputId() : null;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:NodeUtil.java


示例18: Reference

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
private Reference(Node nameNode,
    BasicBlock basicBlock, Scope scope, InputId inputId) {
  this.nameNode = nameNode;
  this.basicBlock = basicBlock;
  this.scope = scope;
  this.inputId = inputId;
  this.sourceFile = nameNode.getStaticSourceFile();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:ReferenceCollectingCallback.java


示例19: CompilerInput

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
public CompilerInput(SourceAst ast, InputId inputId, boolean isExtern) {
  this.ast = ast;
  this.id = inputId;

  // TODO(nicksantos): Add a precondition check here. People are passing
  // in null, but they should not be.
  if (ast != null && ast.getSourceFile() != null) {
    ast.getSourceFile().setIsExtern(isExtern);
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:CompilerInput.java


示例20: removeExternInput

import com.google.javascript.rhino.InputId; //导入依赖的package包/类
/**
 * Removes an input file from AST.
 * @param id The id of the input to be removed.
 */
protected void removeExternInput(InputId id) {
  CompilerInput input = getInput(id);
  if (input == null) {
    return;
  }
  Preconditions.checkState(input.isExtern(), "Not an extern input: %s", input.getName());
  inputsById.remove(id);
  externs.remove(input);
  Node root = input.getAstRoot(this);
  if (root != null) {
    root.detachFromParent();
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:Compiler.java



注:本文中的com.google.javascript.rhino.InputId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MethodCallExpr类代码示例发布时间:2022-05-22
下一篇:
Java GlobFilenameFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap