Search in sources :

Example 16 with CheckReturnValue

use of com.google.errorprone.annotations.CheckReturnValue in project closure-compiler by google.

the class ChainableReverseAbstractInterpreter method declareNameInScope.

/**
 * Declares a refined type in {@code scope} for the name represented by {@code node}. It must be
 * possible to refine the type of the given node in the given scope, as determined by {@link
 * #getTypeIfRefinable}. Returns an updated flow scope, which may be different from the passed-in
 * scope if any changes occur.
 */
@CheckReturnValue
protected FlowScope declareNameInScope(FlowScope scope, Node node, JSType type) {
    switch(node.getToken()) {
        case NAME:
            return scope.inferSlotType(node.getString(), type);
        case GETPROP:
            String qualifiedName = node.getQualifiedName();
            checkNotNull(qualifiedName);
            JSType origType = node.getJSType();
            origType = origType == null ? getNativeType(UNKNOWN_TYPE) : origType;
            return scope.inferQualifiedSlot(node, qualifiedName, origType, type, false);
        case THIS:
            // "this" references aren't currently modeled in the CFG.
            return scope;
        default:
            throw new IllegalArgumentException("Node cannot be refined. \n" + node.toStringTree());
    }
}
Also used : JSType(com.google.javascript.rhino.jstype.JSType) CheckReturnValue(com.google.errorprone.annotations.CheckReturnValue)

Aggregations

CheckReturnValue (com.google.errorprone.annotations.CheckReturnValue)16 JSType (com.google.javascript.rhino.jstype.JSType)11 Node (com.google.javascript.rhino.Node)7 ObjectType (com.google.javascript.rhino.jstype.ObjectType)3 BugCheckerInfo (com.google.errorprone.BugCheckerInfo)2 SeverityLevel (com.google.errorprone.BugPattern.SeverityLevel)2 ErrorProneFlags (com.google.errorprone.ErrorProneFlags)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Predicate (com.google.common.base.Predicate)1 Supplier (com.google.common.base.Supplier)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 ErrorProneOptions (com.google.errorprone.ErrorProneOptions)1 Severity (com.google.errorprone.ErrorProneOptions.Severity)1