private boolean checkParam(
      NodeTraversal t, Node param, @Nullable String name, JSTypeExpression paramType) {
    boolean nameOptional;
    Node nodeToCheck = param;
    if (param.isDefaultValue()) {
      nodeToCheck = param.getFirstChild();
      nameOptional = true;
    } else if (param.isName()) {
      nameOptional = param.getString().startsWith("opt_");
    } else {
      checkState(param.isDestructuringPattern() || param.isRest(), param);
      nameOptional = false;
    }

    if (name == null || !nodeToCheck.isName()) {
      // Skip the name check, but use "<unknown name>" for other errors that might be reported.
      name = "<unknown name>";
    } else if (!nodeToCheck.matchesQualifiedName(name)) {
      t.report(nodeToCheck, INCORRECT_PARAM_NAME);
      return true;
    }

    boolean jsDocOptional = paramType != null && paramType.isOptionalArg();
    if (nameOptional && !jsDocOptional) {
      t.report(nodeToCheck, OPTIONAL_PARAM_NOT_MARKED_OPTIONAL, name);
      return true;
    }
    return false;
  }
private boolean checkParam ( NodeTraversal t , Node param , @ Nullable String name , JSTypeExpression paramType ) { boolean nameOptional ; Node nodeToCheck = param ; if ( param . isDefaultValue ( ) ) { nodeToCheck = param . getFirstChild ( ) ; nameOptional = true ; } else if ( param . isName ( ) ) { nameOptional = param . getString ( ) . startsWith ( "opt_" ) ; } else { checkState ( param . isDestructuringPattern ( ) || param . isRest ( ) , param ) ; nameOptional = false ; } if ( name == null || ! nodeToCheck . isName ( ) ) { name = "<unknown name>" ; } else if ( ! nodeToCheck . matchesQualifiedName ( name ) ) { t . report ( nodeToCheck , INCORRECT_PARAM_NAME ) ; return true ; } boolean jsDocOptional = paramType != null && paramType . isOptionalArg ( ) ; if ( nameOptional && ! jsDocOptional ) { t . report ( nodeToCheck , OPTIONAL_PARAM_NOT_MARKED_OPTIONAL , name ) ; return true ; } return false ; }
Checks that the given parameter node has the given name, and that the given type is
compatible.
@param param If this is a non-NAME node, such as a destructuring pattern, skip the name check.
@param name If null, skip the name check
@return Whether a warning was reported