Java Code Examples for com.google.javascript.rhino.Node#isOr()

The following examples show how to use com.google.javascript.rhino.Node#isOr() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: jKali_003_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 2
Source File: PureFunctionIdentifierTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private String generateNameString(Node node) {
  if (node.isOr()) {
    return "(" + generateNameString(node.getFirstChild()) +
        " || " + generateNameString(node.getLastChild()) + ")";
  } else if (node.isHook()) {
    return "(" + generateNameString(node.getFirstChild().getNext()) +
        " : " + generateNameString(node.getLastChild()) + ")";
  } else {
    String result = node.getQualifiedName();
    if (result == null) {
      if (node.isFunction()) {
        result = node.toString(false, false, false).trim();
      } else {
        result = node.getFirstChild().toString(false, false, false);
        result += " " + node.getLastChild().toString(false, false, false);
      }
    }
    return result;
  }
}
 
Example 3
Source File: Cardumen_0087_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 4
Source File: Cardumen_00149_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 5
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 6
Source File: Cardumen_00149_t.java    From coming with MIT License 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 7
Source File: NodeUtil.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Find the l-value that the given r-value is being assigned to. */
static Node getBestLValue(Node n) {
  Node parent = n.getParent();
  boolean isFunctionDeclaration = isFunctionDeclaration(n);
  if (isFunctionDeclaration) {
    return n.getFirstChild();
  } else if (parent.isName()) {
    return parent;
  } else if (parent.isAssign()) {
    return parent.getFirstChild();
  } else if (isObjectLitKey(parent, parent.getParent())) {
    return parent;
  } else if (
      (parent.isHook() && parent.getFirstChild() != n) ||
      parent.isOr() ||
      parent.isAnd() ||
      (parent.isComma() && parent.getFirstChild() != n)) {
    return getBestLValue(parent);
  } else if (parent.isCast()) {
    return getBestLValue(parent);
  }
  return null;
}
 
Example 8
Source File: Closure_10_NodeUtil_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 9
Source File: jKali_003_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 10
Source File: Cardumen_0087_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 11
Source File: Cardumen_0087_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 12
Source File: jMutRepair_003_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 13
Source File: jKali_003_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 14
Source File: Cardumen_00200_t.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 15
Source File: Cardumen_00200_s.java    From coming with MIT License 5 votes vote down vote up
/** Find the best JSDoc for the given node. */
static JSDocInfo getBestJSDocInfo(Node n) {
  JSDocInfo info = n.getJSDocInfo();
  if (info == null) {
    Node parent = n.getParent();
    if (parent == null) {
      return null;
    }

    if (parent.isName()) {
      return getBestJSDocInfo(parent);
    } else if (parent.isAssign()) {
      return parent.getJSDocInfo();
    } else if (isObjectLitKey(parent, parent.getParent())) {
      return parent.getJSDocInfo();
    } else if (parent.isFunction()) {
      return parent.getJSDocInfo();
    } else if (parent.isVar() && parent.hasOneChild()) {
      return parent.getJSDocInfo();
    } else if ((parent.isHook() && parent.getFirstChild() != n) ||
               parent.isOr() ||
               parent.isAnd() ||
               (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestJSDocInfo(parent);
    }
  }
  return info;
}
 
Example 16
Source File: Closure_17_TypedScopeCreator_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Look for a type declaration on a property assignment
 * (in an ASSIGN or an object literal key).
 *
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,
 *     or {@code null} if this is a stub declaration.
 */
private JSType getDeclaredType(String sourceName, JSDocInfo info,
    Node lValue, @Nullable Node rValue) {
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(sourceName, lValue, info);
  } else if (rValue != null && rValue.isFunction() &&
      shouldUseFunctionLiteralType(
          JSType.toMaybeFunctionType(rValue.getJSType()), info, lValue)) {
    return rValue.getJSType();
  } else if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      } else {
        return createEnumTypeFromNodes(
            rValue, lValue.getQualifiedName(), info, lValue);
      }
    } else if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(
          rValue, lValue.getQualifiedName(), info, lValue);
    } else {
      // Check if this is constant, and if it has a known type.
      if (info.isConstant()) {
        JSType knownType = null;
        if (rValue != null) {
          JSDocInfo rValueInfo = rValue.getJSDocInfo();
          if (rValueInfo != null && rValueInfo.hasType()) {
            // If rValue has a type-cast, we use the type in the type-cast.
            return rValueInfo.getType().evaluate(scope, typeRegistry);
          } else if (rValue.getJSType() != null
              && !rValue.getJSType().isUnknownType()) {
            // If rValue's type was already computed during scope creation,
            // then we can safely use that.
            return rValue.getJSType();
          } else if (rValue.isOr()) {
            // Check for a very specific JS idiom:
            // var x = x || TYPE;
            // This is used by Closure's base namespace for esoteric
            // reasons.
            Node firstClause = rValue.getFirstChild();
            Node secondClause = firstClause.getNext();
            boolean namesMatch = firstClause.isName()
                && lValue.isName()
                && firstClause.getString().equals(lValue.getString());
            if (namesMatch && secondClause.getJSType() != null
                && !secondClause.getJSType().isUnknownType()) {
              return secondClause.getJSType();
            }
          }
        }
      }
    }
  }

  return getDeclaredTypeInAnnotation(sourceName, lValue, info);
}
 
