Package com.google.collide.shared.document

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


  public LineNumberAndColumn getLineNumberAndColumn(int offset) {
    int binarySearchResult = Collections.binarySearch(newlineOffsets, offset);
    int lineNumber = binarySearchResult >= 0 ? binarySearchResult : -(binarySearchResult + 1);
    int offsetOfFirstCharacterOnLine = getOffsetOfPreviousNewline(lineNumber) + 1;
    return new LineNumberAndColumn(lineNumber, offset - offsetOfFirstCharacterOnLine);
  }
View Full Code Here


    NavigableReference result = null;
    if (cubeReferences != null && cubeReferences.getReferences().size() > 0) {
      // TODO: Optimize this search.
      // Seach for reference at position where the cursor would have been if there were
      // no text changes.
      LineNumberAndColumn oldPosition = positionMigrator.migrateFromNow(line, column);
      for (int i = 0; i < cubeReferences.getReferences().size(); i++) {
        CodeReference reference = cubeReferences.getReferences().get(i);
        if (reference.getReferenceStart().getLineNumber() > oldPosition.lineNumber) {
          // We've gone too far, nothing to look further.
          break;
View Full Code Here

   * @return migrated reference or {@code null} if reference cannot be migrated
   */
  private CodeReference migrateCubeReference(CodeReference reference) {
    FilePosition oldStartPosition = reference.getReferenceStart();
    FilePosition oldEndPosition = reference.getReferenceEnd();
    LineNumberAndColumn newStartPosition = positionMigrator.migrateToNow(
        oldStartPosition.getLineNumber(), oldStartPosition.getColumn());
    LineNumberAndColumn newEndPosition = positionMigrator.migrateToNow(
        oldEndPosition.getLineNumber(), oldEndPosition.getColumn());
    int newLength = newEndPosition.column - newStartPosition.column;
    int oldLength = oldEndPosition.getColumn() - oldStartPosition.getColumn();
    if (newStartPosition.lineNumber != newEndPosition.lineNumber
        || newLength != oldLength || newLength < 0) {
View Full Code Here

  private FilePosition migrateFilePositionToNow(FilePosition filePosition) {
    if (!positionMigrator.haveChanges()) {
      return filePosition;
    }
    LineNumberAndColumn newPosition =
        positionMigrator.migrateToNow(filePosition.getLineNumber(), filePosition.getColumn());
    return DtoClientImpls.FilePositionImpl.make()
        .setLineNumber(newPosition.lineNumber)
        .setColumn(newPosition.column);
  }
View Full Code Here

        "0123\n"
      + "56\n"
      + "\n"
      + "9";
    PositionTranslator positionTranslator = new PositionTranslator(src);
    LineNumberAndColumn result = positionTranslator.getLineNumberAndColumn(0);
    assertEquals(0, result.lineNumber);
    assertEquals(0, result.column);

    result = positionTranslator.getLineNumberAndColumn(4);
    assertEquals(0, result.lineNumber);
View Full Code Here

TOP

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

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.