2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.textmanipulation;
7 import java.util.Comparator;
11 * A special comparator to comapre <code>TextRange</code>s.
13 /* package */ class TextEditNodeComparator implements Comparator {
14 public int compare(Object o1, Object o2) {
15 TextEditNode node1= (TextEditNode)o1;
16 TextEditNode node2= (TextEditNode)o2;
17 TextRange pos1= node1.getTextRange();
18 TextRange pos2= node2.getTextRange();
20 int offset1= pos1.fOffset;
21 int offset2= pos2.fOffset;
22 if (offset1 < offset2)
24 if (offset1 > offset2)
28 int length1= pos1.fLength;
29 int length2= pos2.fLength;
31 // insertion points come before anything else at the same position.
32 if (length1 == 0 && length2 != 0)
34 if (length1 != 0 && length2 == 0)
37 // Longer edits come before shorter edits
38 if (length1 < length2)
40 if (length1 > length2)
43 if (node1.fEdit.index < node2.fEdit.index)