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