Package com.google.javascript.rhino

Examples of com.google.javascript.rhino.JSDocInfo


    return false;
  }

  /** Find the best JSDoc for the given node. */
  public static JSDocInfo getBestJSDocInfo(Node n) {
    JSDocInfo info = n.getJSDocInfo();
    if (info == null) {
      Node parent = n.getParent();
      if (parent == null) {
        return null;
      }
View Full Code Here


  static boolean isTypedefDecl(Node n) {
    if (n.isVar()
        || n.isName() && n.getParent().isVar()
        || n.isGetProp() && n.getParent().isExprResult()) {
      JSDocInfo jsdoc = getBestJSDocInfo(n);
      return jsdoc != null && jsdoc.hasTypedefType();
    }
    return false;
  }
View Full Code Here

    if (n.isVar()
        || n.isName() && n.getParent().isVar()
        || (n.isGetProp() && n.getParent().isAssign()
            && n.getParent().getParent().isExprResult())
        || (n.isAssign() && n.getParent().isExprResult())) {
      JSDocInfo jsdoc = getBestJSDocInfo(n);
      return jsdoc != null && jsdoc.hasEnumParameterType();
    }
    return false;
  }
View Full Code Here

      n = n.getParent();
    }
    if (n.isVar() && n.getChildCount() == 1) {
      Node name = n.getFirstChild();
      Node init = name.getFirstChild();
      JSDocInfo jsdoc = getBestJSDocInfo(n);
      return jsdoc != null
          && (jsdoc.isConstructor() || jsdoc.isInterface())
          && init != null
          && init.isQualifiedName();
    }
    Node parent = n.getParent();
    if (n.isGetProp() && n.isQualifiedName()
        && parent.isAssign() && parent.getParent().isExprResult()) {
      JSDocInfo jsdoc = getBestJSDocInfo(n);
      return jsdoc != null
          && (jsdoc.isConstructor() || jsdoc.isInterface())
          && parent.getLastChild().isQualifiedName();
    }
    return false;
  }
View Full Code Here

  /**
   * Returns true iff this node defines a namespace, such as goog or goog.math.
   */
  static boolean isNamespaceDecl(Node n) {
    JSDocInfo jsdoc = getBestJSDocInfo(n);
    if (jsdoc == null || !jsdoc.isConstant()
        || !jsdoc.getTypeNodes().isEmpty()) {
      return false;
    }
    Node qnameNode;
    Node initializer;
    if (n.getParent().isVar()) {
View Full Code Here

    Preconditions.checkArgument(fnNode.isFunction());
    return fnNode.getFirstChild().getNext();
  }

  static boolean hasConstAnnotation(Node node) {
    JSDocInfo jsdoc = getBestJSDocInfo(node);
    return jsdoc != null && jsdoc.isConstant() && !jsdoc.isDefine();
  }
View Full Code Here

    NodeTraversal.traverse(compiler, root, this);
  }

  @Override
  public void visit(NodeTraversal t, Node n, Node parent) {
    JSDocInfo docInfo;

    switch (n.getType()) {
      // Infer JSDocInfo on types of all type declarations on variables.
      case Token.NAME:
        if (parent == null) {
View Full Code Here

        if (!knownLocalResult) {
          sideEffectInfo.setTaintsReturn();
        }
      }

      JSDocInfo info = getJSDocInfoForFunction(node, parent, gramp);
      if (info != null) {
        boolean hasSpecificSideEffects = false;
        if (hasSideEffectsThisAnnotation(info)) {
          if (inExterns) {
            hasSpecificSideEffects = true;
            sideEffectInfo.setTaintsThis();
          } else {
            traversal.report(node, INVALID_MODIFIES_ANNOTATION);
          }
        }

        if (hasSideEffectsArgumentsAnnotation(info)) {
          if (inExterns) {
            hasSpecificSideEffects = true;
            sideEffectInfo.setTaintsArguments();
          } else {
            traversal.report(node, INVALID_MODIFIES_ANNOTATION);
          }
        }

        if (inExterns && !info.getThrownTypes().isEmpty()) {
          hasSpecificSideEffects = true;
          sideEffectInfo.setFunctionThrows();
        }

        if (!hasSpecificSideEffects) {
View Full Code Here

    /**
     * Get the doc info associated with the function.
     */
    private JSDocInfo getJSDocInfoForFunction(
        Node node, Node parent, Node gramp) {
      JSDocInfo info = node.getJSDocInfo();
      if (info != null) {
        return info;
      } else if (parent.isName()) {
        return gramp.hasOneChild() ? gramp.getJSDocInfo() : null;
      } else if (parent.isAssign()) {
View Full Code Here

      // Gather field names from the @typedef declaration.
      // Typedefs are declared on qualified name nodes.
      if (n.isQualifiedName()) {
        // Get the JSDoc for the current node and check if it contains a
        // typedef.
        JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(n);
        if (jsDoc != null && jsDoc.hasTypedefType()) {
          // Get the corresponding type by looking at the type registry.
          JSType typedefType =
              compiler.getTypeRegistry().getType(n.getQualifiedName());
          if (typedefType != null) {
            typeVisitor.visitOnce(typedefType);
View Full Code Here

TOP

Related Classes of com.google.javascript.rhino.JSDocInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.