Package com.google.collide.codemirror2

Examples of com.google.collide.codemirror2.Token


      tail = lineText.substring(LINE_LENGTH_LIMIT);
      lineText = lineText.substring(0, LINE_LENGTH_LIMIT);
    }

    try {
      Stream stream = codeMirrorParser.createStream(lineText);
      JsonArray<Token> tokens = JsonCollections.createArray();
      while (!stream.isEnd()) {
        codeMirrorParser.parseNext(stream, parserState, tokens);
      }

      if (tail != null) {
        tokens.add(new Token(codeMirrorParser.getName(parserState), TokenType.ERROR, tail));
View Full Code Here


    model.cleanup();
  }

  public void onDocumentChanged(DocumentParser parser) {
    model.cleanup();
    SyntaxType syntax = (parser != null) ? parser.getSyntaxType() : SyntaxType.NONE;

    boolean oldAcceptCubeUpdates = acceptCubeUpdates;
    if (currentOutlineParser != null) {
      currentOutlineParser.cleanup();
      currentOutlineParser = null;
View Full Code Here

    JsonStringMap<CodeBlock> codeBlockMap = codeGraph.getCodeBlockMap();
    JsonArray<String> keys = codeBlockMap.getKeys();
    for (int i = 0; i < keys.size(); i++) {
      String key = keys.get(i);
      CodeBlock fileCodeBlock = codeBlockMap.get(key);
      SyntaxType fileMode = SyntaxType.syntaxTypeByFileName(fileCodeBlock.getName());
      if (mode.equals(fileMode)) {
        FileIndex fileIndex = new FileIndex(fileCodeBlock, new PathUtil(fileCodeBlock.getName()));
        fileIdToData.put(fileCodeBlock.getId(), fileIndex);

        String filePath = fileIndex.path.getPathString();
View Full Code Here

  }

  public void testAutocompletionMode() {
    Autocompleter autocompleter = helper.setup(path, "", 0, 0, false);

    SyntaxType mode = SyntaxType.NONE;
    assertTrue(autocompleter.getAutocompleter(mode) instanceof  NoneAutocompleter);

    mode = SyntaxType.YAML;
    assertTrue(autocompleter.getAutocompleter(mode) instanceof  NoneAutocompleter);
View Full Code Here

  }

  public void testAllSyntaxTypesResolvable() {
    SyntaxType[] types = SyntaxType.values();
    for (int i = 0, l = types.length; i < l; i++) {
      SyntaxType syntaxType = types[i];
      try {
        LanguageHelperResolver.getHelper(syntaxType);
      } catch (Exception ex) {
        fail("Can't obtain helper for " + syntaxType);
      }
View Full Code Here

    boolean inAttribute = false;
    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)) {
          inAttribute = false;
View Full Code Here

        && "a".equalsIgnoreCase(parserState.getState().getContext().getTagName())) {
      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)) {
          inAnchorTag = false;
View Full Code Here

    @Override
    public CompletionContext<State> buildContext(
        SelectionModel selection, DocumentParser parser) {
      JsonArray<Token> tokens = JsonCollections.createArray();
      State state = TestUtils.createMockState();
      tokens.add(new Token(null, NULL, ""));
      ParseResult<State> parseResult = new ParseResult<State>(tokens, state) {};
      return buildContext(
          new ParseUtils.ExtendedParseResult<State>(parseResult, ParseUtils.Context.IN_CODE));
    }
View Full Code Here

    Document document = Document.createFromString(text);
    Line line = document.getFirstLine();
    TaggableLine previousLine;

    JsonArray<Token> tokens1 = JsonCollections.createArray();
    tokens1.add(new Token(mode, TokenType.KEYWORD, "function"));
    tokens1.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens1.add(new Token(mode, TokenType.VARIABLE, "a"));
    tokens1.add(new Token(mode, TokenType.NULL, "("));
    tokens1.add(new Token(mode, TokenType.VARIABLE, "b"));
    tokens1.add(new Token(mode, TokenType.NULL, ","));
    tokens1.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens1.add(new Token(mode, TokenType.VARIABLE, "c"));
    tokens1.add(new Token(mode, TokenType.NULL, ")"));
    tokens1.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens1.add(new Token(mode, TokenType.NULL, "{"));
    tokens1.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsonArray<Token> tokens2 = JsonCollections.createArray();
    tokens2.add(new Token(mode, TokenType.WHITESPACE, "  "));
    tokens2.add(new Token(mode, TokenType.VARIABLE, "d"));
    tokens2.add(new Token(mode, TokenType.NULL, "."));
    tokens2.add(new Token(mode, TokenType.VARIABLE, "prototype"));
    tokens2.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens2.add(new Token(mode, TokenType.NULL, "="));
    tokens2.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens2.add(new Token(mode, TokenType.KEYWORD, "function"));
    tokens2.add(new Token(mode, TokenType.NULL, "("));
    tokens2.add(new Token(mode, TokenType.NULL, ")"));
    tokens2.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens2.add(new Token(mode, TokenType.NULL, "{"));
    tokens2.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsonArray<Token> tokens3 = JsonCollections.createArray();
    tokens3.add(new Token(mode, TokenType.WHITESPACE, "  "));
    tokens3.add(new Token(mode, TokenType.NULL, "}"));
    tokens3.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsonArray<Token> tokens4 = JsonCollections.createArray();
    tokens4.add(new Token(mode, TokenType.NULL, "}"));
    tokens4.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsonArray<Token> tokens5 = JsonCollections.createArray();
    tokens5.add(new Token(mode, TokenType.KEYWORD, "var"));
    tokens5.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens5.add(new Token(mode, TokenType.DEF, "e"));
    tokens5.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens5.add(new Token(mode, TokenType.NULL, "="));
    tokens5.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens5.add(new Token(mode, TokenType.NULL, "{"));
    tokens5.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsonArray<Token> tokens6 = JsonCollections.createArray();
    tokens6.add(new Token(mode, TokenType.WHITESPACE, "  "));
    tokens6.add(new Token(mode, TokenType.PROPERTY, "f"));
    tokens6.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens6.add(new Token(mode, TokenType.NULL, ":"));
    tokens6.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens6.add(new Token(mode, TokenType.KEYWORD, "function"));
    tokens6.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens6.add(new Token(mode, TokenType.NULL, "("));
    tokens6.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens6.add(new Token(mode, TokenType.NULL, ")"));
    tokens6.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens6.add(new Token(mode, TokenType.NULL, "{"));
    tokens6.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsonArray<Token> tokens7 = JsonCollections.createArray();
    tokens7.add(new Token(mode, TokenType.WHITESPACE, "  "));
    tokens7.add(new Token(mode, TokenType.VARIABLE, "callMyFunctionWithCallback"));
    tokens7.add(new Token(mode, TokenType.NULL, "("));
    tokens7.add(new Token(mode, TokenType.KEYWORD, "function"));
    tokens7.add(new Token(mode, TokenType.NULL, "("));
    tokens7.add(new Token(mode, TokenType.COMMENT, "/* Knock-knock! */"));
    tokens7.add(new Token(mode, TokenType.NULL, ")"));
    tokens7.add(new Token(mode, TokenType.WHITESPACE, " "));
    tokens7.add(new Token(mode, TokenType.NULL, "{"));
    tokens7.add(new Token(mode, TokenType.NEWLINE, "\n"));

    JsIndexUpdater indexUpdater = new JsIndexUpdater();
    indexUpdater.onBeforeParse();

    previousLine = TaggableLineUtil.getPreviousLine(line);
View Full Code Here

        value = result.getGroup(4);
        type = WHITESPACE;
      } else {
        throw new IllegalArgumentException("Can't parse: " + result.getGroup(1));
      }
      tokens.add(new Token("test", type, value));
      text = text.substring(value.length());
    }
    ParseResult<State> parseResult = new ParseResult<State>(tokens, TestUtils.createMockState());
    return new ParseUtils.ExtendedParseResult<State>(parseResult, ParseUtils.Context.IN_CODE);
  }
View Full Code Here

TOP

Related Classes of com.google.collide.codemirror2.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.