Package com.google.dart.engine.scanner

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


   *
   * @return the offset from the beginning of the file to the first character in the node's source
   *         range
   */
  public int getOffset() {
    Token beginToken = getBeginToken();
    if (beginToken == null) {
      return -1;
    }
    return beginToken.getOffset();
  }
View Full Code Here


    safelyVisitChild(body, visitor);
  }

  @Override
  protected Token getFirstTokenAfterCommentAndMetadata() {
    Token leftMost = leftMost(externalKeyword, constKeyword, factoryKeyword);
    if (leftMost != null) {
      return leftMost;
    }
    return returnType.getBeginToken();
  }
View Full Code Here

   *
   * @param tokens the tokens being compared to find the left-most token
   * @return the left-most of the given tokens
   */
  private Token leftMost(Token... tokens) {
    Token leftMost = null;
    int offset = Integer.MAX_VALUE;
    for (Token token : tokens) {
      if (token != null && token.getOffset() < offset) {
        leftMost = token;
      }
View Full Code Here

  @Override
  public Void visitIndexExpression(IndexExpression node) {
    MethodElement element = node.getBestElement();
    if (element instanceof MethodElement) {
      Token operator = node.getLeftBracket();
      Location location = createLocationFromToken(operator);
      recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, location);
    }
    return super.visitIndexExpression(node);
  }
View Full Code Here

  }

  @Override
  public Void visitDeclaredIdentifier(DeclaredIdentifier node) {
    SimpleIdentifier variableName = node.getIdentifier();
    Token keyword = node.getKeyword();

    LocalVariableElementImpl element = new LocalVariableElementImpl(variableName);
    ForEachStatement statement = (ForEachStatement) node.getParent();
    int declarationEnd = node.getOffset() + node.getLength();
    int statementEnd = statement.getOffset() + statement.getLength();
View Full Code Here

      } finally {
        inFunction = wasInFunction;
      }

      FunctionBody body = expression.getBody();
      Token property = node.getPropertyKeyword();
      if (property == null) {
        SimpleIdentifier functionName = node.getName();
        FunctionElementImpl element = new FunctionElementImpl(functionName);
        element.setFunctions(holder.getFunctions());
        element.setLabels(holder.getLabels());
View Full Code Here

      } finally {
        inFunction = wasInFunction;
      }

      boolean isStatic = node.isStatic();
      Token property = node.getPropertyKeyword();
      FunctionBody body = node.getBody();
      if (property == null) {
        SimpleIdentifier methodName = node.getName();
        String nameOfMethod = methodName.getName();
        if (nameOfMethod.equals(TokenType.MINUS.getLexeme())
View Full Code Here

    return super.visitTypeParameter(node);
  }

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    Token keyword = ((VariableDeclarationList) node.getParent()).getKeyword();
    boolean isConst = matches(keyword, Keyword.CONST);
    boolean isFinal = matches(keyword, Keyword.FINAL);
    boolean hasInitializer = node.getInitializer() != null;

    VariableElementImpl element;
View Full Code Here

  /**
   * Parses given {@link String} as an {@link AngularExpression} at the given offset.
   */
  AngularExpression parseAngularExpression(String contents, int startIndex, int endIndex, int offset) {
    Token token = scanDart(contents, startIndex, endIndex, offset);
    return parseAngularExpressionInToken(token);
  }
View Full Code Here

    List<Token> tokens = splitAtBar(token);
    Expression mainExpression = parseDartExpressionInToken(tokens.get(0));
    // parse formatters
    List<AngularFormatterNode> formatters = Lists.newArrayList();
    for (int i = 1; i < tokens.size(); i++) {
      Token formatterToken = tokens.get(i);
      Token barToken = formatterToken;
      formatterToken = formatterToken.getNext();
      // parse name
      Expression nameExpression = parseDartExpressionInToken(formatterToken);
      if (!(nameExpression instanceof SimpleIdentifier)) {
        reportErrorForNode(AngularCode.INVALID_FORMATTER_NAME, nameExpression);
        continue;
      }
      SimpleIdentifier name = (SimpleIdentifier) nameExpression;
      formatterToken = name.getEndToken().getNext();
      // parse arguments
      List<AngularFormatterArgument> arguments = Lists.newArrayList();
      while (formatterToken.getType() != TokenType.EOF) {
        // skip ":"
        Token colonToken = formatterToken;
        if (colonToken.getType() == TokenType.COLON) {
          formatterToken = formatterToken.getNext();
        } else {
          reportErrorForToken(AngularCode.MISSING_FORMATTER_COLON, colonToken);
        }
        // parse argument
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.