private Node parseUnionTypeWithAlternate ( JsDocToken token , Node alternate ) { Node union = newNode ( Token . PIPE ) ; if ( alternate != null ) { union . addChildToBack ( alternate ) ; } Node expr = null ; do { if ( expr != null ) { skipEOLs ( ) ; token = next ( ) ; checkState ( token == JsDocToken . PIPE ) ; skipEOLs ( ) ; token = next ( ) ; } expr = parseTypeExpression ( token ) ; if ( expr == null ) { return null ; } union . addChildToBack ( expr ) ; } while ( match ( JsDocToken . PIPE ) ) ; if ( alternate == null ) { skipEOLs ( ) ; if ( ! match ( JsDocToken . RIGHT_PAREN ) ) { return reportTypeSyntaxWarning ( "msg.jsdoc.missing.rp" ) ; } next ( ) ; } if ( union . hasOneChild ( ) ) { Node firstChild = union . getFirstChild ( ) ; union . removeChild ( firstChild ) ; return firstChild ; } return union ; }
Create a new union type with an alternate that has already been parsed . The alternate may be null .