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


Java Ref.getModule方法代码示例

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


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

示例1: validateName

import com.google.javascript.jscomp.GlobalNamespace.Ref; //导入方法依赖的package包/类
private void validateName(Name name, boolean isDefined) {
  // If the name is not defined, emit warnings for each reference. While
  // we're looking through each reference, check all the module dependencies.
  Ref declaration = name.getDeclaration();
  Name parent = name.parent;

  JSModuleGraph moduleGraph = compiler.getModuleGraph();
  for (Ref ref : name.getRefs()) {
    // Don't worry about global exprs.
    boolean isGlobalExpr = ref.getNode().getParent().isExprResult();

    if (!isDefined && !isTypedef(ref)) {
      if (!isGlobalExpr) {
        reportRefToUndefinedName(name, ref);
      }
    } else if (declaration != null &&
        ref.getModule() != declaration.getModule() &&
        !moduleGraph.dependsOn(
            ref.getModule(), declaration.getModule())) {
      reportBadModuleReference(name, ref);
    } else {
      // Check for late references.
      if (ref.scope.isGlobal()) {
        // Prototype references are special, because in our reference graph,
        // A.prototype counts as a reference to A.
        boolean isPrototypeGet = (ref.type == Ref.Type.PROTOTYPE_GET);
        Name owner = isPrototypeGet ? name : parent;
        boolean singleGlobalParentDecl =
            owner != null &&
            owner.getDeclaration() != null &&
            owner.localSets == 0;

        if (singleGlobalParentDecl &&
            owner.getDeclaration().preOrderIndex > ref.preOrderIndex) {
          String refName = isPrototypeGet
              ? name.getFullName() + ".prototype"
              : name.getFullName();
          compiler.report(
              JSError.make(ref.source.getName(), ref.node,
                  NAME_DEFINED_LATE_WARNING,
                  refName,
                  owner.getFullName(),
                  owner.getDeclaration().source.getName(),
                  String.valueOf(owner.getDeclaration().node.getLineno())));
        }
      }
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:50,代码来源:CheckGlobalNames.java

示例2: validateName

import com.google.javascript.jscomp.GlobalNamespace.Ref; //导入方法依赖的package包/类
private void validateName(Name name, boolean isDefined) {
  // If the name is not defined, emit warnings for each reference. While
  // we're looking through each reference, check all the module dependencies.
  Ref declaration = name.getDeclaration();
  Name parent = name.parent;

  JSModuleGraph moduleGraph = compiler.getModuleGraph();
  for (Ref ref : name.getRefs()) {
    // Don't worry about global exprs.
    boolean isGlobalExpr = ref.getNode().getParent().isExprResult();

    if (!isDefined && !isTypedef(ref)) {
      if (!isGlobalExpr) {
        reportRefToUndefinedName(name, ref);
      }
    } else if (declaration != null &&
        ref.getModule() != declaration.getModule() &&
        !moduleGraph.dependsOn(
            ref.getModule(), declaration.getModule())) {
      reportBadModuleReference(name, ref);
    } else {
      // Check for late references.
      if (ref.scope.getClosestHoistScope().isGlobal()) {
        // Prototype references are special, because in our reference graph,
        // A.prototype counts as a reference to A.
        boolean isPrototypeGet = (ref.type == Ref.Type.PROTOTYPE_GET);
        Name owner = isPrototypeGet ? name : parent;
        boolean singleGlobalParentDecl =
            owner != null &&
            owner.getDeclaration() != null &&
            owner.localSets == 0;

        if (singleGlobalParentDecl &&
            owner.getDeclaration().preOrderIndex > ref.preOrderIndex) {
          String refName = isPrototypeGet
              ? name.getFullName() + ".prototype"
              : name.getFullName();
          compiler.report(
              JSError.make(ref.node,
                  NAME_DEFINED_LATE_WARNING,
                  refName,
                  owner.getFullName(),
                  owner.getDeclaration().getSourceFile().getName(),
                  String.valueOf(owner.getDeclaration().node.getLineno())));
        }
      }
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:50,代码来源:CheckGlobalNames.java


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