Package com.google.collide.codemirror2

Examples of com.google.collide.codemirror2.TokenType


  @Override
  public void onParseLine(Line line, int lineNumber, JsonArray<Token> tokens) {
    int column = 0;
    for (Token token : tokens.asIterable()) {
      TokenType type = token.getType();
      String value = token.getValue();
      column = column + value.length();

      if (TokenType.WHITESPACE == type || TokenType.NEWLINE == type) {
        spaceBetween = true;
View Full Code Here


    idsToRelease.addAll(lineIds);
    lineIds.clear();

    for (int i = 0, l = tokens.size(); i < l; i++) {
      Token token = tokens.get(i);
      TokenType type = token.getType();
      if (type == VARIABLE || type == VARIABLE2 || type == PROPERTY || type == DEF) {
        String value = token.getValue();
        if (value.length() > 2) {
          lineIds.add(value);
        }
View Full Code Here

     * <p>Tokens that hold no information are omitted.
     *
     * @param nextToken token to push to context
     */
    private void nextToken(Token nextToken) {
      TokenType nextTokenType = nextToken.getType();
      if (WHITESPACE != nextTokenType && NEWLINE != nextTokenType) {
        predpred = pred;
        pred = nextToken;
      }
    }
View Full Code Here

    int index = 0;
    while (index < size) {
      Token token = tokens.get(index);
      index++;

      TokenType tokenType = token.getType();

      if (TokenType.WHITESPACE == tokenType
          || TokenType.NEWLINE == tokenType
          || TokenType.COMMENT == tokenType) {
        // TODO: Parse JsDocs.
View Full Code Here

      StringMultiset tagAttributes = tag.getAttributes();

      while (index < size) {
        Token token = tokens.get(index);
        index++;
        TokenType tokenType = token.getType();
        if (ATTRIBUTE == tokenType) {
          String attribute = token.getValue();
          attribute = ignoreCase ? attribute.toLowerCase() : attribute;
          attributes.add(attribute);
          tagAttributes.add(attribute);
        } else if (TAG == tokenType) {
          // Tag closing token
          tag.setDirty(false);
          inTag = false;
          break;
        }
      }
      if (newAttributes && attributes.size() != 0) {
        line.putTag(TAG_ATTRIBUTES, attributes);
      } else if (!newAttributes && attributes.size() == 0) {
        line.putTag(TAG_ATTRIBUTES, null);
      }
    } else {
      line.putTag(TAG_ATTRIBUTES, null);
    }

    while (index < size) {
      Token token = tokens.get(index);
      index++;
      TokenType tokenType = token.getType();
      if (TAG == tokenType) {
        if (inTag) {
          if (">".equals(token.getValue()) || "/>".equals(token.getValue())) {
            // If type is "tag" and content is ">", this is HTML token.
            inTag = false;
          }
        } else {
          // Check that we are in html mode.
          if (CodeMirror2.HTML.equals(token.getMode())) {
            lastTagTokenIndex = index - 1;
            inTag = true;
          }
        }
      }
    }

    if (inTag) {
      if (lastTagTokenIndex != -1) {
        index = lastTagTokenIndex;
        Token token = tokens.get(index);
        index++;
        String tagName = token.getValue().substring(1).trim();
        tag = new HtmlTagWithAttributes(tagName);
        StringMultiset tagAttributes = tag.getAttributes();
        while (index < size) {
          token = tokens.get(index);
          index++;
          TokenType tokenType = token.getType();
          if (ATTRIBUTE == tokenType) {
            String attribute = token.getValue();
            tagAttributes.add(ignoreCase ? attribute.toLowerCase() : attribute);
          }
        }
View Full Code Here

  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

    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) {
View Full Code Here

    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);
    }
View Full Code Here

      }
      ParseResult<HtmlState> parseResult = getParser().getState(HtmlState.class, cursor, null);
      if (parseResult != null) {
        XmlState xmlState = parseResult.getState().getXmlState();
        if (xmlState != null) {
          XmlContext xmlContext = xmlState.getContext();
          if (xmlContext != null) {
            String tagName = xmlContext.getTagName();
            if (tagName != null) {
              String addend = "/" + tagName + ELEMENT_SEPARATOR_CLOSE;
              return new ExplicitAction(new DefaultAutocompleteResult(addend, "", addend.length()));
            }
          }
View Full Code Here

      if (cursorColumn == 0 || '<' != cursorLine.getText().charAt(cursorColumn - 1)) {
        return ExplicitAction.DEFAULT;
      }
      ParseResult<HtmlState> parseResult = getParser().getState(HtmlState.class, cursor, null);
      if (parseResult != null) {
        XmlState xmlState = parseResult.getState().getXmlState();
        if (xmlState != null) {
          XmlContext xmlContext = xmlState.getContext();
          if (xmlContext != null) {
            String tagName = xmlContext.getTagName();
            if (tagName != null) {
              String addend = "/" + tagName + ELEMENT_SEPARATOR_CLOSE;
              return new ExplicitAction(new DefaultAutocompleteResult(addend, "", addend.length()));
View Full Code Here

TOP

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

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.