Example 17
Source File: TypedScopeCreator.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Look for a type declaration on a property assignment
 * (in an ASSIGN or an object literal key).
 *
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,
 *     or {@code null} if this is a stub declaration.
 */
private JSType getDeclaredType(String sourceName, JSDocInfo info,
    Node lValue, @Nullable Node rValue) {
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(sourceName, lValue, info);
  } else if (rValue != null && rValue.isFunction() &&
      shouldUseFunctionLiteralType(
          JSType.toMaybeFunctionType(rValue.getJSType()), info, lValue)) {
    return rValue.getJSType();
  } else if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      } else {
        return createEnumTypeFromNodes(
            rValue, lValue.getQualifiedName(), info, lValue);
      }
    } else if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(
          rValue, lValue.getQualifiedName(), info, lValue);
    } else {
      // Check if this is constant, and if it has a known type.
      if (info.isConstant()) {
        JSType knownType = null;
        if (rValue != null) {
          JSDocInfo rValueInfo = rValue.getJSDocInfo();
          if (rValueInfo != null && rValueInfo.hasType()) {
            // If rValue has a type-cast, we use the type in the type-cast.
            return rValueInfo.getType().evaluate(scope, typeRegistry);
          } else if (rValue.getJSType() != null
              && !rValue.getJSType().isUnknownType()) {
            // If rValue's type was already computed during scope creation,
            // then we can safely use that.
            return rValue.getJSType();
          } else if (rValue.isOr()) {
            // Check for a very specific JS idiom:
            // var x = x || TYPE;
            // This is used by Closure's base namespace for esoteric
            // reasons.
            Node firstClause = rValue.getFirstChild();
            Node secondClause = firstClause.getNext();
            boolean namesMatch = firstClause.isName()
                && lValue.isName()
                && firstClause.getString().equals(lValue.getString());
            if (namesMatch && secondClause.getJSType() != null
                && !secondClause.getJSType().isUnknownType()) {
              return secondClause.getJSType();
            }
          }
        }
      }
    }
  }

  return getDeclaredTypeInAnnotation(sourceName, lValue, info);
}
 
Example 18
Source File: Closure_48_TypedScopeCreator_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Look for a type declaration on a property assignment
 * (in an ASSIGN or an object literal key).
 *
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,
 *     or {@code null} if this is a stub declaration.
 */
private JSType getDeclaredType(String sourceName, JSDocInfo info,
    Node lValue, @Nullable Node rValue) {
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(sourceName, lValue, info);
  } else if (rValue != null && rValue.isFunction() &&
      shouldUseFunctionLiteralType(
          JSType.toMaybeFunctionType(rValue.getJSType()), info, lValue)) {
    return rValue.getJSType();
  } else if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      } else {
        return createEnumTypeFromNodes(
            rValue, lValue.getQualifiedName(), info, lValue);
      }
    } else if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(
          rValue, lValue.getQualifiedName(), info, lValue);
    } else {
      // Check if this is constant, and if it has a known type.
      if (info.isConstant()) {
        JSType knownType = null;
        if (rValue != null) {
          if (rValue.getJSType() != null
              && !rValue.getJSType().isUnknownType()) {
            return rValue.getJSType();
          } else if (rValue.isOr()) {
            // Check for a very specific JS idiom:
            // var x = x || TYPE;
            // This is used by Closure's base namespace for esoteric
            // reasons.
            Node firstClause = rValue.getFirstChild();
            Node secondClause = firstClause.getNext();
            boolean namesMatch = firstClause.isName()
                && lValue.isName()
                && firstClause.getString().equals(lValue.getString());
            if (namesMatch && secondClause.getJSType() != null
                && !secondClause.getJSType().isUnknownType()) {
              return secondClause.getJSType();
            }
          }
        }
      }
    }
  }

  return getDeclaredTypeInAnnotation(sourceName, lValue, info);
}
 
