Package com.google.collide.codemirror2

Examples of com.google.collide.codemirror2.Parser


   *
   * @see #loadParserStateForBeginningOfLine
   */
  @Nullable
  String getInitialMode(@Nonnull TaggableLine line) {
    State state = loadParserStateForBeginningOfLine(line);
    if (state == null) {
      return null;
    }
    return codeMirrorParser.getName(state);
  }
View Full Code Here


    }
    return codeMirrorParser.getName(state);
  }

  private void saveEndOfLineParserState(Line line, State parserState) {
    State copiedParserState = parserState.copy(codeMirrorParser);
    line.putTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT, copiedParserState);
  }
View Full Code Here

      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

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.