Package org.eclipse.orion.server.cf.manifest.v2

Examples of org.eclipse.orion.server.cf.manifest.v2.Token


    HtmlTagsAndAttributes htmlAttributes = HtmlTagsAndAttributes.getInstance();
    SimpleStringBag excluded = new SimpleStringBag();
    assertEquals(1, htmlAttributes.searchAttributes("ol", excluded, reversed).size());
    excluded.add(reversed);

    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<ol"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, reversed));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATOM, "="));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.STRING, "\"\""));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    AutocompleteProposals proposals = findAutocompletions();

    assertEquals(htmlAttributes.searchAttributes("ol", excluded, "").size(), proposals.size());
    assertEquals("accesskey", proposals.get(0).getName());
    assertNull(TestUtils.selectProposalByName(proposals, reversed));
View Full Code Here


  /**
   * Tests the proposals for ELEMENT.
   */
  public void testAutocompleteHtmlElements() {
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<a"));
    AutocompleteProposals proposals = findAutocompletions();

    assertEquals(7, proposals.size());
    assertEquals("abbr", proposals.get(1).getName());

    lineTokens.clear();
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<bod"));
    proposals = findAutocompletions();
    assertEquals(1, proposals.size());
    assertEquals("body", proposals.get(0).getName());

    lineTokens.clear();
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<body"));
    assertEquals(1, findAutocompletions().size());

    lineTokens.clear();
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<body"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, ">"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "</body"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, ">"));
    assertTrue(findAutocompletions().isEmpty());

    lineTokens.clear();
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<"));
    assertEquals(
        HtmlTagsAndAttributes.getInstance().searchTags("").size(), findAutocompletions().size());
  }
View Full Code Here

  /**
   * Tests the autocompletion of self-closing tag.
   */
  public void testAutocompleteSelfClosingTag() {
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<lin"));
    AutocompleteProposals autocompletions = findAutocompletions();
    assertNotNull(autocompletions);
    ProposalWithContext linkProposal = TestUtils.selectProposalByName(autocompletions, "link");
    assertNotNull(linkProposal);
    AutocompleteResult commonResult =
View Full Code Here

  /**
   * Tests full autocompletion for ATTRIBUTE.
   */
  public void testJumpLengthAndFullAutocompletionHtmlAttribute() {
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<body"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    AutocompleteProposals autocompletions = findAutocompletions();
    assertNotNull(autocompletions);
    ProposalWithContext onloadProposal = TestUtils.selectProposalByName(autocompletions, "onload");
    assertNotNull(onloadProposal);
    AutocompleteResult commonResult =
View Full Code Here

  /**
   * Tests full autocompletion for ELEMENT.
   */
  public void testJumpLengthAndFullAutocompletionHtmlElement() {
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<bod"));
    AutocompleteProposals autocompletions = findAutocompletions();
    assertNotNull(autocompletions);
    ProposalWithContext bodyProposal = TestUtils.selectProposalByName(autocompletions, "body");
    assertNotNull(bodyProposal);

View Full Code Here

      tokens.add(JsonCollections.<Token>createArray());
    }
    JsonArray<Token> lineTokens;

    lineTokens = tokens.get(1);
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "first"));

    lineTokens = tokens.get(2);
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "second"));

    lineTokens = tokens.get(3);
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "third"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, ">"));

    codeAnalyzer.onBeforeParse();
    for (int i = 1; i <= 3; i++) {
      codeAnalyzer.onParseLine(lines.get(i - 1), lines.get(i), tokens.get(i));
    }
View Full Code Here

      tokens.add(JsonCollections.<Token>createArray());
    }
    JsonArray<Token> lineTokens;

    lineTokens = tokens.get(1);
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "first"));

    lineTokens = tokens.get(2);
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "second"));

    lineTokens = tokens.get(3);
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "third"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, ">"));

    codeAnalyzer.onBeforeParse();
    for (int i = 1; i <= 3; i++) {
      codeAnalyzer.onParseLine(lines.get(i - 1), lines.get(i), tokens.get(i));
    }
    codeAnalyzer.onAfterParse();

    lineTokens = tokens.get(2);
    lineTokens.clear();
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, "fixed"));

    codeAnalyzer.onBeforeParse();
    for (int i = 2; i <= 3; i++) {
      codeAnalyzer.onParseLine(lines.get(i - 1), lines.get(i), tokens.get(i));
    }
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

    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

TOP

Related Classes of org.eclipse.orion.server.cf.manifest.v2.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.