当前位置: 首页>>代码示例>>Java>>正文


Java Name.needsToBeStubbed方法代码示例

本文整理汇总了Java中com.google.javascript.jscomp.GlobalNamespace.Name.needsToBeStubbed方法的典型用法代码示例。如果您正苦于以下问题:Java Name.needsToBeStubbed方法的具体用法?Java Name.needsToBeStubbed怎么用?Java Name.needsToBeStubbed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.jscomp.GlobalNamespace.Name的用法示例。


在下文中一共展示了Name.needsToBeStubbed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addStubsForUndeclaredProperties

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Adds global variable "stubs" for any properties of a global name that are only set in a local
 * scope or read but never set.
 *
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we are adding stubs for (e.g.
 *     "a$b$c")
 * @param parent The node to which new global variables should be added as children
 * @param addAfter The child of after which new variables should be added
 */
private void addStubsForUndeclaredProperties(Name n, String alias, Node parent, Node addAfter) {
  checkState(n.canCollapseUnannotatedChildNames(), n);
  checkArgument(NodeUtil.isStatementBlock(parent), parent);
  checkNotNull(addAfter);
  if (n.props == null) {
    return;
  }
  for (Name p : n.props) {
    if (p.needsToBeStubbed()) {
      String propAlias = appendPropForAlias(alias, p.getBaseName());
      Node nameNode = IR.name(propAlias);
      Node newVar = IR.var(nameNode).useSourceInfoIfMissingFromForTree(addAfter);
      parent.addChildAfter(newVar, addAfter);
      addAfter = newVar;
      compiler.reportChangeToEnclosingScope(newVar);
      // Determine if this is a constant var by checking the first
      // reference to it. Don't check the declaration, as it might be null.
      if (p.getRefs().get(0).node.getLastChild().getBooleanProp(
          Node.IS_CONSTANT_NAME)) {
        nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
        compiler.reportChangeToEnclosingScope(nameNode);
      }
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:36,代码来源:CollapseProperties.java

示例2: addStubsForUndeclaredProperties

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Adds global variable "stubs" for any properties of a global name that are
 * only set in a local scope or read but never set.
 *
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we are
 *     adding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be added
 *     as children
 * @param addAfter The child of after which new
 *     variables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(
    Name n, String alias, Node parent, Node addAfter) {
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  int numStubs = 0;
  if (n.props != null) {
    for (Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias = appendPropForAlias(alias, p.name);
        Node nameNode = Node.newString(Token.NAME, propAlias);
        Node newVar = new Node(Token.VAR, nameNode);
        if (addAfter == null) {
          parent.addChildToFront(newVar);
        } else {
          parent.addChildAfter(newVar, addAfter);
          addAfter = newVar;
        }
        numStubs++;
        compiler.reportCodeChange();

        // Determine if this is a constant var by checking the first
        // reference to it. Don't check the declaration, as it might be null.
        if (p.refs.get(0).node.getLastChild().getBooleanProp(
              Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
        }
      }
    }
  }
  return numStubs;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:44,代码来源:CollapseProperties.java

示例3: addStubsForUndeclaredProperties

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Adds global variable "stubs" for any properties of a global name that are
 * only set in a local scope or read but never set.
 *
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we are
 *     adding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be added
 *     as children
 * @param addAfter The child of after which new
 *     variables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(
    Name n, String alias, Node parent, Node addAfter) {
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  Preconditions.checkNotNull(addAfter);
  int numStubs = 0;
  if (n.props != null) {
    for (Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias = appendPropForAlias(alias, p.name);
        Node nameNode = Node.newString(Token.NAME, propAlias);
        Node newVar = new Node(Token.VAR, nameNode)
            .copyInformationFromForTree(addAfter);
        parent.addChildAfter(newVar, addAfter);
        addAfter = newVar;
        numStubs++;
        compiler.reportCodeChange();

        // Determine if this is a constant var by checking the first
        // reference to it. Don't check the declaration, as it might be null.
        if (p.refs.get(0).node.getLastChild().getBooleanProp(
              Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
        }
      }
    }
  }
  return numStubs;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:42,代码来源:CollapseProperties.java

示例4: addStubsForUndeclaredProperties

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Adds global variable "stubs" for any properties of a global name that are
 * only set in a local scope or read but never set.
 *
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we are
 *     adding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be added
 *     as children
 * @param addAfter The child of after which new
 *     variables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(
    Name n, String alias, Node parent, Node addAfter) {
  Preconditions.checkState(n.canCollapseUnannotatedChildNames());
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  Preconditions.checkNotNull(addAfter);
  int numStubs = 0;
  if (n.props != null) {
    for (Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias = appendPropForAlias(alias, p.getBaseName());
        Node nameNode = IR.name(propAlias);
        Node newVar = IR.var(nameNode)
            .copyInformationFromForTree(addAfter);
        parent.addChildAfter(newVar, addAfter);
        addAfter = newVar;
        numStubs++;
        compiler.reportCodeChange();

        // Determine if this is a constant var by checking the first
        // reference to it. Don't check the declaration, as it might be null.
        if (p.getRefs().get(0).node.getLastChild().getBooleanProp(
                Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
        }
      }
    }
  }
  return numStubs;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:43,代码来源:CollapseProperties.java


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