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


Java JSDocInfo.isDefine方法代码示例

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


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

示例1: declare

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/**
 * Declares a variable.
 *
 * @param name name of the variable
 * @param nameNode the NAME node declaring the variable
 * @param type the variable's type
 * @param input the input in which this variable is defined.
 * @param inferred Whether this variable's type is inferred (as opposed
 *     to declared).
 */
Var declare(String name, Node nameNode,
    JSType type, CompilerInput input, boolean inferred) {
  Preconditions.checkState(name != null && name.length() > 0);

  // Make sure that it's declared only once
  Preconditions.checkState(vars.get(name) == null);

  Var var = new Var(inferred);
  var.name = name;
  var.nameNode = nameNode;
  var.type = type;
  var.scope = this;
  var.index = vars.size();
  var.input = input;

  // native variables do not have a name node.
  // TODO(user): make Var abstract and have NativeVar, NormalVar.
  JSDocInfo info = NodeUtil.getInfoForNameNode(nameNode);

  var.isDefine = info != null && info.isDefine();
  var.info = info;

  vars.put(name, var);
  return var;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:36,代码来源:Scope.java

示例2: collectDefines

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/**
 * Finds all defines, and creates a {@link DefineInfo} data structure for
 * each one.
 * @return A map of {@link DefineInfo} structures, keyed by name.
 */
private Map<String, DefineInfo> collectDefines(Node root,
    GlobalNamespace namespace) {
  // Find all the global names with a @define annotation
  List<Name> allDefines = Lists.newArrayList();
  for (Name name : namespace.getNameIndex().values()) {
    if (name.docInfo != null && name.docInfo.isDefine()) {
      allDefines.add(name);
    } else if (name.refs != null) {
      for (Ref ref : name.refs) {
        Node n = ref.node;
        Node parent = ref.node.getParent();
        JSDocInfo info = n.getJSDocInfo();
        if (info == null &&
            parent.getType() == Token.VAR && parent.hasOneChild()) {
          info = parent.getJSDocInfo();
        }

        if (info != null && info.isDefine()) {
          allDefines.add(name);
          break;
        }
      }
    }
  }

  CollectDefines pass = new CollectDefines(compiler, allDefines);
  NodeTraversal.traverse(compiler, root, pass);
  return pass.getAllDefines();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:35,代码来源:ProcessDefines.java


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