Package com.google.dart.engine.scanner

Examples of com.google.dart.engine.scanner.Token


         * </pre>
         *
         * @return the type argument list that was parsed
         */
  protected TypeArgumentList parseTypeArgumentList() {
    Token leftBracket = expect(TokenType.LT);
    List<TypeName> arguments = new ArrayList<TypeName>();
    arguments.add(parseTypeName());
    while (optional(TokenType.COMMA)) {
      arguments.add(parseTypeName());
    }
    Token rightBracket = expectGt();
    return new TypeArgumentList(leftBracket, arguments, rightBracket);
  }
View Full Code Here


   */
  protected TypeParameter parseTypeParameter() {
    CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
    SimpleIdentifier name = parseSimpleIdentifier();
    if (matchesKeyword(Keyword.EXTENDS)) {
      Token keyword = getAndAdvance();
      TypeName bound = parseTypeName();
      return new TypeParameter(
          commentAndMetadata.getComment(),
          commentAndMetadata.getMetadata(),
          name,
View Full Code Here

         * </pre>
         *
         * @return the list of type parameters that were parsed
         */
  protected TypeParameterList parseTypeParameterList() {
    Token leftBracket = expect(TokenType.LT);
    List<TypeParameter> typeParameters = new ArrayList<TypeParameter>();
    typeParameters.add(parseTypeParameter());
    while (optional(TokenType.COMMA)) {
      typeParameters.add(parseTypeParameter());
    }
    Token rightBracket = expectGt();
    return new TypeParameterList(leftBracket, typeParameters, rightBracket);
  }
View Full Code Here

* </pre>
   *
   * @return the with clause that was parsed
   */
  protected WithClause parseWithClause() {
    Token with = expectKeyword(Keyword.WITH);
    ArrayList<TypeName> types = new ArrayList<TypeName>();
    types.add(parseTypeName());
    while (optional(TokenType.COMMA)) {
      types.add(parseTypeName());
    }
View Full Code Here

    } else if (matchesIdentifier()) {
      if (tokenMatches(peek(), TokenType.OPEN_PAREN)) {
        // This looks like the start of a function
        return true;
      }
      Token token = skipReturnType(currentToken);
      if (token == null) {
        return false;
      }
      if (matchesKeyword(Keyword.GET) || matchesKeyword(Keyword.SET)
          || (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) || matchesIdentifier()) {
View Full Code Here

   * Create a synthetic identifier.
   *
   * @return the synthetic identifier that was created
   */
  private SimpleIdentifier createSyntheticIdentifier() {
    Token syntheticToken;
    if (currentToken.getType() == TokenType.KEYWORD) {
      // Consider current keyword token as an identifier.
      // It is not always true, e.g. "^is T" where "^" is place the place for synthetic identifier.
      // By creating SyntheticStringToken we can distinguish a real identifier from synthetic.
      // In the code completion behavior will depend on a cursor position - before or on "is".
View Full Code Here

   * Advance to the next token in the token stream, making it the new current token.
   *
   * @return the token that was current before this method was invoked
   */
  private Token getAndAdvance() {
    Token token = currentToken;
    advance();
    return token;
  }
View Full Code Here

   *
   * @return {@code true} if we can successfully parse the rest of a type alias if we first parse a
   *         return type.
   */
  private boolean hasReturnTypeInTypeAlias() {
    Token next = skipReturnType(currentToken);
    if (next == null) {
      return false;
    }
    return tokenMatchesIdentifier(next);
  }
View Full Code Here

   *
   * @param token the token to be added to the token stream
   * @return the token that was just added to the token stream
   */
  private Token injectToken(Token token) {
    Token previous = currentToken.getPrevious();
    token.setNext(currentToken);
    previous.setNext(token);
    return token;
  }
View Full Code Here

   */
  private boolean isFunctionDeclaration() {
    if (matchesKeyword(Keyword.VOID)) {
      return true;
    }
    Token afterReturnType = skipTypeName(currentToken);
    if (afterReturnType == null) {
      // There was no return type, but it is optional, so go back to where we started.
      afterReturnType = currentToken;
    }
    Token afterIdentifier = skipSimpleIdentifier(afterReturnType);
    if (afterIdentifier == null) {
      // It's possible that we parsed the function name as if it were a type name, so see whether
      // it makes sense if we assume that there is no type.
      afterIdentifier = skipSimpleIdentifier(currentToken);
    }
    if (afterIdentifier == null) {
      return false;
    }
    if (isFunctionExpression(afterIdentifier)) {
      return true;
    }
    // It's possible that we have found a getter. While this isn't valid at this point we test for
    // it in order to recover better.
    if (matchesKeyword(Keyword.GET)) {
      Token afterName = skipSimpleIdentifier(currentToken.getNext());
      if (afterName == null) {
        return false;
      }
      return tokenMatches(afterName, TokenType.FUNCTION)
          || tokenMatches(afterName, TokenType.OPEN_CURLY_BRACKET);
View Full Code Here

TOP

Related Classes of com.google.dart.engine.scanner.Token

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.