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


Java Ref.isSet方法代码示例

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


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

示例1: flattenReferencesTo

import com.google.javascript.jscomp.GlobalNamespace.Ref; //导入方法依赖的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) {
  if (n.refs != null) {
    String originalName = n.fullName();
    for (Ref r : n.refs) {
      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:andyjko,项目名称:feedlack,代码行数:35,代码来源:CollapseProperties.java

示例2: flattenPrefixes

import com.google.javascript.jscomp.GlobalNamespace.Ref; //导入方法依赖的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.fullName();
  if (n.declaration != null && n.declaration.node != null &&
      n.declaration.node.getType() == Token.GETPROP) {
    flattenNameRefAtDepth(alias, n.declaration.node, depth, originalName);
  }

  if (n.refs != null) {
    for (Ref r : n.refs) {

      // 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:andyjko,项目名称:feedlack,代码行数:36,代码来源:CollapseProperties.java

示例3: flattenReferencesTo

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

示例4: flattenPrefixes

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

示例5: flattenReferencesTo

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

示例6: flattenPrefixes

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

示例7: flattenReferencesTo

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

示例8: isKnownToReturnOnlyUndefined

import com.google.javascript.jscomp.GlobalNamespace.Ref; //导入方法依赖的package包/类
private boolean isKnownToReturnOnlyUndefined(String functionQName) {
  if (globalNamespace == null) {
    return false;
  }
  Name globalName = globalNamespace.getSlot(functionQName);
  if (globalName == null) {
    return false;
  }

  Ref declarationRef = globalName.getDeclaration();
  if (declarationRef == null) {
    for (Ref ref : globalName.getRefs()) {
      if (ref.isSet()) {
        declarationRef = ref;
      }
    }
  }
  if (declarationRef == null) {
    return false;
  }

  Node declaredVarOrProp = declarationRef.getNode();
  if (declaredVarOrProp.isFromExterns()) {
    return false;
  }

  Node declaration = declaredVarOrProp.getParent();
  Node declaredValue = null;
  if (declaration.isFunction()) {
    declaredValue = declaration;
  } else if (NodeUtil.isNameDeclaration(declaration) && declaredVarOrProp.isName()) {
    if (declaredVarOrProp.hasChildren()) {
      declaredValue = checkNotNull(declaredVarOrProp.getFirstChild());
    } else {
      return false; // Declaration without an assigned value.
    }
  } else if (declaration.isAssign() && declaration.getFirstChild() == declaredVarOrProp) {
    declaredValue = checkNotNull(declaration.getSecondChild());
  } else if (declaration.isObjectLit() && declaredVarOrProp.hasOneChild()){
    declaredValue = checkNotNull(declaredVarOrProp.getFirstChild());
  } else {
    throw new IllegalStateException(
        "Unexpected declaration format:\n" + declaration.toStringTree());
  }

  if (declaredValue.isFunction()) {
    Node functionBody = checkNotNull(declaredValue.getChildAtIndex(2));
    return !(new UndefinedReturnValueCheck().mayReturnDefinedValue(functionBody));
  } else if (declaredValue.isQualifiedName()) {
    return isKnownToReturnOnlyUndefined(declaredValue.getQualifiedName());
  } else {
    // TODO(bradfordcsmith): What cases are these? Can we do better?
    return false;
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:56,代码来源:Es6ConvertSuperConstructorCalls.java


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