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


Java JSDocInfo.hasEnumParameterType方法代码示例

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


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

示例1: isConstructorOrEnumDeclaration

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/**
 * Determines whether a set operation is a constructor or enumeration
 * declaration. The set operation may either be an assignment to a name,
 * a variable declaration, or an object literal key mapping.
 *
 * @param n The node that represents the name being set
 * @param parent Parent node of {@code n} (an ASSIGN, VAR, or OBJLIT node)
 * @return Whether the set operation is either a constructor or enum
 *     declaration
 */
private boolean isConstructorOrEnumDeclaration(Node n, Node parent) {
  JSDocInfo info;
  int valueNodeType;
  switch (parent.getType()) {
    case Token.ASSIGN:
      info = parent.getJSDocInfo();
      valueNodeType = n.getNext().getType();
      break;
    case Token.VAR:
      info = n.getJSDocInfo();
      if (info == null) {
        info = parent.getJSDocInfo();
      }
      Node valueNode = n.getFirstChild();
      valueNodeType = valueNode != null ? valueNode.getType() : Token.VOID;
      break;
    default:
      return false;
  }
  // Heed the annotations only if they're sensibly used.
  return info != null &&
         (info.isConstructor() && valueNodeType == Token.FUNCTION ||
          info.hasEnumParameterType() && valueNodeType == Token.OBJECTLIT);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:35,代码来源:GlobalNamespace.java

示例2: attachJsDoc

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/** Attach JSDocInfo to a node, if we can find one. */
private void attachJsDoc(Comment comment, JSDocInfo info) {
  Collection<NodeWithJsDoc> candidates =
      nodesWithJsDoc.get(comment.getValue());
  if (candidates.isEmpty()) {
    return;
  }

  Iterator<NodeWithJsDoc> candidateIter = candidates.iterator();
  Node node = candidateIter.next().node;
  candidateIter.remove();
  node.setJSDocInfo(info);
  if (info.hasEnumParameterType()) {
    if (node.getType() == Token.NAME) {
      registry.identifyEnumName(node.getString());
    } else if (node.getType() == Token.VAR &&
          node.getChildCount() == 1) {
      registry.identifyEnumName(
          node.getFirstChild().getString());
    } else if (node.getType() == Token.ASSIGN) {
      registry.identifyEnumName(
          node.getFirstChild().getQualifiedName());
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:26,代码来源:IRFactory.java

示例3: visitVar

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/**
 * Visits a VAR node.
 *
 * @param t The node traversal object that supplies context, such as the
 * scope chain to use in name lookups as well as error reporting.
 * @param n The node being visited.
 */
private void visitVar(NodeTraversal t, Node n) {
  // TODO(nicksantos): Fix this so that the doc info always shows up
  // on the NAME node. We probably want to wait for the parser
  // merge to fix this.
  JSDocInfo varInfo = n.hasOneChild() ? n.getJSDocInfo() : null;
  for (Node name : n.children()) {
    Node value = name.getFirstChild();
    // A null var would indicate a bug in the scope creation logic.
    Var var = t.getScope().getVar(name.getString());

    if (value != null) {
      JSType valueType = getJSType(value);
      JSType nameType = var.getType();
      nameType = (nameType == null) ? getNativeType(UNKNOWN_TYPE) : nameType;

      JSDocInfo info = name.getJSDocInfo();
      if (info == null) {
        info = varInfo;
      }
      if (info != null && info.hasEnumParameterType()) {
        // var.getType() can never be null, this would indicate a bug in the
        // scope creation logic.
        checkEnumInitializer(
            t, value,  info.getEnumParameterType().evaluate(t.getScope()));
      } else if (var.isTypeInferred()) {
        ensureTyped(t, name, valueType);
      } else {
        validator.expectCanAssignTo(
            t, value, valueType, nameType, "initializing variable");
      }
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:41,代码来源:TypeCheck.java

示例4: defineName

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/**
 * Defines a variable based on the {@link Token#NAME} node passed.
 * @param name The {@link Token#NAME} node.
 * @param var The parent of the {@code name} node, which must be a
 *     {@link Token#VAR} node.
 * @param parent {@code var}'s parent.
 * @param info the {@link JSDocInfo} information relating to this
 *     {@code name} node.
 */
private void defineName(Node name, Node var, Node parent, JSDocInfo info) {
  Node value = name.getFirstChild();

  if (value != null && value.getType() == Token.FUNCTION) {
    // function
    String functionName = name.getString();
    FunctionType functionType =
        getFunctionType(functionName, value, info, null);
    defineSlot(name, var, functionType);
  } else {
    // variable's type
    JSType type = null;
    if (info == null) {
      // the variable's type will be inferred
      CompilerInput input = compiler.getInput(sourceName);
      Preconditions.checkNotNull(input, sourceName);
      type = input.isExtern() ?
          typeRegistry.getNativeType(UNKNOWN_TYPE) : null;
    } else if (info.hasEnumParameterType()) {
      type = getEnumType(name.getString(), var, value,
          info.getEnumParameterType().evaluate(scope));
    } else if (info.isConstructor()) {
      type = getFunctionType(name.getString(), value, info, name);
    } else {
      type = getDeclaredTypeInAnnotation(sourceName, name, info);
    }

    defineSlot(name, var, type);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:40,代码来源:TypedScopeCreator.java

示例5: getDeclaredGetPropType

import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
/**
 * Look for a type declaration on a GETPROP node.
 *
 * @param info The doc info for this property.
 * @param n A top-level GETPROP node (it should not be contained inside
 *     another GETPROP).
 * @param rhsValue The node that {@code n} is being initialized to,
 *     or {@code null} if this is a stub declaration.
 */
private JSType getDeclaredGetPropType(NodeTraversal t, JSDocInfo info,
    Node n, Node rhsValue) {
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(t, n, info);
  } else if (info != null && info.hasEnumParameterType()) {
    return n.getJSType();
  } else if (rhsValue != null &&
      rhsValue.getType() == Token.FUNCTION) {
    return rhsValue.getJSType();
  } else {
    return getDeclaredTypeInAnnotation(t, n, info);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:23,代码来源:TypedScopeCreator.java


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