Package com.google.collide.codemirror2

Examples of com.google.collide.codemirror2.XmlContext


      return ExplicitAction.DEFAULT;
    }
    JsonArray<Token> tokens = parseResult.getTokens();
    Preconditions.checkNotNull(tokens);
    Preconditions.checkState(tokens.size() > 0);
    CssToken lastToken = (CssToken) tokens.peek();
    if ("{".equals(lastToken.getContext())) {
      return ExplicitAction.DEFAULT;
    }

    // 2) Check we will enter block.
    parseResult = parser.getState(CssState.class, selectionModel.getCursorPosition(), "{");
    if (parseResult == null) {
      return ExplicitAction.DEFAULT;
    }
    tokens = parseResult.getTokens();
    Preconditions.checkNotNull(tokens);
    Preconditions.checkState(tokens.size() > 0);
    lastToken = (CssToken) tokens.peek();
    String context = lastToken.getContext();
    boolean inBlock = context != null && context.endsWith("{");
    if (inBlock && NULL == lastToken.getType()) {
      return new ExplicitAction(
          new DefaultAutocompleteResult(CLASS_SEPARATOR, "", CLASS_JUMPLENGTH));
    }
    return ExplicitAction.DEFAULT;
  }
View Full Code Here


      return JsonCollections.createArray();
    }

    JsonArray<String> result = JsonCollections.createArray();
    JsState jsState = parseResult.getState();
    JsLocalVariable localVariable = jsState.getLocalVariables();
    while (localVariable != null) {
      result.add(localVariable.getName());
      localVariable = localVariable.getNext();
    }
    return result;
  }
View Full Code Here

    if (parseResult == null) {
      return JsonCollections.createArray();
    }

    JsonArray<String> result = JsonCollections.createArray();
    JsState jsState = parseResult.getState();
    JsLocalVariable localVariable = jsState.getLocalVariables();
    while (localVariable != null) {
      result.add(localVariable.getName());
      localVariable = localVariable.getNext();
    }
    return result;
View Full Code Here

    this.path = path;

    documentManager.attachToEditor(document, editor);

    Parser codeMirrorParser = CodeMirror2.getParser(path);
    parser = codeMirrorParser == null ? null
        : DocumentParser.create(document, codeMirrorParser, userActivityManager);

    LanguageHelper languageHelper = LanguageHelperResolver.getHelper(parser.getSyntaxType());
    RootActionExecutor actionExecutor = editor.getInput().getActionExecutor();
View Full Code Here

      parser.teardown();
      parser = null;
    }


    Parser codeMirrorParser = CodeMirror2.getParser(path);
    parser = DocumentParser.create(document, codeMirrorParser, userActivityManager);
    Preconditions.checkNotNull(parser);

    editor.setDocument(document);
    editor.addLineRenderer(diffRenderer);
View Full Code Here

        path, false, new MockIncrementalScheduler(), Document.createEmpty());
  }

  public static DocumentParser createDocumentParser(PathUtil path, boolean setupRealParser,
      IncrementalScheduler scheduler, Document document) {
    Parser parser = setupRealParser ? CodeMirror2.getParser(path)
        : new MockParser(SyntaxType.syntaxTypeByFilePath(path));
    return DocumentParser.create(document, parser, scheduler);
  }
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

   * @param anchorToUpdate the optional anchor that this method will update
   */
  private boolean parseImplCm2(Line line, int lineNumber, int numLinesToProcess,
      @Nullable Anchor anchorToUpdate, ParsedTokensRecipient tokensRecipient) {

    State parserState = loadParserStateForBeginningOfLine(line);
    if (parserState == null) {
      return false;
    }

    Line previousLine = line.getPreviousLine();

    for (int numLinesProcessed = 0; line != null && numLinesProcessed < numLinesToProcess;) {
      State stateToSave = parserState;
      if (line.getText().length() > LINE_LENGTH_LIMIT) {
        // Save the initial state instead of state at the end of line.
        stateToSave = parserState.copy(codeMirrorParser);
      }

View Full Code Here

    parseImplCm2(line, -1, 1, null, tokensRecipient);
    return tokensRecipient.tokens;
  }

  int getIndentation(Line line) {
    State stateBefore = loadParserStateForBeginningOfLine(line);
    String textAfter = line.getText();
    textAfter = textAfter.substring(StringUtils.lengthOfStartingWhitespace(textAfter));
    return codeMirrorParser.indent(stateBefore, textAfter);
  }
View Full Code Here

   *
   * @return copy of corresponding parser state, or {@code null} if the state
   *         if not known yet (previous line wasn't parsed).
   */
  private <T extends State> T loadParserStateForBeginningOfLine(TaggableLine line) {
    State state;
    if (line.isFirstLine()) {
      state = codeMirrorParser.defaultState();
    } else {
      state = line.getPreviousLine().getTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT);
      state = (state == null) ? null : state.copy(codeMirrorParser);
    }

    @SuppressWarnings("unchecked")
    T result = (T) state;
    return result;
View Full Code Here

TOP

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

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.