Package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer

Examples of org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifference


      synchronized (fList) {
        for (ListIterator it= fList.listIterator(); it.hasNext();) {
          if (fDifference.equals(it.next())) {
            if (it.hasNext()) {
              RangeDifference next= (RangeDifference) it.next();
              if (next.rightLength() == 0)
                return Math.max(next.leftLength() - next.rightLength(), 0);
            }
            break;
          }
        }
      }
View Full Code Here


    if (getChangeType() == UNCHANGED && fOffset == 0) {
      synchronized (fList) {
        for (ListIterator it= fList.listIterator(fList.size()); it.hasPrevious();) {
          if (fDifference.equals(it.previous())) {
            if (it.hasPrevious()) {
              RangeDifference previous= (RangeDifference) it.previous();
              return Math.max(previous.leftLength() - previous.rightLength(), 0);
            }
            break;
          }
        }
      }
View Full Code Here

   * @param line the line before which the range has to occur
   * @param size the minimal size of the range
   * @return the first range found, or the first range in the differ if none can be found
   */
  private RangeDifference findConsistentRangeBeforeRight(int line, int size) {
    RangeDifference found= null;

    int unchanged= -1; // the number of unchanged lines before line
    for (ListIterator it= fDifferences.listIterator(); it.hasNext();) {
      RangeDifference difference= (RangeDifference) it.next();
      if (found == null)
        found= difference;
      else if (difference.kind() == RangeDifference.NOCHANGE) {
        unchanged= Math.min(line, difference.rightEnd()) - difference.rightStart();
        if (unchanged >= size)
          found= difference;
      }

      if (difference.rightEnd() >= line)
        break;
    }

    return found;
  }
View Full Code Here

   * @param line the line after which the range has to occur
   * @param size the minimal size of the range
   * @return the first range found, or the last range in the differ if none can be found
   */
  private RangeDifference findConsistentRangeAfterRight(int line, int size) {
    RangeDifference found= null;

    int unchanged= -1; // the number of unchanged lines after line
    for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
      RangeDifference difference= (RangeDifference) it.previous();
      if (found == null)
        found= difference;
      else if (difference.kind() == RangeDifference.NOCHANGE) {
        unchanged= difference.rightEnd() - Math.max(line + 1, difference.rightStart()); // + 1 to step over the changed line
        if (unchanged >= size)
          found= difference;
      }

      if (difference.rightStart() <= line)
        break;
    }

    return found;
  }
View Full Code Here

   *
   * @param rightLine the line on the right side
   * @return the corresponding left hand line, or <code>-1</code>
   */
  private int getLeftLine(int rightLine) {
    RangeDifference d= getRangeDifferenceForRightLine(rightLine);
    if (d == null)
      return -1;
    return Math.min(d.leftEnd() - 1, d.leftStart() + rightLine - d.rightStart());
  }
View Full Code Here

   *
   * @param leftLine the line on the left side
   * @return the corresponding right hand line, or <code>-1</code>
   */
  private int getRightLine(int leftLine) {
    RangeDifference d= getRangeDifferenceForLeftLine(leftLine);
    if (d == null)
      return -1;
    return Math.min(d.rightEnd() - 1, d.rightStart() + leftLine - d.leftStart());
  }
View Full Code Here

   * @param leftLine the line on the left side
   * @return the corresponding RangeDifference, or <code>null</code>
   */
  private RangeDifference getRangeDifferenceForLeftLine(int leftLine) {
    for (Iterator it= fDifferences.iterator(); it.hasNext();) {
      RangeDifference d= (RangeDifference) it.next();
      if (leftLine >= d.leftStart() && leftLine < d.leftEnd()) {
        return d;
      }
    }
    return null;
  }
View Full Code Here

   */
  private RangeDifference getRangeDifferenceForRightLine(int rightLine) {
    final List differences= fDifferences;
    synchronized (differences) {
      for (Iterator it= differences.iterator(); it.hasNext();) {
        RangeDifference d= (RangeDifference) it.next();
        if (rightLine >= d.rightStart() && rightLine < d.rightEnd()) {
          return d;
        }
      }
    }
    return null;
View Full Code Here

      public boolean hasNext() {
        return iter.hasNext();
      }

      public Object next() {
        RangeDifference diff= (RangeDifference) iter.next();
        return diff.getDiffRegion(copy, fLeftDocument);
      }

    };
  }
View Full Code Here

  /*
   * @see org.eclipse.jface.text.source.IAnnotationModel#getPosition(org.eclipse.jface.text.source.Annotation)
   */
  public Position getPosition(Annotation annotation) {
    if (fRightDocument != null && annotation instanceof DiffRegion) {
      RangeDifference difference= ((DiffRegion)annotation).getDifference();
      try {
        int offset= fRightDocument.getLineOffset(difference.rightStart());
        return new Position(offset, fRightDocument.getLineOffset(difference.rightEnd() - 1) + fRightDocument.getLineLength(difference.rightEnd() - 1) - offset);
      } catch (BadLocationException e) {
        // ignore and return null;
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifference

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.