author | convert-repo |
Fri, 06 Jul 2018 03:31:58 +0000 | |
changeset 18262 | 18e456b91b31 |
parent 15723 | 901522438802 |
child 15724 | c2b9162d087d |
permissions | -rw-r--r-- |
15723
901522438802
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15474
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
901522438802
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15474
diff
changeset
|
2 |
|
9978 | 3 |
" |
10074 | 4 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
5 |
All Rights Reserved |
|
9978 | 6 |
|
10074 | 7 |
Permission is hereby granted, free of charge, to any person |
8 |
obtaining a copy of this software and associated documentation |
|
9 |
files (the 'Software'), to deal in the Software without |
|
10 |
restriction, including without limitation the rights to use, |
|
11 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12 |
copies of the Software, and to permit persons to whom the |
|
13 |
Software is furnished to do so, subject to the following |
|
14 |
conditions: |
|
15 |
||
16 |
The above copyright notice and this permission notice shall be |
|
17 |
included in all copies or substantial portions of the Software. |
|
18 |
||
19 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
20 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
21 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
22 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
23 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
24 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
25 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
26 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9978 | 27 |
" |
28 |
"{ Package: 'stx:libtool' }" |
|
29 |
||
30 |
"{ NameSpace: Tools }" |
|
31 |
||
32 |
TwoColumnTextView subclass:#DiffCodeView2 |
|
33 |
instanceVariableNames:'' |
|
34 |
classVariableNames:'' |
|
35 |
poolDictionaries:'' |
|
36 |
category:'Interface-CodeView' |
|
37 |
! |
|
38 |
||
39 |
Object subclass:#DiffData |
|
40 |
instanceVariableNames:'text1 text2 inserted deleted changed' |
|
41 |
classVariableNames:'' |
|
42 |
poolDictionaries:'' |
|
43 |
privateIn:DiffCodeView2 |
|
44 |
! |
|
45 |
||
46 |
!DiffCodeView2 class methodsFor:'documentation'! |
|
47 |
||
48 |
copyright |
|
49 |
" |
|
10074 | 50 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
51 |
All Rights Reserved |
|
52 |
||
53 |
Permission is hereby granted, free of charge, to any person |
|
54 |
obtaining a copy of this software and associated documentation |
|
55 |
files (the 'Software'), to deal in the Software without |
|
56 |
restriction, including without limitation the rights to use, |
|
57 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
58 |
copies of the Software, and to permit persons to whom the |
|
59 |
Software is furnished to do so, subject to the following |
|
60 |
conditions: |
|
9978 | 61 |
|
10074 | 62 |
The above copyright notice and this permission notice shall be |
63 |
included in all copies or substantial portions of the Software. |
|
64 |
||
65 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
66 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
67 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
68 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
69 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
70 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
71 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
72 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9978 | 73 |
" |
74 |
! ! |
|
75 |
||
76 |
!DiffCodeView2 class methodsFor:'defaults'! |
|
77 |
||
78 |
textViewClass |
|
79 |
"return the type of the synced subViews. |
|
80 |
Can be redefined in subclasses" |
|
81 |
||
82 |
^ Tools::CodeView2 |
|
83 |
||
84 |
"Created: / 06-03-2010 / 10:40:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
85 |
! ! |
|
86 |
||
87 |
!DiffCodeView2 methodsFor:'accessing'! |
|
88 |
||
10331 | 89 |
classHolder: aValueModel |
90 |
||
91 |
textViews do:[:each|each classHolder: aValueModel]. |
|
92 |
||
93 |
"Created: / 19-07-2011 / 12:55:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
94 |
! |
|
95 |
||
11707 | 96 |
codeAspect:aSymbol |
14639
457ed8f2bbde
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14370
diff
changeset
|
97 |
"tell the textViews what is shown, so they can adjust their |
457ed8f2bbde
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14370
diff
changeset
|
98 |
syntaxhighlighters. |
457ed8f2bbde
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14370
diff
changeset
|
99 |
See SyntaxHighlighter codeAspectXXX for possible aspects." |
457ed8f2bbde
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14370
diff
changeset
|
100 |
|
457ed8f2bbde
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14370
diff
changeset
|
101 |
textViews do:[:each|each codeAspect:aSymbol]. |
11707 | 102 |
|
103 |
"Created: / 27-07-2012 / 23:24:46 / cg" |
|
104 |
! |
|
105 |
||
10331 | 106 |
languageHolder: aValueModel |
107 |
||
108 |
textViews do:[:each|each languageHolder: aValueModel]. |
|
109 |
||
110 |
"Created: / 19-07-2011 / 12:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111 |
! |
|
112 |
||
13808 | 113 |
modeHolder: aValueModel |
114 |
||
115 |
textViews do:[:each|each modeHolder: aValueModel]. |
|
116 |
||
117 |
"Created: / 26-07-2012 / 19:19:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118 |
! |
|
119 |
||
9978 | 120 |
text1:t1 text2:t2 |
121 |
|data| |
|
122 |
||
123 |
data := self computeDiffDataForText1:t1 text2:t2. |
|
124 |
||
125 |
(textViews at:1) |
|
126 |
contents:(data text1); |
|
127 |
deletedLines:(data deleted); |
|
128 |
changedLines:(data changed); |
|
129 |
insertedLines:#(); |
|
130 |
originDiffText:t1; |
|
131 |
emptyLines:(data inserted). |
|
132 |
||
133 |
(textViews at:2) |
|
134 |
contents:(data text2); |
|
135 |
deletedLines:#(); |
|
136 |
changedLines:(data changed); |
|
137 |
insertedLines:(data inserted); |
|
138 |
originDiffText:t2; |
|
139 |
emptyLines:(data deleted). |
|
140 |
||
141 |
"Created: / 06-03-2010 / 10:45:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
142 |
"Modified: / 22-06-2010 / 21:36:35 / Jakub <zelenja7@fel.cvut.cz>" |
|
143 |
"Modified: / 15-07-2010 / 23:08:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
144 |
! ! |
|
145 |
||
146 |
!DiffCodeView2 methodsFor:'initialization'! |
|
147 |
||
148 |
initialize |
|
149 |
super initialize. |
|
15279
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
150 |
textViews do:[:thisView | |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
151 |
thisView diffMode:true. |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
152 |
thisView ~= textViews first ifTrue:[ |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
153 |
thisView showGutterChannel value:false |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
154 |
]. |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
155 |
textViews do:[:otherView | |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
156 |
thisView == otherView ifFalse:[ |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
157 |
thisView synchronizeWith:otherView |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
158 |
] |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
159 |
] |
e15c49676d90
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
14639
diff
changeset
|
160 |
]. |
9978 | 161 |
|
162 |
"Created: / 06-04-2010 / 14:15:03 / Jakub <zelenja7@fel.cvut.cz>" |
|
163 |
"Modified: / 23-06-2010 / 19:36:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
164 |
! ! |
|
165 |
||
166 |
!DiffCodeView2 methodsFor:'private'! |
|
167 |
||
168 |
computeDiffDataForText1:t1 text2:t2 |
|
11598
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
169 |
"created diffText object from two strings |
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
170 |
This processes the DiffData as returned by the (now internal) Diff-tool" |
9978 | 171 |
|
14370
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
172 |
"/ cg: same code as in Diff2CodeView2!!!!!! |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
173 |
"/ please refactor and make this a utility method on the class side |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
174 |
|
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
175 |
|array1 array2 diff change index1 index2 text1 text2 i |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
176 |
diffData deleted inserted helperText addConstant1 addConstant2 changed helper ins del pom |
15474
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
177 |
array1Size array2Size cr| |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
178 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
179 |
cr := Character cr asString. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
180 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
181 |
"create line arrays from origin text(1 item/row)" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
182 |
array1 := self createArray:t1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
183 |
array2 := self createArray:t2. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
184 |
"inserted,deleted, cahnged lines" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
185 |
inserted := OrderedCollection new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
186 |
deleted := OrderedCollection new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
187 |
changed := OrderedCollection new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
188 |
"indicates which row of origin text is added to ne text" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
189 |
index1 := 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
190 |
index2 := 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
191 |
"indicate how much rows were deleted or inserted " |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
192 |
addConstant1 := 0. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
193 |
addConstant2 := 0. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
194 |
text1 := OrderedCollection new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
195 |
text2 := OrderedCollection new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
196 |
diff := Diff new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
197 |
diff a:array1 b:array2. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
198 |
change := diff diff:false. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
199 |
diffData := DiffData new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
200 |
[ change notNil ] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
201 |
"check first lines which are same" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
202 |
(((change line0) > 0) and:[ ((change line1) > 0) ]) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
203 |
[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
204 |
index1 <= (change line0) |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
205 |
] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
206 |
helperText := (array1 at:index1) asText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
207 |
text1 add: helperText asString. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
208 |
index1 := index1 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
209 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
210 |
[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
211 |
index2 <= (change line1) |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
212 |
] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
213 |
helperText := (array2 at:index2) asText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
214 |
text2 add: helperText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
215 |
index2 := index2 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
216 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
217 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
218 |
ins := change inserted. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
219 |
del := change deleted. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
220 |
index1 := (change line0) + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
221 |
index2 := (change line1) + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
222 |
"find replaced lines " |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
223 |
((del > 0) and:[ ins > 0 ]) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
224 |
helper := del - ins. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
225 |
(helper <= 0) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
226 |
pom := change deleted. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
227 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
228 |
(helper > 0) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
229 |
pom := change inserted. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
230 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
231 |
"its same count row" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
232 |
i := 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
233 |
[ i <= pom ] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
234 |
changed add:index1 + addConstant1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
235 |
text1 add: (array1 at:index1) asString. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
236 |
text2 add: (array2 at:index2) asString. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
237 |
index1 := index1 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
238 |
index2 := index2 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
239 |
del := del - 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
240 |
ins := ins - 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
241 |
i := i + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
242 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
243 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
244 |
"find deleted lines" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
245 |
(del > 0) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
246 |
i := 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
247 |
[ i <= del ] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
248 |
deleted add:index1 + addConstant1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
249 |
text2 add: cr. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
250 |
addConstant2 := addConstant2 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
251 |
text1 add: (array1 at:index1) asString. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
252 |
index1 := index1 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
253 |
i := i + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
254 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
255 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
256 |
"find inserted lines" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
257 |
(ins > 0) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
258 |
i := 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
259 |
[ i <= ins ] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
260 |
inserted add:index2 + addConstant2. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
261 |
text1 add: cr. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
262 |
addConstant1 := addConstant1 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
263 |
text2 add: (array2 at:index2) asString. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
264 |
index2 := index2 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
265 |
i := i + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
266 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
267 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
268 |
change := change nextLink. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
269 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
270 |
"kontrola zda nam nechybi posledni znaky" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
271 |
array1Size := array1 size. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
272 |
(index1 <= array1Size) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
273 |
[ index1 <= array1Size ] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
274 |
helperText := (array1 at:index1) asText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
275 |
text1 add: helperText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
276 |
index1 := index1 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
277 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
278 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
279 |
array2Size := array2 size. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
280 |
(index2 <= array2Size) ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
281 |
[ index2 <= array2Size ] whileTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
282 |
helperText := (array2 at:index2) asText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
283 |
text2 add: helperText. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
284 |
index2 := index2 + 1. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
285 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
286 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
287 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
288 |
1 to:(text1 size min:text2 size) do:[:idx | |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
289 |
|l1 l2| |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
290 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
291 |
l1 := text1 at:idx. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
292 |
l2 := text2 at:idx. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
293 |
l1 = l2 ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
294 |
text1 at:idx put:l1 string. "/ remove color |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
295 |
text2 at:idx put:l2 string. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
296 |
changed remove:idx ifAbsent:[]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
297 |
] ifFalse:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
298 |
l1 withoutSeparators = l2 withoutSeparators ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
299 |
text1 at:idx put:l1 string. "/ remove color |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
300 |
text2 at:idx put:l2 string. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
301 |
changed remove:idx ifAbsent:[]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
302 |
] ifFalse:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
303 |
"/ self halt. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
304 |
] |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
305 |
] |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
306 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
307 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
308 |
diffData text1:(text1 asStringWith:''). |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
309 |
diffData text2:(text2 asStringWith:''). |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
310 |
diffData changed:changed. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
311 |
diffData inserted:inserted. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
312 |
diffData deleted:deleted. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
313 |
^ diffData. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
314 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
315 |
"Modified: / 22-06-2010 / 21:02:50 / Jakub <zelenja7@fel.cvut.cz>" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
316 |
"Modified: / 24-06-2010 / 21:07:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
317 |
"Modified: / 17-07-2012 / 18:55:01 / cg" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
318 |
! |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
319 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
320 |
createArray:text1 |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
321 |
"cg: isn't that an obfuscated variation of #asCollectionOfLines ?" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
322 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
323 |
"/ ^ text1 asStringCollection. "/ yes, it looks like !! |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
324 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
325 |
"/ JV@2012-07-26: Yes, looks like but it is not!! This version |
15723
901522438802
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15474
diff
changeset
|
326 |
"/ keeps CRs in lines. Do not change it back - if you do, DiffCodeView2 |
15474
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
327 |
"/ will show whole source in a single line. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
328 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
329 |
| array src line c | |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
330 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
331 |
array := StringCollection new. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
332 |
src := text1 readStream. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
333 |
line := (String new: 80) writeStream. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
334 |
[ src atEnd ] whileFalse:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
335 |
c := src next. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
336 |
line nextPut: c. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
337 |
c == Character cr ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
338 |
array add: line contents. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
339 |
line reset. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
340 |
] |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
341 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
342 |
line position ~~ 0 ifTrue:[ |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
343 |
array add: line contents |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
344 |
]. |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
345 |
^array |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
346 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
347 |
"Created: / 22-03-2010 / 14:48:27 / Jakub <zelenja7@fel.cvut.cz>" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
348 |
"Modified: / 17-07-2012 / 18:55:21 / cg" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
349 |
"Modified (comment): / 26-07-2012 / 21:45:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
350 |
! |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
351 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
352 |
old_computeDiffDataForText1:t1 text2:t2 |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
353 |
"created diffText object from two strings |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
354 |
This processes the DiffData as returned by the (now internal) Diff-tool" |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
355 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
356 |
"/ cg: same code as in Diff2CodeView2!!!!!! |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
357 |
"/ please refactor and make this a utility method on the class side |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
358 |
|
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
359 |
|array1 array2 diff change index1 index2 text1 text2 i |
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
360 |
diffData deleted inserted helperText addConstant1 addConstant2 changed helper ins del pom |
14370
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
361 |
array1Size array2Size| |
9978 | 362 |
|
11598
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
363 |
"create line arrays from origin text(1 item/row)" |
9978 | 364 |
array1 := self createArray:t1. |
365 |
array2 := self createArray:t2. |
|
366 |
"inserted,deleted, cahnged lines" |
|
367 |
inserted := OrderedCollection new. |
|
368 |
deleted := OrderedCollection new. |
|
369 |
changed := OrderedCollection new. |
|
370 |
"indicates which row of origin text is added to ne text" |
|
371 |
index1 := 1. |
|
372 |
index2 := 1. |
|
373 |
"indicate how much rows were deleted or inserted " |
|
374 |
addConstant1 := 0. |
|
375 |
addConstant2 := 0. |
|
376 |
text1 := ''. |
|
377 |
text2 := ''. |
|
378 |
diff := Diff new. |
|
379 |
diff a:array1 b:array2. |
|
380 |
change := diff diff:false. |
|
11598
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
381 |
diffData := DiffData new. |
9978 | 382 |
[ change notNil ] whileTrue:[ |
383 |
"check first lines which are same" |
|
384 |
(((change line0) > 0) and:[ ((change line1) > 0) ]) ifTrue:[ |
|
385 |
[ |
|
386 |
index1 <= (change line0) |
|
387 |
] whileTrue:[ |
|
388 |
helperText := (array1 at:index1) asText. |
|
389 |
text1 := text1 asString , helperText asString. |
|
390 |
index1 := index1 + 1. |
|
391 |
]. |
|
392 |
[ |
|
393 |
index2 <= (change line1) |
|
394 |
] whileTrue:[ |
|
395 |
helperText := (array2 at:index2) asText. |
|
396 |
text2 := text2 , helperText. |
|
397 |
index2 := index2 + 1. |
|
398 |
]. |
|
399 |
]. |
|
400 |
ins := change inserted. |
|
401 |
del := change deleted. |
|
402 |
index1 := (change line0) + 1. |
|
403 |
index2 := (change line1) + 1. |
|
15474
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
404 |
"find replaced lines " |
9978 | 405 |
((del > 0) and:[ ins > 0 ]) ifTrue:[ |
406 |
helper := del - ins. |
|
407 |
(helper <= 0) ifTrue:[ |
|
408 |
pom := change deleted. |
|
409 |
]. |
|
410 |
(helper > 0) ifTrue:[ |
|
411 |
pom := change inserted. |
|
412 |
]. |
|
413 |
"its same count row" |
|
414 |
i := 1. |
|
415 |
[ i <= pom ] whileTrue:[ |
|
416 |
changed add:index1 + addConstant1. |
|
417 |
text1 := text1 , (array1 at:index1) asString. |
|
418 |
text2 := text2 , (array2 at:index2) asString. |
|
419 |
index1 := index1 + 1. |
|
420 |
index2 := index2 + 1. |
|
421 |
del := del - 1. |
|
422 |
ins := ins - 1. |
|
423 |
i := i + 1. |
|
424 |
]. |
|
425 |
]. |
|
15474
9d8648afebd3
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15279
diff
changeset
|
426 |
"find deleted lines" |
9978 | 427 |
(del > 0) ifTrue:[ |
428 |
i := 1. |
|
429 |
[ i <= del ] whileTrue:[ |
|
430 |
deleted add:index1 + addConstant1. |
|
431 |
text2 := text2 , Character cr. |
|
432 |
addConstant2 := addConstant2 + 1. |
|
433 |
text1 := text1 , (array1 at:index1) asString. |
|
434 |
index1 := index1 + 1. |
|
435 |
i := i + 1. |
|
436 |
]. |
|
437 |
]. |
|
438 |
"find inserted lines" |
|
439 |
(ins > 0) ifTrue:[ |
|
440 |
i := 1. |
|
441 |
[ i <= ins ] whileTrue:[ |
|
442 |
inserted add:index2 + addConstant2. |
|
443 |
text1 := text1 , Character cr. |
|
444 |
addConstant1 := addConstant1 + 1. |
|
445 |
text2 := text2 , (array2 at:index2) asString. |
|
446 |
index2 := index2 + 1. |
|
447 |
i := i + 1. |
|
448 |
]. |
|
449 |
]. |
|
450 |
change := change nextLink. |
|
451 |
]. |
|
452 |
"kontrola zda nam nechybi posledni znaky" |
|
14370
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
453 |
array1Size := array1 size. |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
454 |
(index1 <= array1Size) ifTrue:[ |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
455 |
[ index1 <= array1Size ] whileTrue:[ |
9978 | 456 |
helperText := (array1 at:index1) asText. |
457 |
text1 := text1 , helperText. |
|
458 |
index1 := index1 + 1. |
|
459 |
]. |
|
460 |
]. |
|
14370
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
461 |
array2Size := array2 size. |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
462 |
(index2 <= array2Size) ifTrue:[ |
bb3f3eec9f1b
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
13808
diff
changeset
|
463 |
[ index2 <= array2Size ] whileTrue:[ |
9978 | 464 |
helperText := (array2 at:index2) asText. |
465 |
text2 := text2 , helperText. |
|
466 |
index2 := index2 + 1. |
|
467 |
]. |
|
468 |
]. |
|
11598
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
469 |
diffData text1:text1. |
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
470 |
diffData text2:text2. |
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
471 |
diffData changed:changed. |
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
472 |
diffData inserted:inserted. |
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
473 |
diffData deleted:deleted. |
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
474 |
^ diffData. |
9978 | 475 |
|
476 |
"Modified: / 22-06-2010 / 21:02:50 / Jakub <zelenja7@fel.cvut.cz>" |
|
477 |
"Modified: / 24-06-2010 / 21:07:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11598
0350a5f84be7
comment/format in: #computeDiffDataForText1:text2:
Claus Gittinger <cg@exept.de>
parents:
10331
diff
changeset
|
478 |
"Modified: / 17-07-2012 / 18:55:01 / cg" |
9978 | 479 |
! ! |
480 |
||
481 |
!DiffCodeView2::DiffData methodsFor:'accessing'! |
|
482 |
||
483 |
changed |
|
484 |
||
485 |
^changed copy |
|
486 |
||
487 |
"Modified: / 02-05-2010 / 19:31:18 / Jakub <zelenja7@fel.cvut.cz>" |
|
488 |
"Modified: / 16-07-2010 / 09:35:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
489 |
! |
|
490 |
||
491 |
changed:something |
|
492 |
changed := something. |
|
493 |
! |
|
494 |
||
495 |
deleted |
|
496 |
^ deleted |
|
497 |
! |
|
498 |
||
499 |
deleted:something |
|
500 |
deleted := something. |
|
501 |
! |
|
502 |
||
503 |
inserted |
|
504 |
^ inserted |
|
505 |
! |
|
506 |
||
507 |
inserted:something |
|
508 |
inserted := something. |
|
509 |
! |
|
510 |
||
511 |
text1 |
|
512 |
^ text1 |
|
513 |
! |
|
514 |
||
515 |
text1:something |
|
516 |
text1 := something. |
|
517 |
! |
|
518 |
||
519 |
text2 |
|
520 |
^ text2 |
|
521 |
! |
|
522 |
||
523 |
text2:something |
|
524 |
text2 := something. |
|
525 |
! ! |
|
526 |
||
527 |
!DiffCodeView2 class methodsFor:'documentation'! |
|
528 |
||
529 |
version_CVS |
|
15723
901522438802
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15474
diff
changeset
|
530 |
^ '$Header$' |
9978 | 531 |
! |
532 |
||
533 |
version_SVN |
|
15723
901522438802
class: Tools::DiffCodeView2
Claus Gittinger <cg@exept.de>
parents:
15474
diff
changeset
|
534 |
^ '$Id$' |
9978 | 535 |
! ! |
13808 | 536 |