Example 19
Source File: Nopol2017_0027_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Look for a type declaration on a property assignment
 * (in an ASSIGN or an object literal key).
 *
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,
 *     or {@code null} if this is a stub declaration.
 */
private JSType getDeclaredType(String sourceName, JSDocInfo info,
    Node lValue, @Nullable Node rValue) {
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(sourceName, lValue, info);
  } else if (rValue != null && rValue.isFunction() &&
      shouldUseFunctionLiteralType(
          JSType.toMaybeFunctionType(rValue.getJSType()), info, lValue)) {
    return rValue.getJSType();
  } else if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      } else {
        return createEnumTypeFromNodes(
            rValue, lValue.getQualifiedName(), info, lValue);
      }
    } else if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(
          rValue, lValue.getQualifiedName(), info, lValue);
    } else {
      // Check if this is constant, and if it has a known type.
      if (info.isConstant()) {
        JSType knownType = null;
        if (rValue != null) {
          if (rValue.getJSType() != null && !rValue.getJSType().isUnknownType()) {
            // If rValue has a type-cast, we use the type in the type-cast.
            // If rValue's type was already computed during scope creation,
            // then we can safely use that.
            return rValue.getJSType();
          } else if (rValue.isOr()) {
            // Check for a very specific JS idiom:
            // var x = x || TYPE;
            // This is used by Closure's base namespace for esoteric
            // reasons.
            Node firstClause = rValue.getFirstChild();
            Node secondClause = firstClause.getNext();
            boolean namesMatch = firstClause.isName()
                && lValue.isName()
                && firstClause.getString().equals(lValue.getString());
            if (namesMatch && secondClause.getJSType() != null
                && !secondClause.getJSType().isUnknownType()) {
              return secondClause.getJSType();
            }
          }
        }
      }
    }
  }

  return getDeclaredTypeInAnnotation(sourceName, lValue, info);
}
 
Example 20
Source File: Nopol2017_0027_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Look for a type declaration on a property assignment
 * (in an ASSIGN or an object literal key).
 *
 * @param info The doc info for this property.
 * @param lValue The l-value node.
 * @param rValue The node that {@code n} is being initialized to,
 *     or {@code null} if this is a stub declaration.
 */
private JSType getDeclaredType(String sourceName, JSDocInfo info,
    Node lValue, @Nullable Node rValue) {
  if (info != null && info.hasType()) {
    return getDeclaredTypeInAnnotation(sourceName, lValue, info);
  } else if (rValue != null && rValue.isFunction() &&
      shouldUseFunctionLiteralType(
          JSType.toMaybeFunctionType(rValue.getJSType()), info, lValue)) {
    return rValue.getJSType();
  } else if (info != null) {
    if (info.hasEnumParameterType()) {
      if (rValue != null && rValue.isObjectLit()) {
        return rValue.getJSType();
      } else {
        return createEnumTypeFromNodes(
            rValue, lValue.getQualifiedName(), info, lValue);
      }
    } else if (info.isConstructor() || info.isInterface()) {
      return createFunctionTypeFromNodes(
          rValue, lValue.getQualifiedName(), info, lValue);
    } else {
      // Check if this is constant, and if it has a known type.
      if (info.isConstant()) {
        JSType knownType = null;
        if (rValue != null) {
          if (rValue.getJSType() != null && !rValue.getJSType().isUnknownType()) {
            // If rValue has a type-cast, we use the type in the type-cast.
            // If rValue's type was already computed during scope creation,
            // then we can safely use that.
            if (!(com.google.javascript.jscomp.TypedScopeCreator.DELEGATE_PROXY_SUFFIX.length() == -1 + com.google.javascript.jscomp.TypedScopeCreator.this.functionAnalysisResults.size())) {
              return rValue.getJSType();
            }
          } else if (rValue.isOr()) {
            // Check for a very specific JS idiom:
            // var x = x || TYPE;
            // This is used by Closure's base namespace for esoteric
            // reasons.
            Node firstClause = rValue.getFirstChild();
            Node secondClause = firstClause.getNext();
            boolean namesMatch = firstClause.isName()
                && lValue.isName()
                && firstClause.getString().equals(lValue.getString());
            if (namesMatch && secondClause.getJSType() != null
                && !secondClause.getJSType().isUnknownType()) {
              return secondClause.getJSType();
            }
          }
        }
      }
    }
  }

  return getDeclaredTypeInAnnotation(sourceName, lValue, info);
}