Package com.google.collide.codemirror2

Examples of com.google.collide.codemirror2.Parser


   */
  static boolean buildInvocationSequenceContext(
      JsonArray<Token> tokens, boolean expectingPeriod, JsonArray<String> contextParts) {
    // right-to-left tokens processing loop.
    while (!tokens.isEmpty()) {
      Token lastToken = tokens.pop();
      TokenType lastTokenType = lastToken.getType();
      String lastTokenValue = lastToken.getValue();

      // Omit whitespaces.
      if (lastTokenType == WHITESPACE) {
        continue;
      }
View Full Code Here


    if (result == null) {
      return new ExtendedParseResult<T>(null, Context.NOT_PARSED);
    }

    JsonArray<Token> tokens = result.getTokens();
    Token lastToken = tokens.peek();
    Preconditions.checkNotNull(lastToken,
        "Last token expected to be non-null; text='%s', position=%s", text, position);
    TokenType lastTokenType = lastToken.getType();
    String lastTokenValue = lastToken.getValue();
    if (!addSpace) {
      if (lastTokenType == STRING || lastTokenType == REGEXP) {
        return new ExtendedParseResult<T>(result, Context.IN_STRING);
      } else if (lastTokenType == TokenType.COMMENT) {
        return new ExtendedParseResult<T>(result, Context.IN_COMMENT);
      }

      // Python parser, for a purpose of simplicity, parses period and variable
      // name as a single token. If period is not followed by identifier, parser
      // states that this is and error, which is, generally, not truth.
      if ((lastTokenType == TokenType.ERROR) && LITERAL_PERIOD.equals(lastTokenValue)) {
        tokens.pop();
        tokens.add(new Token(lastToken.getMode(), TokenType.NULL, LITERAL_PERIOD));
      }

      return new ExtendedParseResult<T>(result, Context.IN_CODE);
    }

    // Remove / shorten last token to omit added whitespace.
    tokens.pop();
    if (lastTokenType == STRING || lastTokenType == REGEXP || lastTokenType == TokenType.COMMENT) {
      // Whitespace stuck to token - strip it.
      lastTokenValue = lastTokenValue.substring(0, lastTokenValue.length() - 1);
      tokens.add(new Token(lastToken.getMode(), lastTokenType, lastTokenValue));
      if (lastTokenType == STRING || lastTokenType == REGEXP) {
        return new ExtendedParseResult<T>(result, Context.IN_STRING);
      } else {
        return new ExtendedParseResult<T>(result, Context.IN_COMMENT);
      }
View Full Code Here

      }
      JsonArray<Token> tokens = parseResult.getTokens();
      if (tokens.isEmpty()) {
        return null;
      }
      Token lastToken = tokens.peek();
      return lastToken.getValue();
    }
View Full Code Here

    int indent = 0;
    if (TokenType.WHITESPACE == tokens.get(0).getType()) {
      indent = tokens.get(0).getValue().length();
    }

    Token lastToken = tokens.pop();
    TokenType lastTokenType = lastToken.getType();

    if (lastTokenType == WHITESPACE) {
      return new CompletionContext<T>("", "", false, CompletionType.GLOBAL, parseResult, indent);
    }

    String lastTokenValue = lastToken.getValue();

    if (lastTokenType == KEYWORD) {
      return new CompletionContext<T>(
          "", lastTokenValue, false, CompletionType.GLOBAL, parseResult, indent);
    }
View Full Code Here

    boolean inAnchorTag = false;
    boolean inHrefAttribute = false;
    int tokenEndColumn = 0;
    for (int i = 0, l = tokens.size() - 1; i < l; i++) {
      Token token = tokens.get(i);
      TokenType type = token.getType();
      String value = token.getValue();
      int tokenStartColumn = tokenEndColumn;
      tokenEndColumn += value.length()// Exclusive.
      if (type == TokenType.TAG) {
        if (">".equals(value) || "/>".equals(value)) {
View Full Code Here

      inAnchorTag = true;
    }
    int tokenEndColumn = 0;
    for (int i = 0, l = tokens.size() - 1; i < l; i++) {
      Token token = tokens.get(i);
      TokenType type = token.getType();
      String value = token.getValue();
      int tokenStartColumn = tokenEndColumn;
      tokenEndColumn += value.length();
      if (type == TokenType.TAG) {
        if (">".equals(value) || "/>".equals(value)) {
View Full Code Here

      MatchResult result = PARSER.exec(text);
      if (result == null) {
        throw new IllegalArgumentException("Can't parse: " + text);
      }
      String value;
      TokenType type;
      if (result.getGroup(2) != null) {
        value = result.getGroup(2);
        type = VARIABLE;
      } else if (result.getGroup(3) != null) {
        value = result.getGroup(3);
View Full Code Here

    int index = 0;

    while (index < size) {
      Token token = tokens.get(index);
      colCount += token.getValue().length();
      TokenType type = token.getType();
      index++;
      if (TokenType.TAG == type) {
        // Toggle "inTag" flag and update tag bounds.
        if (result.inTag) {
          // Refer to XmlCodeAnalyzer parsing code notes.
View Full Code Here

    StringMultiset tagAttributes = result.getAttributes();
    while (index < findTagResult.endTagIndex) {
      token = tokens.get(index);
      index++;
      TokenType tokenType = token.getType();
      if (TokenType.ATTRIBUTE == tokenType) {
        tagAttributes.add(token.getValue().toLowerCase());
      }
    }
View Full Code Here

        // Or new (temporary) object constructed.
        tag = buildTag(findTagResult, tokens);
      }
    }

    TokenType type = findTagResult.inToken.getType();
    String value = findTagResult.inToken.getValue();
    value = value.substring(0, value.length() - findTagResult.cut);
    if (TokenType.TAG == type) {
      value = value.substring(1).trim();
      return new HtmlAutocompleteProposals(
View Full Code Here

TOP

Related Classes of com.google.collide.codemirror2.Parser

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.