File tree Expand file tree Collapse file tree
src/main/java/org/variantsync/diffdetective/diff/difftree Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -693,10 +693,19 @@ public boolean isMacro() {
693693
694694 /**
695695 * @return An integer that uniquely identifiers this DiffNode within its patch.
696+ *
697+ * From the returned id a new node with all essential attributes reconstructed can be obtained
698+ * by using {@code fromID}.
699+ *
700+ * Note that only {@code 26} bits of the line number are encoded, so if the line number is bigger than
701+ * {@code 2^26} this id will no longer be unique.
696702 */
697703 public int getID () {
704+ int lineNumber = 1 + from .inDiff ;
705+ Assert .assertTrue ((lineNumber << 2 *ID_OFFSET ) >> 2 *ID_OFFSET == lineNumber );
706+
698707 int id ;
699- id = 1 + from . inDiff ;
708+ id = lineNumber ;
700709 id <<= ID_OFFSET ;
701710 id += diffType .ordinal ();
702711 id <<= ID_OFFSET ;
@@ -705,7 +714,6 @@ public int getID() {
705714 }
706715
707716 public static DiffNode fromID (final int id , String label ) {
708- // lowest 8 bits
709717 final int lowestBitsMask = (1 << ID_OFFSET ) - 1 ;
710718
711719 final int codeTypeOrdinal = id & lowestBitsMask ;
You can’t perform that action at this time.
0 commit comments