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

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


    JsCodeScope scope = context.scope;

    int size = tokens.size();
    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.
        continue;
      }

      String tokenValue = token.getValue();

      switch (state) {
        case NONE:
          if (isFunctionKeyword(tokenType, tokenValue)) {
            state = State.FUNCTION;
View Full Code Here


    int indent = 0;
    int n = tokens.size();
    int i = 0;
    if (n > 0) {
      Token token = tokens.get(i);
      if (TokenType.WHITESPACE == token.getType()) {
        i++;
        indent = token.getValue().length();
      }
      if (n >= i + 3
          && TokenType.KEYWORD == tokens.get(i).getType()
          && TokenType.WHITESPACE == tokens.get(i + 1).getType()
          && TokenType.VARIABLE == tokens.get(i + 2).getType()) {
View Full Code Here

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

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

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

    codeAnalyzer.onBeforeParse();
    for (int i = 1; i <= 2; 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));
    }
View Full Code Here

   * Tests attributes proposals.
   */
  public void testHtmlAttributes() {
    HtmlTagsAndAttributes htmlAttributes = HtmlTagsAndAttributes.getInstance();

    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    AutocompleteProposals proposals = findAutocompletions();

    assertEquals(htmlAttributes.searchAttributes("html", new SimpleStringBag(), "").size(),
        proposals.size());
    assertEquals("accesskey", proposals.get(0).getName());
View Full Code Here

    SimpleStringBag excluded = new SimpleStringBag();
    assertEquals(1, htmlAttributes.searchAttributes("html", excluded, sampleAttribute).size());
    excluded.add(sampleAttribute);

    JsonArray<Token> tokens1 = JsonCollections.createArray();
    tokens1.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    tokens1.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    String line1 = tokensToText(tokens1);
    parsedLines.put(line1, tokens1);

    JsonArray<Token> tokens2 = JsonCollections.createArray();
    tokens2.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, sampleAttribute));
    tokens2.add(new Token(CodeMirror2.HTML, TokenType.TAG, ">"));
    String line2 = tokensToText(tokens2);
    parsedLines.put(line2, tokens2);

    String text = line1 + "\n" + line2 + "\n";
    helper.setup(path, text, 0, line1.length(), false);
View Full Code Here

  /**
   * Tests that {@link HtmlAutocompleter#getModeForColumn} gets the mode from
   * the anchor set prior to the given column.
   */
  public void testGetModeForColumn() {
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));

    prepareAutocompleter();

    Document document = helper.editor.getDocument();
    AnchorManager anchorManager = document.getAnchorManager();
View Full Code Here

  /**
   * Tests {@link HtmlAutocompleter#putModeAnchors}.
   */
  public void testPutModeAnchors() {
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));

    prepareAutocompleter();

    Document document = helper.editor.getDocument();
    Line line = document.getFirstLine();
View Full Code Here

    SimpleStringBag excluded = new SimpleStringBag();
    assertEquals(1, htmlAttributes.searchAttributes("html", excluded, sampleAttribute).size());
    excluded.add(sampleAttribute);

    JsonArray<Token> tokens1 = JsonCollections.createArray();
    tokens1.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    tokens1.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    String line1 = tokensToText(tokens1);
    parsedLines.put(line1, tokens1);

    JsonArray<Token> tokens2 = JsonCollections.createArray();
    tokens2.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, sampleAttribute));
    String line2 = tokensToText(tokens2);
    parsedLines.put(line2, tokens2);

    JsonArray<Token> tokens3 = JsonCollections.createArray();
    tokens3.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
    String line3 = tokensToText(tokens3);
    parsedLines.put(line3, tokens3);

    String text = line1 + "\n" + line2 + "\n ";
    helper.setup(path, text, 0, line1.length(), false);
View Full Code Here

  /**
   * Tests that find autocompletions do not ruin existing "clean" results.
   */
  public void testFindDoNotRuinResults() {
    String id = "id";
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.TAG, "<html"));
    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));

    prepareAutocompleter();
    HtmlTagWithAttributes before = helper.editor.getDocument().getFirstLine().getTag(
        XmlCodeAnalyzer.TAG_END_TAG);
    assertNotNull(before);

    lineTokens.add(new Token(CodeMirror2.HTML, TokenType.ATTRIBUTE, id));
    helper.autocompleter.htmlAutocompleter.findAutocompletions(
        helper.editor.getSelection(), CTRL_SPACE);
    HtmlTagWithAttributes after = helper.editor.getDocument().getFirstLine().getTag(
        XmlCodeAnalyzer.TAG_END_TAG);

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.