Search in sources :

Example 1 with StaticTypedRef

use of com.google.javascript.rhino.jstype.StaticTypedRef in project closure-compiler by google.

the class TypeInferenceTest method getParamNameNode.

/**
 * Returns the NAME node {@code name} from the PARAM_LIST of the top level of type inference.
 */
private Node getParamNameNode(String name) {
    StaticTypedScope staticScope = checkNotNull(returnScope.getDeclarationScope(), returnScope);
    StaticTypedSlot slot = checkNotNull(staticScope.getSlot(name), staticScope);
    StaticTypedRef declaration = checkNotNull(slot.getDeclaration(), slot);
    Node node = checkNotNull(declaration.getNode(), declaration);
    assertNode(node).hasType(Token.NAME);
    assertThat(stream(node.getAncestors()).filter(Node::isParamList).collect(toImmutableList())).isNotEmpty();
    return node;
}
Also used : StaticTypedSlot(com.google.javascript.rhino.jstype.StaticTypedSlot) StaticTypedScope(com.google.javascript.rhino.jstype.StaticTypedScope) Node(com.google.javascript.rhino.Node) NodeSubject.assertNode(com.google.javascript.rhino.testing.NodeSubject.assertNode) StaticTypedRef(com.google.javascript.rhino.jstype.StaticTypedRef)

Aggregations

Node (com.google.javascript.rhino.Node)1 StaticTypedRef (com.google.javascript.rhino.jstype.StaticTypedRef)1 StaticTypedScope (com.google.javascript.rhino.jstype.StaticTypedScope)1 StaticTypedSlot (com.google.javascript.rhino.jstype.StaticTypedSlot)1 NodeSubject.assertNode (com.google.javascript.rhino.testing.NodeSubject.assertNode)1