Package com.google.dart.engine.internal.parser

Examples of com.google.dart.engine.internal.parser.FinalConstVarOrType


   *
   * @return the normal formal parameter that was parsed
   */
  protected NormalFormalParameter parseNormalFormalParameter() {
    CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
    FinalConstVarOrType holder = parseFinalConstVarOrType(true);
    Token thisKeyword = null;
    Token period = null;
    if (matchesKeyword(Keyword.THIS)) {
      thisKeyword = getAndAdvance();
      period = expect(TokenType.PERIOD);
    }
    SimpleIdentifier identifier = parseSimpleIdentifier();
    if (matches(TokenType.OPEN_PAREN)) {
      FormalParameterList parameters = parseFormalParameterList();
      if (thisKeyword == null) {
        if (holder.getKeyword() != null) {
          reportErrorForToken(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.getKeyword());
        }
        return new FunctionTypedFormalParameter(
            commentAndMetadata.getComment(),
            commentAndMetadata.getMetadata(),
            holder.getType(),
            identifier,
            parameters);
      } else {
        return new FieldFormalParameter(
            commentAndMetadata.getComment(),
            commentAndMetadata.getMetadata(),
            holder.getKeyword(),
            holder.getType(),
            thisKeyword,
            period,
            identifier,
            parameters);
      }
    }
    TypeName type = holder.getType();
    if (type != null) {
      if (tokenMatchesKeyword(type.getName().getBeginToken(), Keyword.VOID)) {
        reportErrorForToken(ParserErrorCode.VOID_PARAMETER, type.getName().getBeginToken());
      } else if (holder.getKeyword() != null
          && tokenMatchesKeyword(holder.getKeyword(), Keyword.VAR)) {
        reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.getKeyword());
      }
    }
    if (thisKeyword != null) {
      return new FieldFormalParameter(
          commentAndMetadata.getComment(),
          commentAndMetadata.getMetadata(),
          holder.getKeyword(),
          holder.getType(),
          thisKeyword,
          period,
          identifier,
          null);
    }
    return new SimpleFormalParameter(
        commentAndMetadata.getComment(),
        commentAndMetadata.getMetadata(),
        holder.getKeyword(),
        holder.getType(),
        identifier);
  }
View Full Code Here


        type = parseReturnType();
      } else if (!optional) {
        reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE);
      }
    }
    return new FinalConstVarOrType(keyword, type);
  }
View Full Code Here

   * @param commentAndMetadata the metadata to be associated with the variable declaration list
   * @return the variable declaration list that was parsed
   */
  private VariableDeclarationList parseVariableDeclarationListAfterMetadata(
      CommentAndMetadata commentAndMetadata) {
    FinalConstVarOrType holder = parseFinalConstVarOrType(false);
    return parseVariableDeclarationListAfterType(
        commentAndMetadata,
        holder.getKeyword(),
        holder.getType());
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.parser.FinalConstVarOrType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.