private Node parseParametersType ( JsDocToken token ) { Node paramsType = newNode ( Token . PARAM_LIST ) ; boolean isVarArgs = false ; Node paramType = null ; if ( token != JsDocToken . RIGHT_PAREN ) { do { if ( paramType != null ) { // skip past the comma next ( ) ; skipEOLs ( ) ; token = next ( ) ; } if ( token == JsDocToken . ELLIPSIS ) { // In the latest ES4 proposal, there are no type constraints allowed // on variable arguments. We support the old syntax for backwards // compatibility, but we should gradually tear it out. skipEOLs ( ) ; if ( match ( JsDocToken . RIGHT_PAREN ) ) { paramType = newNode ( Token . ELLIPSIS ) ; } else { skipEOLs ( ) ; paramType = wrapNode ( Token . ELLIPSIS , parseTypeExpression ( next ( ) ) ) ; skipEOLs ( ) ; } isVarArgs = true ; } else { paramType = parseTypeExpression ( token ) ; if ( match ( JsDocToken . EQUALS ) ) { skipEOLs ( ) ; next ( ) ; paramType = wrapNode ( Token . EQUALS , paramType ) ; } } if ( paramType == null ) { return null ; } paramsType . addChildToBack ( paramType ) ; if ( isVarArgs ) { break ; } } while ( match ( JsDocToken . COMMA ) ) ; } if ( isVarArgs && match ( JsDocToken . COMMA ) ) { return reportTypeSyntaxWarning ( "msg.jsdoc.function.varargs" ) ; } // The right paren will be checked by parseFunctionType return paramsType ; }
order - checking in two places we just do all of it in type resolution .