Package com.google.collide.shared.document

Examples of com.google.collide.shared.document.Position


      PositionUtils.visit(dirtyMarkingLineVisitor, visibleRange[0], visibleRange[1]);
    }
  }

  private Position[] getViewportRange() {
    return new Position[] {new Position(viewport.getTop(), 0),
        new Position(viewport.getBottom(), viewport.getBottomLine().getText().length() - 1)};
  }
View Full Code Here


  private void splitLine(Editor editor) {
    // TODO: Add language specific logic (i.e. string splitting).
    SelectionModel selection = editor.getSelection();
    Position[] selectionRange = selection.getSelectionRange(false);
    Position cursor = selectionRange[0];

    editor.getEditorDocumentMutator().insertText(cursor.getLine(), cursor.getLineNumber(),
        cursor.getColumn(), "\n", true);
    selection.setCursorPosition(cursor.getLineInfo(), cursor.getColumn());
  }
View Full Code Here

    Position[] selectionRange = selection.getSelectionRange(false);
    boolean selectionChanged = false;

    // 1) New beginning of selection based on suffix-matching and
    //    backspaceCount
    Position selectionStart = selectionRange[0];
    int selectionStartColumn = selectionStart.getColumn();
    String textBefore = selectionStart.getLine().getText().substring(0, selectionStartColumn);
    if (!textBefore.endsWith(preContentSuffix)) {
      Log.warn(getClass(),
          "expected suffix [" + preContentSuffix + "] do not match [" + textBefore + "]");
      return;
    }
    int matchCount = preContentSuffix.length();

    int leftOffset = backspaceCount + matchCount;
    if (leftOffset > 0) {
      selectionStart = getPosition(selectionStart, -leftOffset);
      selectionChanged = true;
    }

    // 2) Calculate end of selection
    Position selectionEnd = selectionRange[1];
    if (deleteCount > 0) {
      selectionEnd = getPosition(selectionEnd, deleteCount);
      selectionChanged = true;
    }

    // 3) Set selection it was changed.
    if (selectionChanged) {
      selection.setSelection(selectionStart.getLineInfo(), selectionStart.getColumn(),
          selectionEnd.getLineInfo(), selectionEnd.getColumn());
    }

    // 4) Replace selection
    EditorDocumentMutator mutator = editor.getEditorDocumentMutator();
    if (selection.hasSelection() || autocompletionText.length() > 0) {
      mutator.insertText(selectionStart.getLine(), selectionStart.getLineNumber(),
          selectionStart.getColumn(), autocompletionText);
    }

    // 5) Move cursor / set final selection
    selectionEnd = getPosition(selectionStart, jumpLength);
    if (selectionCount == 0) {
      selection.setCursorPosition(selectionEnd.getLineInfo(), selectionEnd.getColumn());
    } else {
      selectionStart = getPosition(selectionStart, jumpLength - selectionCount);
      selection.setSelection(selectionStart.getLineInfo(), selectionStart.getColumn(),
          selectionEnd.getLineInfo(), selectionEnd.getColumn());
    }
  }
View Full Code Here

      return result;
    }

    // Use the parser information to determine if we are inside a comment
    // or a string or any other place that does not make sense to evaluate.
    Position endPosition = new Position(lineInfo, result.getEndColumn() + 1);
    ParseResult<JsState> parseResult = parser.getState(JsState.class, endPosition, null);
    if (parseResult == null) {
      return result;
    }
View Full Code Here

        texts.add((String) alternatingPositionOperationAndText[i++]);
      }
    }

    private Position createPosition(int lineNumber, int column) {
      return new Position(doc.getLineFinder().findLine(lineNumber), column);
    }
View Full Code Here

  }

  @Override
  public ExplicitAction getExplicitAction(SelectionModel selectionModel,
      SignalEventEssence signal, boolean popupIsShown) {
    Position cursor = selectionModel.getCursorPosition();
    int cursorColumn = cursor.getColumn();
    Line cursorLine = cursor.getLine();
    String mode = getModeForColumn(cursorLine, cursorColumn);

    if (cssAutocompleter != null && CodeMirror2.CSS.equals(mode)) {
      return cssAutocompleter.getExplicitAction(selectionModel, signal, popupIsShown);
    } else if (jsAutocompleter != null && CodeMirror2.JAVASCRIPT.equals(mode)) {
View Full Code Here

  @Override
  public AutocompleteProposals findAutocompletions(
      SelectionModel selection, SignalEventEssence trigger) {
    resetDirtyScope();

    Position cursor = selection.getCursorPosition();
    final Line line = cursor.getLine();
    final int column = cursor.getColumn();

    DocumentParser parser = getParser();
    JsonArray<Token> tokens = parser.parseLineSync(line);
    if (tokens == null) {
      // This line has never been parsed yet. No variants.
      return AutocompleteProposals.EMPTY;
    }

    // We do not ruin parse results for "clean" lines.
    if (parser.isLineDirty(cursor.getLineNumber())) {
      // But "processing" of "dirty" line is harmless.
      XmlCodeAnalyzer.processLine(TaggableLineUtil.getPreviousLine(line), line, tokens);
    }
    String initialMode = parser.getInitialMode(line);
    JsonArray<Pair<Integer, String>> modes = TokenUtil.buildModes(initialMode, tokens);
View Full Code Here

  private ExplicitAction getExplicitBackspaceAutocompletion(
      SelectionModel selection, @Nonnull DocumentParser parser) {
    if (selection.hasSelection()) {
      return ExplicitAction.DEFAULT;
    }
    Position cursor = selection.getCursorPosition();

    String textToCursor = leftTrimmedLineTextBeforePosition(cursor);
    String textAfterCursor = textAfterPosition(cursor);

    ParseUtils.ExtendedParseResult<State> extendedParseResult = ParseUtils
View Full Code Here

TOP

Related Classes of com.google.collide.shared.document.Position

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.