Tools__TextMergeInfo.st
branchjv
changeset 12202 eaa1f6cb6ce8
parent 12201 283826cb8bcc
child 12203 bcfd4488d8a2
--- a/Tools__TextMergeInfo.st	Tue Mar 20 16:59:54 2012 +0000
+++ b/Tools__TextMergeInfo.st	Wed Mar 21 01:52:35 2012 +0000
@@ -21,7 +21,7 @@
 !
 
 Object subclass:#LineInfo
-	instanceVariableNames:'line resolution conflict'
+	instanceVariableNames:'line resolution conflict offset'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:TextMergeInfo
@@ -54,7 +54,7 @@
 !
 
 text
-    ^list asString
+    ^(list reject:[:l|l isNil]) asString
 
     "Created: / 19-03-2012 / 14:58:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -68,14 +68,9 @@
     list := StringCollection new.
     listInfos := OrderedCollection new.
 
-    text1 isNil ifTrue:[ ^self ].
-    text2 isNil ifTrue:[ ^self ].
-    text2 isNil ifTrue:[ ^self ].
-
-
-    t1c := text1 asStringCollection.
-    t2c := text2 asStringCollection.
-    t3c := text3 asStringCollection.
+    t1c := (text1 ? #()) asStringCollection.
+    t2c := (text2 ? #()) asStringCollection.
+    t3c := (text3 ? #()) asStringCollection.
 
 
     merges := Diff3 new
@@ -93,9 +88,9 @@
             ].
         ].
         merge key == #conflict ifTrue:[
-            merge value length timesRepeat:[
+            1 to: merge value length do:[:i|
                 list add:nil. "/no resolution now"
-                listInfos add: (LineInfo line: lnr resolution: #Conflict conflict: merge value).
+                listInfos add: (LineInfo line: lnr resolution: #Conflict conflict: merge value offset: i).
                 lnr := lnr + 1.
             ].
         ].
@@ -117,7 +112,7 @@
 
         lineInfo := listInfos at: lineNr.
         lineInfo conflict notNil ifTrue:[
-            self list at: lineNr put: (lineInfo conflict left first).
+            self list at: lineNr put: (lineInfo conflict leftAt: lineInfo offset).
             lineInfo resolution: #MergedUsingA.
             changed := true
         ].
@@ -136,7 +131,7 @@
 
         lineInfo := listInfos at: lineNr.
         lineInfo conflict notNil ifTrue:[
-            self list at: lineNr put: (lineInfo conflict right first).
+            self list at: lineNr put: (lineInfo conflict rightAt: lineInfo offset).
             lineInfo resolution: #MergedUsingB.
             changed := true
         ].
@@ -158,7 +153,7 @@
 !TextMergeInfo::LineInfo class methodsFor:'accessing'!
 
 line:lineArg resolution:resolutionArg
-    ^self new line:lineArg resolution:resolutionArg conflict:nil
+    ^self new line:lineArg resolution:resolutionArg conflict:nil offset: nil
 
     "Created: / 19-03-2012 / 15:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
@@ -168,6 +163,14 @@
     ^self new line:lineArg resolution:resolutionArg conflict:conflictArg
 
     "Modified: / 19-03-2012 / 15:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+line:lineArg resolution:resolutionArg conflict:conflictArg offset: offsetArg 
+
+    ^self new line:lineArg resolution:resolutionArg conflict:conflictArg offset: offsetArg
+
+    "Modified: / 19-03-2012 / 15:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 20-03-2012 / 20:42:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !TextMergeInfo::LineInfo methodsFor:'accessing'!
@@ -194,15 +197,22 @@
 !
 
 line:lineArg resolution:resolutionArg
-    self line:lineArg resolution:resolutionArg conflict:nil
+    self line:lineArg resolution:resolutionArg conflict:nil offset: nil
 
     "Created: / 19-03-2012 / 15:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-line:lineArg resolution:resolutionArg conflict:conflictArg 
+line:lineArg resolution:resolutionArg conflict:conflictArg offset: offsetArg
     line := lineArg.
     resolution := resolutionArg.
     conflict := conflictArg.
+    offset := offsetArg
+
+    "Created: / 20-03-2012 / 20:41:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+offset
+    ^ offset
 !
 
 resolution
@@ -273,5 +283,5 @@
 !TextMergeInfo class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: Tools__TextMergeInfo.st 7947 2012-03-20 16:59:54Z vranyj1 $'
+    ^ '$Id: Tools__TextMergeInfo.st 7948 2012-03-21 01:52:35Z vranyj1 $'
 ! !