Java Code Examples for com.google.javascript.rhino.Token#UNDEFINED_TYPE

The following examples show how to use com.google.javascript.rhino.Token#UNDEFINED_TYPE . 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: TypeAnnotationPass.java    From clutz with MIT License 5 votes vote down vote up
/** Returns whether a union type contains `undefined`. */
private static boolean unionContainsUndefined(TypeDeclarationNode union) {
  for (Node unionChild : union.children()) {
    if (unionChild.getToken() == Token.UNDEFINED_TYPE) {
      return true;
    }
  }
  return false;
}
 
Example 2
Source File: TypeAnnotationPass.java    From clutz with MIT License 5 votes vote down vote up
/** Converts a union type to one without `undefined`, if it is present, detaching the original union. */
private static TypeDeclarationNode getUnionTypeNoUndefined(TypeDeclarationNode union) {
  List<TypeDeclarationNode> nonUndefinedChildren = new ArrayList<>();
  for (Node unionChild : union.children()) {
    if (unionChild.getToken() != Token.UNDEFINED_TYPE) {
      nonUndefinedChildren.add((TypeDeclarationNode) unionChild);
    }
  }
  union.detachChildren();
  return unionType(nonUndefinedChildren);
}