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


Java Name.getFullName方法代码示例

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


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

示例1: flattenReferencesTo

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Flattens all references to a collapsible property of a global name except
 * its initial definition.
 *
 * @param n A global property name (e.g. "a.b" or "a.b.c.d")
 * @param alias The flattened name (e.g. "a$b" or "a$b$c$d")
 */
private void flattenReferencesTo(Name n, String alias) {
  String originalName = n.getFullName();
  for (Ref r : n.getRefs()) {
    if (r == n.getDeclaration()) {
      // Declarations are handled separately.
      continue;
    }

    Node rParent = r.node.getParent();

    // There are two cases when we shouldn't flatten a reference:
    // 1) Object literal keys, because duplicate keys show up as refs.
    // 2) References inside a complex assign. (a = x.y = 0). These are
    //    called TWIN references, because they show up twice in the
    //    reference list. Only collapse the set, not the alias.
    if (!NodeUtil.isObjectLitKey(r.node, rParent) &&
        (r.getTwin() == null || r.isSet())) {
      flattenNameRef(alias, r.node, rParent, originalName);
    }
  }

  // Flatten all occurrences of a name as a prefix of its subnames. For
  // example, if {@code n} corresponds to the name "a.b", then "a.b" will be
  // replaced with "a$b" in all occurrences of "a.b.c", "a.b.c.d", etc.
  if (n.props != null) {
    for (Name p : n.props) {
      flattenPrefixes(alias, p, 1);
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:38,代码来源:CollapseProperties.java

示例2: flattenPrefixes

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Flattens all occurrences of a name as a prefix of subnames beginning
 * with a particular subname.
 *
 * @param n A global property name (e.g. "a.b.c.d")
 * @param alias A flattened prefix name (e.g. "a$b")
 * @param depth The difference in depth between the property name and
 *    the prefix name (e.g. 2)
 */
private void flattenPrefixes(String alias, Name n, int depth) {
  // Only flatten the prefix of a name declaration if the name being
  // initialized is fully qualified (i.e. not an object literal key).
  String originalName = n.getFullName();
  Ref decl = n.getDeclaration();
  if (decl != null && decl.node != null &&
      decl.node.isGetProp()) {
    flattenNameRefAtDepth(alias, decl.node, depth, originalName);
  }

  for (Ref r : n.getRefs()) {
    if (r == decl) {
      // Declarations are handled separately.
      continue;
    }

    // References inside a complex assign (a = x.y = 0)
    // have twins. We should only flatten one of the twins.
    if (r.getTwin() == null || r.isSet()) {
      flattenNameRefAtDepth(alias, r.node, depth, originalName);
    }
  }

  if (n.props != null) {
    for (Name p : n.props) {
      flattenPrefixes(alias, p, depth + 1);
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:39,代码来源:CollapseProperties.java

示例3: flattenReferencesTo

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Flattens all references to a collapsible property of a global name except
 * its initial definition.
 *
 * @param n A global property name (e.g. "a.b" or "a.b.c.d")
 * @param alias The flattened name (e.g. "a$b" or "a$b$c$d")
 */
private void flattenReferencesTo(Name n, String alias) {
  String originalName = n.getFullName();
  for (Ref r : n.getRefs()) {
    if (r == n.getDeclaration()) {
      // Declarations are handled separately.
      continue;
    }
    Node rParent = r.node.getParent();
    // There are two cases when we shouldn't flatten a reference:
    // 1) Object literal keys, because duplicate keys show up as refs.
    // 2) References inside a complex assign. (a = x.y = 0). These are
    //    called TWIN references, because they show up twice in the
    //    reference list. Only collapse the set, not the alias.
    if (!NodeUtil.isObjectLitKey(r.node) && (r.getTwin() == null || r.isSet())) {
      flattenNameRef(alias, r.node, rParent, originalName);
    }
  }

  // Flatten all occurrences of a name as a prefix of its subnames. For
  // example, if {@code n} corresponds to the name "a.b", then "a.b" will be
  // replaced with "a$b" in all occurrences of "a.b.c", "a.b.c.d", etc.
  if (n.props != null) {
    for (Name p : n.props) {
      flattenPrefixes(alias, p, 1);
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:35,代码来源:CollapseProperties.java

示例4: flattenPrefixes

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Flattens all occurrences of a name as a prefix of subnames beginning
 * with a particular subname.
 *
 * @param n A global property name (e.g. "a.b.c.d")
 * @param alias A flattened prefix name (e.g. "a$b")
 * @param depth The difference in depth between the property name and
 *    the prefix name (e.g. 2)
 */
private void flattenPrefixes(String alias, Name n, int depth) {
  // Only flatten the prefix of a name declaration if the name being
  // initialized is fully qualified (i.e. not an object literal key).
  String originalName = n.getFullName();
  Ref decl = n.getDeclaration();
  if (decl != null && decl.node != null && decl.node.isGetProp()) {
    flattenNameRefAtDepth(alias, decl.node, depth, originalName);
  }

  for (Ref r : n.getRefs()) {
    if (r == decl) {
      // Declarations are handled separately.
      continue;
    }

    // References inside a complex assign (a = x.y = 0)
    // have twins. We should only flatten one of the twins.
    if (r.getTwin() == null || r.isSet()) {
      flattenNameRefAtDepth(alias, r.node, depth, originalName);
    }
  }

  if (n.props != null) {
    for (Name p : n.props) {
      flattenPrefixes(alias, p, depth + 1);
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:38,代码来源:CollapseProperties.java

示例5: flattenReferencesTo

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Flattens all references to a collapsible property of a global name except
 * its initial definition.
 *
 * @param n A global property name (e.g. "a.b" or "a.b.c.d")
 * @param alias The flattened name (e.g. "a$b" or "a$b$c$d")
 */
private void flattenReferencesTo(Name n, String alias) {
  String originalName = n.getFullName();
  for (Ref r : n.getRefs()) {
    if (r == n.getDeclaration()) {
      // Declarations are handled separately.
      continue;
    }

    Node rParent = r.node.getParent();

    // There are two cases when we shouldn't flatten a reference:
    // 1) Object literal keys, because duplicate keys show up as refs.
    // 2) References inside a complex assign. (a = x.y = 0). These are
    //    called TWIN references, because they show up twice in the
    //    reference list. Only collapse the set, not the alias.
    if (!NodeUtil.isObjectLitKey(r.node) &&
        (r.getTwin() == null || r.isSet())) {
      flattenNameRef(alias, r.node, rParent, originalName);
    }
  }

  // Flatten all occurrences of a name as a prefix of its subnames. For
  // example, if {@code n} corresponds to the name "a.b", then "a.b" will be
  // replaced with "a$b" in all occurrences of "a.b.c", "a.b.c.d", etc.
  if (n.props != null) {
    for (Name p : n.props) {
      flattenPrefixes(alias, p, 1);
    }
  }
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:38,代码来源:CollapseProperties.java

示例6: validateName

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的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

示例7: rewriteAllSubclassInheritedAccesses

import com.google.javascript.jscomp.GlobalNamespace.Name; //导入方法依赖的package包/类
/**
 * Inline all references to inherited static superclass properties from the subclass or any
 * descendant of the given subclass. Avoids inlining references to inherited methods when
 * possible, since they may use this or super().
 *
 * @param superclassNameObj The Name of the superclass
 * @param subclassNameObj The Name of the subclass
 * @param prop The property on the superclass to rewrite, if any descendant accesses it.
 * @param namespace The GlobalNamespace containing superclassNameObj
 */
private boolean rewriteAllSubclassInheritedAccesses(
    Name superclassNameObj, Name subclassNameObj, Name prop, GlobalNamespace namespace) {
  Ref propDeclRef = prop.getDeclaration();
  if (propDeclRef == null
      || propDeclRef.node == null
      || !propDeclRef.node.getParent().isAssign()) {
    return false;
  }
  Node propRhs = propDeclRef.node.getParent().getLastChild();
  if (propRhs.isFunction()) {
    return false;
  }

  String subclassQualifiedPropName = subclassNameObj.getFullName() + "." + prop.getBaseName();
  Name subclassPropNameObj = namespace.getOwnSlot(subclassQualifiedPropName);
  // Don't rewrite if the subclass ever shadows the parent static property.
  // This may also back off on cases where the subclass first accesses the parent property, then
  // shadows it.
  if (subclassPropNameObj != null
      && (subclassPropNameObj.localSets > 0 || subclassPropNameObj.globalSets > 0)) {
    return false;
  }

  // Recurse to find potential sub-subclass accesses of the superclass property.
  if (subclassNameObj.subclasses != null) {
    for (Name name : subclassNameObj.subclasses) {
      rewriteAllSubclassInheritedAccesses(superclassNameObj, name, prop, namespace);
    }
  }

  if (subclassPropNameObj != null) {
    Set<AstChange> newNodes = new LinkedHashSet<>();

    // Use this node as a template for rewriteAliasProp.
    Node superclassNameNode = superclassNameObj.getDeclaration().node;
    if (superclassNameNode.isName()) {
      superclassNameNode = superclassNameNode.cloneNode();
    } else if (superclassNameNode.isGetProp()) {
      superclassNameNode = superclassNameNode.cloneTree();
    } else {
      return false;
    }

    rewriteAliasProp(superclassNameNode, 0, newNodes, subclassPropNameObj);
    namespace.scanNewNodes(newNodes);
  }
  return true;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:59,代码来源:AggressiveInlineAliases.java

示例8: validateName

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