0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
45
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
73
|
13 |
'From Smalltalk/X, Version:2.10.4 on 26-feb-1995 at 5:18:24 am'!
|
45
|
14 |
|
0
|
15 |
StandardSystemView subclass:#ChangesBrowser
|
45
|
16 |
instanceVariableNames:'changeListView codeView changeFileName changeChunks
|
|
17 |
changePositions changeClassNames changeHeaderLines anyChanges
|
51
|
18 |
changeNrShown changeNrProcessed skipSignal'
|
58
|
19 |
classVariableNames:'CompressSnapshotInfo'
|
45
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Browsers'
|
0
|
22 |
!
|
|
23 |
|
|
24 |
ChangesBrowser comment:'
|
4
|
25 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
45
|
26 |
All Rights Reserved
|
0
|
27 |
|
73
|
28 |
$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.25 1995-02-28 21:54:57 claus Exp $
|
29
|
29 |
'!
|
|
30 |
|
|
31 |
!ChangesBrowser class methodsFor:'documentation'!
|
|
32 |
|
|
33 |
copyright
|
|
34 |
"
|
|
35 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
45
|
36 |
All Rights Reserved
|
0
|
37 |
|
29
|
38 |
This software is furnished under a license and may be used
|
|
39 |
only in accordance with the terms of that license and with the
|
|
40 |
inclusion of the above copyright notice. This software may not
|
|
41 |
be provided or otherwise made available to, or used by, any
|
|
42 |
other person. No title to or ownership of the software is
|
|
43 |
hereby transferred.
|
|
44 |
"
|
|
45 |
!
|
|
46 |
|
|
47 |
version
|
|
48 |
"
|
73
|
49 |
$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.25 1995-02-28 21:54:57 claus Exp $
|
31
|
50 |
"
|
29
|
51 |
!
|
|
52 |
|
|
53 |
documentation
|
|
54 |
"
|
|
55 |
this implements a browser for the changes-file.
|
|
56 |
See the extra document 'doc/misc/cbrowser.doc' for how to use this browser.
|
|
57 |
|
|
58 |
written jan 90 by claus
|
51
|
59 |
|
58
|
60 |
Class variables:
|
|
61 |
CompressSnapshotInfo if true (the default), snapshot entries
|
|
62 |
are also compressed in the compress function.
|
|
63 |
Some users prefer them to be not compressed.
|
|
64 |
Set it to false for this.
|
|
65 |
|
51
|
66 |
Notice:
|
|
67 |
this needs a total rewrite, to build up a changeSet from the file
|
|
68 |
(which did not exist when the ChangesBrowser was written) and
|
|
69 |
manipulate that changeSet.
|
58
|
70 |
This way, we get a browser for any upcoming incore changeSets for
|
|
71 |
free. Also, this will put the chunk analyzation code into Change and
|
|
72 |
subclasses (where it belongs) and give a better encapsulation and
|
|
73 |
overall structure. Do not take this as an example for good style ;-)
|
29
|
74 |
"
|
|
75 |
! !
|
0
|
76 |
|
45
|
77 |
!ChangesBrowser class methodsFor:'instance creation'!
|
|
78 |
|
|
79 |
new
|
|
80 |
"create a new changes browser"
|
|
81 |
|
|
82 |
^ super label:'Changes Browser'
|
|
83 |
icon:(Form fromFile:'CBrowser.xbm' resolution:100)
|
|
84 |
!
|
|
85 |
|
|
86 |
openOn:aFileName
|
|
87 |
"create c changes browser on a change file"
|
|
88 |
|
49
|
89 |
^ ((self new label:'Changes Browser: ', aFileName) changeFileName:aFileName) open
|
45
|
90 |
! !
|
|
91 |
|
0
|
92 |
!ChangesBrowser class methodsFor:'behavior'!
|
|
93 |
|
|
94 |
autoSelectNext
|
|
95 |
"returning true here, makes a Delete operation automatically
|
|
96 |
select the next change"
|
|
97 |
|
|
98 |
^ true
|
|
99 |
! !
|
|
100 |
|
73
|
101 |
!ChangesBrowser class methodsFor:'defaults'!
|
0
|
102 |
|
73
|
103 |
defaultLabel
|
|
104 |
^ 'Changes Browser'
|
28
|
105 |
! !
|
|
106 |
|
0
|
107 |
!ChangesBrowser methodsFor:'private'!
|
|
108 |
|
|
109 |
streamForChange:changeNr
|
|
110 |
"answer a stream for change"
|
|
111 |
|
|
112 |
|aStream|
|
|
113 |
|
56
|
114 |
(changeNr between:1 and:changePositions size) ifFalse:[^ nil].
|
0
|
115 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
116 |
aStream isNil ifTrue:[^ nil].
|
|
117 |
aStream position:(changePositions at:changeNr).
|
|
118 |
^ aStream
|
|
119 |
!
|
|
120 |
|
73
|
121 |
autoSelect:changeNr
|
|
122 |
"select a change"
|
|
123 |
|
|
124 |
self class autoSelectNext ifTrue:[
|
|
125 |
(changeNr <= changePositions size) ifTrue:[
|
|
126 |
changeListView selection:changeNr.
|
|
127 |
self changeSelection:changeNr.
|
|
128 |
^ self
|
|
129 |
]
|
|
130 |
].
|
|
131 |
self clearCodeView.
|
|
132 |
changeListView selection:nil.
|
|
133 |
!
|
|
134 |
|
|
135 |
clearCodeView
|
|
136 |
self unselect "changeListView deselect".
|
|
137 |
codeView contents:nil.
|
|
138 |
changeNrShown := nil
|
|
139 |
!
|
|
140 |
|
51
|
141 |
applyChange:changeNr
|
|
142 |
"fileIn a change"
|
|
143 |
|
|
144 |
|aStream upd nm|
|
45
|
145 |
|
51
|
146 |
aStream := self streamForChange:changeNr.
|
|
147 |
aStream isNil ifTrue:[^ self].
|
|
148 |
|
|
149 |
nm := self classNameOfChange:changeNr.
|
|
150 |
nm notNil ifTrue:[
|
|
151 |
|cls|
|
45
|
152 |
|
51
|
153 |
cls := Smalltalk at:(nm asSymbol) ifAbsent:[].
|
|
154 |
cls notNil ifTrue:[
|
|
155 |
cls isLoaded ifFalse:[
|
|
156 |
cls autoload
|
|
157 |
]
|
|
158 |
]
|
|
159 |
].
|
45
|
160 |
|
51
|
161 |
changeNrProcessed := changeNr.
|
45
|
162 |
|
51
|
163 |
upd := Class updateChanges:false.
|
|
164 |
[
|
|
165 |
|sig|
|
45
|
166 |
|
51
|
167 |
(skipSignal notNil) ifTrue:[
|
|
168 |
sig := skipSignal
|
|
169 |
] ifFalse:[
|
|
170 |
sig := Object abortSignal
|
|
171 |
].
|
|
172 |
sig catch:[
|
|
173 |
aStream fileInNextChunkNotifying:self
|
|
174 |
].
|
|
175 |
changeNrProcessed := nil.
|
|
176 |
] valueNowOrOnUnwindDo:[
|
|
177 |
Class updateChanges:upd.
|
|
178 |
aStream close
|
45
|
179 |
].
|
|
180 |
!
|
|
181 |
|
73
|
182 |
unselect
|
|
183 |
"common unselect"
|
|
184 |
|
|
185 |
changeListView deselect.
|
|
186 |
!
|
|
187 |
|
51
|
188 |
setChangeList
|
|
189 |
"extract type-information from changes and stuff into top selection
|
|
190 |
view"
|
0
|
191 |
|
51
|
192 |
changeListView setList:changeHeaderLines expandTabs:false.
|
|
193 |
"/ changeListView deselect.
|
50
|
194 |
!
|
|
195 |
|
37
|
196 |
readChangesFileInBackground:inBackground
|
|
197 |
"read the changes file, create a list of header-lines (changeChunks)
|
51
|
198 |
and a list of chunk-positions (changePositions).
|
|
199 |
Starting with 2.10.3, the entries are multi-col entries;
|
|
200 |
the cols are:
|
|
201 |
1 class/selector
|
|
202 |
2 delta
|
|
203 |
'+' -> new method (w.r.t. current state)
|
|
204 |
'-' -> removed method (w.r.t. current state)
|
|
205 |
'?' -> class does not exist currently
|
|
206 |
3 type of change
|
|
207 |
doit
|
|
208 |
method
|
|
209 |
category change
|
|
210 |
"
|
37
|
211 |
|
51
|
212 |
|aStream maxLen|
|
50
|
213 |
|
|
214 |
maxLen := 60.
|
0
|
215 |
|
|
216 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
217 |
aStream isNil ifTrue:[^ nil].
|
|
218 |
|
|
219 |
self withCursor:(Cursor read) do:[
|
51
|
220 |
|tabSpec myProcess myPriority|
|
|
221 |
|
49
|
222 |
tabSpec := TabulatorSpecification new.
|
|
223 |
tabSpec unit:#inch.
|
51
|
224 |
tabSpec positions:#(0 4.5 4.65 5.5 ).
|
|
225 |
" cls>>sel +/- type info"
|
|
226 |
tabSpec align: #(#left #left #left #left).
|
49
|
227 |
|
45
|
228 |
"
|
|
229 |
this is a time consuming operation (especially, if reading an
|
|
230 |
NFS-mounted directory; therefore lower my priority ...
|
|
231 |
"
|
|
232 |
inBackground ifTrue:[
|
|
233 |
myProcess := Processor activeProcess.
|
|
234 |
myPriority := myProcess priority.
|
|
235 |
myProcess priority:(Processor userBackgroundPriority).
|
|
236 |
].
|
51
|
237 |
|
45
|
238 |
[
|
51
|
239 |
|excla|
|
50
|
240 |
|
45
|
241 |
changeChunks := OrderedCollection new.
|
|
242 |
changeHeaderLines := OrderedCollection new.
|
|
243 |
changePositions := OrderedCollection new.
|
|
244 |
excla := aStream class chunkSeparator.
|
0
|
245 |
|
45
|
246 |
[aStream atEnd] whileFalse:[
|
51
|
247 |
|entry changeDelta changeString changeType
|
|
248 |
line s l changeClass sawExcla category
|
|
249 |
chunkText chunkPos|
|
|
250 |
|
45
|
251 |
"
|
|
252 |
get a chunk (separated by excla)
|
|
253 |
"
|
|
254 |
aStream skipSeparators.
|
|
255 |
chunkPos := aStream position.
|
73
|
256 |
|
|
257 |
|
45
|
258 |
sawExcla := aStream peekFor:excla.
|
|
259 |
chunkText := aStream nextChunk.
|
|
260 |
chunkText notNil ifTrue:[
|
51
|
261 |
|index headerLine|
|
|
262 |
|
45
|
263 |
"
|
|
264 |
only first line is saved in changeChunks ...
|
|
265 |
"
|
|
266 |
index := chunkText indexOf:(Character cr).
|
|
267 |
(index ~~ 0) ifTrue:[
|
|
268 |
chunkText := chunkText copyTo:(index - 1).
|
|
269 |
|
|
270 |
"take care for comment changes - must still be a
|
|
271 |
valid expression for classNameOfChange: to work"
|
|
272 |
|
|
273 |
(chunkText endsWith:'comment:''') ifTrue:[
|
|
274 |
chunkText := chunkText , '...'''
|
|
275 |
]
|
29
|
276 |
|
45
|
277 |
].
|
|
278 |
|
|
279 |
changeChunks add:chunkText.
|
|
280 |
changePositions add:chunkPos.
|
50
|
281 |
headerLine := nil.
|
51
|
282 |
changeDelta := ' '.
|
29
|
283 |
|
45
|
284 |
sawExcla ifFalse:[
|
51
|
285 |
(chunkText startsWith:'''---- snap') ifTrue:[
|
|
286 |
changeType := ''.
|
|
287 |
headerLine := chunkText.
|
|
288 |
changeString := (chunkText contractTo:maxLen).
|
|
289 |
] ifFalse:[
|
|
290 |
|p sel cls|
|
|
291 |
|
49
|
292 |
headerLine := chunkText , ' (doIt)'.
|
50
|
293 |
|
51
|
294 |
"
|
|
295 |
first, assume doIt - then lets have a more detailed look ...
|
|
296 |
"
|
73
|
297 |
(chunkText startsWith:'''---- file') ifTrue:[
|
|
298 |
changeType := ''.
|
|
299 |
] ifFalse:[
|
|
300 |
changeType := '(doIt)'.
|
|
301 |
].
|
50
|
302 |
changeString := (chunkText contractTo:maxLen).
|
51
|
303 |
|
50
|
304 |
p := Parser parseExpression:chunkText.
|
51
|
305 |
(p notNil
|
|
306 |
and:[p ~~ #Error
|
|
307 |
and:[p isMessage]]) ifTrue:[
|
50
|
308 |
sel := p selector.
|
51
|
309 |
].
|
|
310 |
(sel == #removeSelector:) ifTrue:[
|
|
311 |
p receiver isUnaryMessage ifTrue:[
|
|
312 |
cls := p receiver receiver name.
|
|
313 |
changeClass := (Smalltalk classNamed:cls) class.
|
|
314 |
cls := cls , ' class'.
|
|
315 |
] ifFalse:[
|
|
316 |
cls := p receiver name.
|
|
317 |
changeClass := (Smalltalk classNamed:cls)
|
|
318 |
].
|
|
319 |
sel := (p args at:1) evaluate.
|
|
320 |
(changeClass isNil or:[changeClass isLoaded not]) ifTrue:[
|
|
321 |
changeDelta := '?'
|
|
322 |
] ifFalse:[
|
|
323 |
(changeClass implements:sel asSymbol) ifTrue:[
|
|
324 |
changeDelta := '-'.
|
|
325 |
]
|
|
326 |
].
|
|
327 |
changeType := '(remove)'.
|
|
328 |
changeString := self contractClass:cls selector:sel to:maxLen.
|
|
329 |
].
|
|
330 |
(sel == #category:) ifTrue:[
|
|
331 |
(p receiver isMessage
|
|
332 |
and:[p receiver selector == #compiledMethodAt:]) ifTrue:[
|
|
333 |
p receiver receiver isUnaryMessage ifTrue:[
|
|
334 |
cls := p receiver receiver receiver name.
|
|
335 |
changeClass := (Smalltalk classNamed:cls) class.
|
|
336 |
cls := cls , ' class'.
|
|
337 |
] ifFalse:[
|
50
|
338 |
cls := p receiver receiver name.
|
51
|
339 |
changeClass := (Smalltalk classNamed:cls)
|
50
|
340 |
].
|
51
|
341 |
sel := (p receiver args at:1) evaluate.
|
|
342 |
changeType := '(category change)'.
|
50
|
343 |
changeString := self contractClass:cls selector:sel to:maxLen.
|
|
344 |
]
|
73
|
345 |
].
|
|
346 |
(#(#'subclass:'
|
|
347 |
#'variableSubclass:'
|
|
348 |
#'variableByteSubclass:'
|
|
349 |
#'variableWordSubclass:'
|
|
350 |
#'variableLongSubclass:'
|
|
351 |
#'variableFloatSubclass:'
|
|
352 |
#'variableDoubleSubclass:'
|
|
353 |
) includes:sel) ifTrue:[
|
|
354 |
changeType := '(class definition)'.
|
|
355 |
].
|
45
|
356 |
].
|
|
357 |
] ifTrue:[
|
51
|
358 |
|done first p sel cls text|
|
|
359 |
|
45
|
360 |
"
|
|
361 |
method definitions actually consist of
|
|
362 |
two (or more) chunks; skip next chunk(s)
|
|
363 |
up to an empty one.
|
|
364 |
The system only writes one chunk,
|
|
365 |
and we cannot handle more in this ChangesBrowser ....
|
|
366 |
"
|
|
367 |
cls := nil.
|
|
368 |
p := Parser parseExpression:chunkText.
|
37
|
369 |
|
45
|
370 |
(p notNil and:[p ~~ #Error]) ifTrue:[
|
|
371 |
sel := p selector.
|
|
372 |
(sel == #methodsFor:) ifTrue:[
|
|
373 |
p receiver isUnaryMessage ifTrue:[
|
|
374 |
cls := p receiver receiver name.
|
51
|
375 |
changeClass := (Smalltalk classNamed:cls) class.
|
|
376 |
cls := cls , ' class'.
|
45
|
377 |
] ifFalse:[
|
51
|
378 |
cls := p receiver name.
|
|
379 |
changeClass := Smalltalk classNamed:cls
|
45
|
380 |
].
|
50
|
381 |
category := (p args at:1) evaluate.
|
|
382 |
].
|
45
|
383 |
].
|
|
384 |
done := false.
|
|
385 |
first := true.
|
|
386 |
[done] whileFalse:[
|
|
387 |
text := aStream nextChunk.
|
|
388 |
text isNil ifTrue:[
|
|
389 |
done := true
|
|
390 |
] ifFalse:[
|
|
391 |
done := text isEmpty
|
|
392 |
].
|
|
393 |
done ifFalse:[
|
|
394 |
first ifFalse:[
|
|
395 |
Transcript showCr:'only one method per ''methodsFor:'' handled'.
|
|
396 |
] ifTrue:[
|
|
397 |
first := false.
|
|
398 |
"
|
|
399 |
try to find the selector
|
|
400 |
"
|
|
401 |
sel := nil.
|
|
402 |
cls notNil ifTrue:[
|
|
403 |
p := Parser
|
|
404 |
parseMethodSpecification:text
|
|
405 |
in:nil
|
|
406 |
ignoreErrors:true
|
|
407 |
ignoreWarnings:true.
|
|
408 |
(p notNil and:[p ~~ #Error]) ifTrue:[
|
|
409 |
sel := p selector.
|
|
410 |
]
|
|
411 |
].
|
50
|
412 |
|
|
413 |
sel isNil ifTrue:[
|
|
414 |
changeString := (chunkText contractTo:maxLen).
|
|
415 |
changeType := '(change)'.
|
|
416 |
] ifFalse:[
|
|
417 |
changeString := self contractClass:cls selector:sel to:maxLen.
|
|
418 |
changeType := '(method in: ''' , category , ''')'.
|
|
419 |
].
|
45
|
420 |
sel isNil ifTrue:[
|
49
|
421 |
headerLine := chunkText , ' (change)'.
|
45
|
422 |
] ifFalse:[
|
49
|
423 |
headerLine := cls , ' ' , sel , ' ' , '(change category: ''' , category , ''')'.
|
51
|
424 |
].
|
|
425 |
(changeClass isNil or:[changeClass isLoaded not]) ifTrue:[
|
|
426 |
changeDelta := '?'
|
|
427 |
] ifFalse:[
|
|
428 |
(changeClass implements:sel asSymbol) ifFalse:[
|
|
429 |
changeDelta := '+'.
|
|
430 |
]
|
45
|
431 |
]
|
|
432 |
]
|
|
433 |
]
|
|
434 |
]
|
49
|
435 |
].
|
51
|
436 |
changeString notNil ifTrue:[
|
|
437 |
entry := MultiColListEntry new.
|
50
|
438 |
entry tabulatorSpecification:tabSpec.
|
|
439 |
entry colAt:1 put:changeString.
|
51
|
440 |
entry colAt:2 put:changeDelta.
|
|
441 |
entry colAt:3 put:changeType.
|
49
|
442 |
changeHeaderLines add:entry
|
|
443 |
] ifFalse:[
|
|
444 |
headerLine notNil ifTrue:[
|
|
445 |
changeHeaderLines add:headerLine
|
|
446 |
]
|
45
|
447 |
]
|
|
448 |
]
|
|
449 |
].
|
|
450 |
changeClassNames := OrderedCollection new grow:(changeChunks size).
|
|
451 |
aStream close.
|
|
452 |
anyChanges := false
|
|
453 |
] valueNowOrOnUnwindDo:[
|
|
454 |
inBackground ifTrue:[myProcess priority:myPriority].
|
|
455 |
].
|
|
456 |
]
|
|
457 |
!
|
37
|
458 |
|
51
|
459 |
contractClass:className selector:selector to:maxLen
|
|
460 |
|s l|
|
|
461 |
|
|
462 |
s := className , ' ', selector.
|
|
463 |
s size > maxLen ifTrue:[
|
|
464 |
l := maxLen - 1 - selector size max:20.
|
|
465 |
s := (className contractTo:l) , ' ' , selector.
|
|
466 |
|
|
467 |
s size > maxLen ifTrue:[
|
|
468 |
l := maxLen - 1 - className size max:20.
|
|
469 |
s := className , ' ', (selector contractTo:l).
|
45
|
470 |
|
51
|
471 |
s size > maxLen ifTrue:[
|
|
472 |
s := (className contractTo:(maxLen // 2 - 1)) , ' ' , (selector contractTo:maxLen // 2)
|
|
473 |
]
|
|
474 |
]
|
|
475 |
].
|
|
476 |
^ s
|
|
477 |
!
|
|
478 |
|
73
|
479 |
silentDeleteChange:changeNr
|
|
480 |
"delete a change do not update changeListView"
|
57
|
481 |
|
73
|
482 |
anyChanges := true.
|
|
483 |
changeChunks removeIndex:changeNr.
|
|
484 |
changePositions removeIndex:changeNr.
|
|
485 |
changeClassNames removeIndex:changeNr.
|
|
486 |
changeHeaderLines removeIndex:changeNr
|
45
|
487 |
!
|
|
488 |
|
51
|
489 |
classNameOfChange:changeNr
|
|
490 |
"return the classname of a change (for xxx class - changes xxx is returned)
|
|
491 |
- since parsing ascii methods is slow, keep result cached in
|
|
492 |
changeClassNames for the next query"
|
|
493 |
|
|
494 |
|chunk aParseTree recTree sel name arg1Tree|
|
|
495 |
|
|
496 |
changeNr isNil ifTrue:[^ nil].
|
|
497 |
|
|
498 |
"
|
|
499 |
first look, if not already known
|
|
500 |
"
|
|
501 |
name := changeClassNames at:changeNr.
|
|
502 |
name notNil ifTrue:[^ name].
|
45
|
503 |
|
51
|
504 |
"
|
|
505 |
get the chunk
|
|
506 |
"
|
|
507 |
chunk := changeChunks at:changeNr.
|
|
508 |
chunk isNil ifTrue:[^ nil]. "mhmh - empty"
|
45
|
509 |
|
51
|
510 |
"
|
|
511 |
use parser to construct a parseTree
|
|
512 |
"
|
|
513 |
aParseTree := Parser parseExpression:chunk.
|
|
514 |
(aParseTree isNil or:[aParseTree == #Error]) ifTrue:[
|
|
515 |
^ nil "seems strange ... (could be a comment)"
|
|
516 |
].
|
|
517 |
aParseTree isMessage ifFalse:[
|
|
518 |
^ nil "very strange ... (whats that ?)"
|
|
519 |
].
|
|
520 |
|
|
521 |
"
|
|
522 |
ask parser for selector
|
|
523 |
"
|
|
524 |
sel := aParseTree selector.
|
|
525 |
recTree := aParseTree receiver.
|
45
|
526 |
|
51
|
527 |
"
|
|
528 |
is it a method-change, methodRemove or comment-change ?
|
|
529 |
"
|
|
530 |
(#(#'methodsFor:'
|
|
531 |
#'privateMethodsFor:'
|
|
532 |
#'protectedMethodsFor:'
|
|
533 |
#'publicMethodsFor:'
|
|
534 |
#'removeSelector:'
|
|
535 |
#'comment:'
|
|
536 |
#'renameCategory:to:'
|
61
|
537 |
#'instanceVariableNames:'
|
51
|
538 |
) includes:sel) ifTrue:[
|
|
539 |
"
|
|
540 |
yes, the className is the receiver
|
|
541 |
"
|
|
542 |
(recTree notNil and:[recTree ~~ #Error]) ifTrue:[
|
|
543 |
recTree isUnaryMessage ifTrue:[
|
|
544 |
(recTree selector ~~ #class) ifTrue:[^ nil].
|
|
545 |
"id class methodsFor:..."
|
|
546 |
recTree := recTree receiver
|
|
547 |
].
|
|
548 |
recTree isPrimary ifTrue:[
|
|
549 |
name := recTree name.
|
|
550 |
changeClassNames at:changeNr put:name.
|
|
551 |
^ name
|
45
|
552 |
]
|
51
|
553 |
].
|
|
554 |
"more strange things"
|
|
555 |
^ nil
|
|
556 |
].
|
|
557 |
|
|
558 |
"
|
|
559 |
is it a change in a class-description ?
|
|
560 |
"
|
73
|
561 |
(('subclass:*' match:sel)
|
|
562 |
or:[('variable*subclass:*' match:sel)]) ifTrue:[
|
51
|
563 |
arg1Tree := aParseTree arg1.
|
|
564 |
(arg1Tree notNil and:[arg1Tree isConstant]) ifTrue:[
|
|
565 |
name := arg1Tree value asString.
|
|
566 |
changeClassNames at:changeNr put:name.
|
|
567 |
^ name
|
|
568 |
].
|
|
569 |
"very strange"
|
|
570 |
^ nil
|
|
571 |
].
|
|
572 |
|
|
573 |
"
|
|
574 |
is it a class remove ?
|
|
575 |
"
|
|
576 |
(sel == #removeClass:) ifTrue:[
|
|
577 |
(recTree notNil
|
|
578 |
and:[recTree ~~ #Error
|
|
579 |
and:[recTree isPrimary
|
|
580 |
and:[recTree name = 'Smalltalk']]]) ifTrue:[
|
|
581 |
arg1Tree := aParseTree arg1.
|
|
582 |
(arg1Tree notNil and:[arg1Tree isPrimary]) ifTrue:[
|
|
583 |
name := arg1Tree name.
|
|
584 |
changeClassNames at:changeNr put:name.
|
|
585 |
^ name
|
|
586 |
].
|
45
|
587 |
]
|
|
588 |
].
|
|
589 |
|
51
|
590 |
"
|
|
591 |
is it a method category change ?
|
|
592 |
"
|
|
593 |
(sel == #category:) ifTrue:[
|
|
594 |
(recTree notNil
|
|
595 |
and:[recTree ~~ #Error
|
|
596 |
and:[recTree isMessage
|
|
597 |
and:[recTree selector == #compiledMethodAt:]]]) ifTrue:[
|
|
598 |
recTree := recTree receiver.
|
|
599 |
recTree isUnaryMessage ifTrue:[
|
|
600 |
(recTree selector ~~ #class) ifTrue:[^ nil].
|
|
601 |
"id class "
|
|
602 |
recTree := recTree receiver
|
|
603 |
].
|
|
604 |
recTree isPrimary ifTrue:[
|
|
605 |
name := recTree name.
|
|
606 |
changeClassNames at:changeNr put:name.
|
|
607 |
^ name
|
|
608 |
]
|
|
609 |
]
|
45
|
610 |
].
|
51
|
611 |
^ nil
|
45
|
612 |
!
|
|
613 |
|
73
|
614 |
autoSelectOrEnd:changeNr
|
|
615 |
"select the next change or the last"
|
|
616 |
|
|
617 |
|last|
|
|
618 |
|
|
619 |
last := changePositions size.
|
|
620 |
changeNr < last ifTrue:[
|
|
621 |
self autoSelect:changeNr
|
|
622 |
] ifFalse:[
|
|
623 |
changeListView selection:last .
|
|
624 |
self changeSelection:last.
|
|
625 |
]
|
|
626 |
!
|
|
627 |
|
|
628 |
withSelectedChangeDo:aBlock
|
|
629 |
"just a helper, check for a selected change and evaluate aBlock
|
|
630 |
with busy cursor"
|
|
631 |
|
|
632 |
|changeNr|
|
|
633 |
|
|
634 |
changeNr := changeListView selection.
|
|
635 |
changeNr notNil ifTrue:[
|
|
636 |
self withCursor:(Cursor execute) do:[
|
|
637 |
aBlock value:changeNr
|
|
638 |
]
|
|
639 |
]
|
|
640 |
!
|
|
641 |
|
|
642 |
autoSelectLast
|
|
643 |
"select the last change"
|
|
644 |
|
|
645 |
self autoSelect:(changePositions size)
|
|
646 |
!
|
|
647 |
|
|
648 |
compareChange:changeNr
|
|
649 |
"compare a change with current version"
|
|
650 |
|
|
651 |
|aStream chunk sawExcla parseTree thisClass cat oldSource newSource
|
|
652 |
parser sel oldMethod outcome showDiff d t1 t2|
|
|
653 |
|
|
654 |
aStream := self streamForChange:changeNr.
|
|
655 |
aStream isNil ifTrue:[^ self].
|
|
656 |
|
|
657 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
658 |
chunk := aStream nextChunk.
|
|
659 |
sawExcla ifFalse:[
|
|
660 |
outcome := 'not comparable ...'
|
|
661 |
] ifTrue:[
|
|
662 |
parseTree := Parser parseExpression:chunk.
|
|
663 |
(parseTree notNil and:[parseTree isMessage]) ifTrue:[
|
|
664 |
(parseTree selector == #methodsFor:) ifTrue:[
|
|
665 |
thisClass := (parseTree receiver evaluate).
|
|
666 |
thisClass isBehavior ifTrue:[
|
|
667 |
showDiff := false.
|
|
668 |
|
|
669 |
cat := parseTree arg1 evaluate.
|
|
670 |
newSource := aStream nextChunk.
|
|
671 |
parser := Parser parseMethod:newSource in:thisClass.
|
|
672 |
(parser notNil and:[parser ~~ #Error]) ifTrue:[
|
|
673 |
sel := parser selector.
|
|
674 |
oldMethod := thisClass compiledMethodAt:sel.
|
|
675 |
oldMethod notNil ifTrue:[
|
|
676 |
(oldMethod category = cat) ifFalse:[
|
|
677 |
Transcript showCr:'category changed.'.
|
|
678 |
].
|
|
679 |
oldSource := oldMethod source.
|
|
680 |
(oldSource = newSource) ifTrue:[
|
|
681 |
outcome := 'same source'
|
|
682 |
] ifFalse:[
|
|
683 |
"/
|
|
684 |
"/ compare for tabulator <-> space changes
|
|
685 |
"/ before showing diff ...
|
|
686 |
"/
|
|
687 |
t1 := oldSource asString withTabsExpanded.
|
|
688 |
t2 := newSource asString withTabsExpanded.
|
|
689 |
t1 = t2 ifTrue:[
|
|
690 |
outcome := 'same source (tabs <-> spaces)'
|
|
691 |
] ifFalse:[
|
|
692 |
outcome := 'source changed.'.
|
|
693 |
showDiff := true
|
|
694 |
]
|
|
695 |
]
|
|
696 |
] ifFalse:[
|
|
697 |
outcome := 'method does not exist.'
|
|
698 |
]
|
|
699 |
] ifFalse:[
|
|
700 |
outcome := 'change unparsable.'
|
|
701 |
].
|
|
702 |
(showDiff and:[oldSource notNil and:[newSource notNil]]) ifTrue:[
|
|
703 |
d := DiffTextView openOn:oldSource and:newSource.
|
|
704 |
d label:'differences (current left; change right)'.
|
|
705 |
]
|
|
706 |
] ifFalse:[
|
|
707 |
outcome := 'class does not exist.'
|
|
708 |
]
|
|
709 |
] ifFalse:[
|
|
710 |
outcome := 'not comparable.'
|
|
711 |
]
|
|
712 |
] ifFalse:[
|
|
713 |
outcome := 'not comparable.'
|
|
714 |
]
|
|
715 |
].
|
|
716 |
Transcript showCr:outcome.
|
|
717 |
aStream close.
|
|
718 |
!
|
|
719 |
|
45
|
720 |
writeBackChanges
|
|
721 |
"write back the changes file"
|
|
722 |
|
51
|
723 |
|inStream outStream|
|
45
|
724 |
|
|
725 |
outStream := FileStream newFileNamed:'n_changes'.
|
|
726 |
outStream isNil ifTrue:[
|
|
727 |
self warn:'cannot create temporary file'.
|
|
728 |
^ self
|
|
729 |
].
|
|
730 |
|
|
731 |
inStream := FileStream readonlyFileNamed:changeFileName.
|
|
732 |
inStream isNil ifTrue:[^ nil].
|
|
733 |
|
|
734 |
self withCursor:(Cursor write) do:[
|
51
|
735 |
|excla sawExcla done dir chunk
|
|
736 |
nChanges "{Class:SmallInteger}" |
|
|
737 |
|
45
|
738 |
excla := inStream class chunkSeparator.
|
51
|
739 |
nChanges := changePositions size.
|
|
740 |
|
|
741 |
1 to:nChanges do:[:index |
|
45
|
742 |
inStream position:(changePositions at:index).
|
|
743 |
sawExcla := inStream peekFor:excla.
|
|
744 |
chunk := inStream nextChunk.
|
|
745 |
|
|
746 |
sawExcla ifTrue:[
|
|
747 |
outStream nextPut:excla.
|
|
748 |
outStream nextChunkPut:chunk.
|
|
749 |
outStream cr.
|
51
|
750 |
"
|
|
751 |
a method-definition chunk - skip followups
|
|
752 |
"
|
45
|
753 |
done := false.
|
|
754 |
[done] whileFalse:[
|
|
755 |
chunk := inStream nextChunk.
|
|
756 |
chunk isNil ifTrue:[
|
|
757 |
done := true
|
|
758 |
] ifFalse:[
|
|
759 |
outStream nextChunkPut:chunk.
|
|
760 |
outStream cr.
|
|
761 |
done := chunk isEmpty
|
|
762 |
]
|
|
763 |
].
|
|
764 |
] ifFalse:[
|
|
765 |
outStream nextChunkPut:chunk.
|
|
766 |
outStream cr
|
|
767 |
]
|
|
768 |
].
|
|
769 |
outStream close.
|
|
770 |
inStream close.
|
|
771 |
dir := FileDirectory currentDirectory.
|
51
|
772 |
dir renameFile:changeFileName newName:'changes.bak'.
|
45
|
773 |
dir renameFile:'n_changes' newName:changeFileName.
|
|
774 |
anyChanges := false
|
|
775 |
]
|
|
776 |
!
|
0
|
777 |
|
|
778 |
deleteChange:changeNr
|
|
779 |
"delete a change"
|
|
780 |
|
|
781 |
changeListView deselect.
|
|
782 |
self silentDeleteChange:changeNr.
|
51
|
783 |
self setChangeList
|
45
|
784 |
|
|
785 |
!
|
|
786 |
|
51
|
787 |
deleteChangesFrom:start to:stop
|
|
788 |
"delete a range of changes"
|
|
789 |
|
|
790 |
changeListView deselect.
|
|
791 |
stop to:start by:-1 do:[:changeNr |
|
|
792 |
self silentDeleteChange:changeNr
|
|
793 |
].
|
|
794 |
self setChangeList
|
|
795 |
|
|
796 |
!
|
|
797 |
|
73
|
798 |
queryCloseText
|
|
799 |
"made this a method for easy redefinition in subclasses"
|
|
800 |
|
|
801 |
^ 'Quit without updating changeFile ?'
|
|
802 |
!
|
|
803 |
|
51
|
804 |
changeFileName:aFileName
|
|
805 |
changeFileName := aFileName
|
|
806 |
!
|
|
807 |
|
|
808 |
readChangesFile
|
|
809 |
"read the changes file, create a list of header-lines (changeChunks)
|
|
810 |
and a list of chunk-positions (changePositions)"
|
|
811 |
|
|
812 |
^ self readChangesFileInBackground:false
|
|
813 |
!
|
|
814 |
|
28
|
815 |
appendChange:changeNr toFile:fileName
|
37
|
816 |
"append change to a file. return true if ok."
|
0
|
817 |
|
37
|
818 |
|aStream outStream chunk sawExcla separator|
|
0
|
819 |
|
28
|
820 |
outStream := FileStream oldFileNamed:fileName.
|
0
|
821 |
outStream isNil ifTrue:[
|
45
|
822 |
outStream isNil ifTrue:[
|
|
823 |
outStream := FileStream newFileNamed:fileName.
|
|
824 |
outStream isNil ifTrue:[
|
|
825 |
self warn:'cannot update file ''%1''' with:fileName.
|
|
826 |
^ false
|
|
827 |
]
|
|
828 |
]
|
0
|
829 |
].
|
37
|
830 |
|
0
|
831 |
outStream setToEnd.
|
28
|
832 |
|
0
|
833 |
aStream := self streamForChange:changeNr.
|
37
|
834 |
aStream isNil ifTrue:[
|
45
|
835 |
self warn:'oops cannot read change'.
|
|
836 |
^ false
|
37
|
837 |
].
|
|
838 |
|
|
839 |
separator := aStream class chunkSeparator.
|
|
840 |
sawExcla := aStream peekFor:separator.
|
0
|
841 |
sawExcla ifTrue:[
|
45
|
842 |
outStream nextPut:separator
|
0
|
843 |
].
|
|
844 |
chunk := aStream nextChunk.
|
|
845 |
outStream nextChunkPut:chunk.
|
|
846 |
outStream cr.
|
|
847 |
sawExcla ifTrue:[
|
45
|
848 |
chunk := aStream nextChunk.
|
|
849 |
outStream nextChunkPut:chunk.
|
|
850 |
outStream space
|
0
|
851 |
].
|
|
852 |
sawExcla ifTrue:[
|
45
|
853 |
outStream nextPut:separator
|
0
|
854 |
].
|
|
855 |
outStream cr.
|
|
856 |
aStream close.
|
37
|
857 |
outStream close.
|
|
858 |
^ true
|
0
|
859 |
!
|
|
860 |
|
28
|
861 |
makeChangeAPatch:changeNr
|
|
862 |
"append change to patchfile"
|
|
863 |
|
|
864 |
self appendChange:changeNr toFile:'patches'
|
|
865 |
!
|
|
866 |
|
0
|
867 |
makeChangePermanent:changeNr
|
28
|
868 |
"rewrite the source file where change changeNr lies"
|
0
|
869 |
|
|
870 |
self notify:'this is not yet implemented'
|
|
871 |
!
|
|
872 |
|
45
|
873 |
silentDeleteChangesFor:aClassName from:start to:stop
|
|
874 |
"delete changes for a given class in a range"
|
|
875 |
|
|
876 |
|thisClassName index|
|
0
|
877 |
|
45
|
878 |
index := stop.
|
|
879 |
[index >= start] whileTrue:[
|
|
880 |
thisClassName := self classNameOfChange:index.
|
|
881 |
thisClassName = aClassName ifTrue:[
|
|
882 |
self silentDeleteChange:index
|
|
883 |
].
|
|
884 |
index := index - 1
|
|
885 |
]
|
0
|
886 |
|
|
887 |
! !
|
|
888 |
|
73
|
889 |
!ChangesBrowser methodsFor:'user interaction'!
|
51
|
890 |
|
73
|
891 |
doApply
|
|
892 |
"user wants a change to be applied"
|
51
|
893 |
|
73
|
894 |
self withSelectedChangeDo:[:changeNr |
|
|
895 |
skipSignal := nil.
|
|
896 |
self applyChange:changeNr.
|
|
897 |
self autoSelect:(changeNr + 1)
|
|
898 |
]
|
57
|
899 |
!
|
|
900 |
|
0
|
901 |
changeSelection:lineNr
|
|
902 |
"show a change in the codeView"
|
|
903 |
|
|
904 |
|aStream sawExcla chunk|
|
|
905 |
|
|
906 |
aStream := self streamForChange:lineNr.
|
|
907 |
aStream isNil ifTrue:[^ self].
|
|
908 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
909 |
chunk := aStream nextChunk.
|
|
910 |
sawExcla ifTrue:[
|
45
|
911 |
chunk := aStream nextChunk
|
0
|
912 |
].
|
|
913 |
aStream close.
|
|
914 |
codeView contents:chunk.
|
13
|
915 |
codeView acceptAction:[:theCode | self doApply "noChangesAllowed"].
|
15
|
916 |
changeNrShown := lineNr.
|
0
|
917 |
|
51
|
918 |
!
|
|
919 |
|
45
|
920 |
noChangesAllowed
|
|
921 |
"show a warning that changes cannot be changed"
|
|
922 |
|
|
923 |
self warn:'changes are not allowed to be changed'
|
|
924 |
!
|
|
925 |
|
37
|
926 |
doSaveClass
|
|
927 |
"user wants changes for some class from current to end to be appended to a file"
|
|
928 |
|
|
929 |
self doSaveClassFrom:1
|
|
930 |
!
|
|
931 |
|
|
932 |
doSaveClassAll
|
|
933 |
"user wants changes for some class from current to end to be appended to a file"
|
|
934 |
|
|
935 |
self doSaveClassFrom:1
|
|
936 |
!
|
|
937 |
|
|
938 |
doSaveClassRest
|
|
939 |
"user wants changes for some class from current to end to be appended to a file"
|
28
|
940 |
|
|
941 |
|changeNr|
|
|
942 |
|
|
943 |
changeNr := changeListView selection.
|
|
944 |
changeNr notNil ifTrue:[
|
45
|
945 |
self doSaveClassFrom:changeNr
|
37
|
946 |
]
|
|
947 |
!
|
|
948 |
|
45
|
949 |
doBrowse
|
|
950 |
"user wants a browser on the class of a change"
|
|
951 |
|
|
952 |
|changeNr className cls|
|
|
953 |
|
|
954 |
changeNr := changeListView selection.
|
|
955 |
changeNr notNil ifTrue:[
|
|
956 |
className := self classNameOfChange:changeNr.
|
|
957 |
className notNil ifTrue:[
|
|
958 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[
|
|
959 |
SystemBrowser browseClass:cls
|
|
960 |
]
|
|
961 |
]
|
37
|
962 |
]
|
|
963 |
!
|
|
964 |
|
73
|
965 |
doCompare
|
|
966 |
"compare change with current system version
|
|
967 |
- give a note in transcript"
|
|
968 |
|
|
969 |
|changeNr|
|
|
970 |
|
|
971 |
changeNr := changeListView selection.
|
|
972 |
changeNr notNil ifTrue:[
|
|
973 |
self withCursor:(Cursor execute) do:[
|
|
974 |
self compareChange:changeNr
|
|
975 |
]
|
|
976 |
]
|
|
977 |
!
|
|
978 |
|
51
|
979 |
saveClass:aClassName from:startNr
|
|
980 |
"user wants changes from current to end to be appended to a file"
|
|
981 |
|
73
|
982 |
|changeNr fileName|
|
51
|
983 |
|
|
984 |
changeNr := changeListView selection.
|
|
985 |
changeNr notNil ifTrue:[
|
73
|
986 |
fileName := DialogView
|
|
987 |
requestFileName:'append changes for class to:'
|
|
988 |
default:''
|
|
989 |
ok:'append'
|
|
990 |
abort:'abort'
|
|
991 |
pattern:'*.chg'.
|
|
992 |
|
|
993 |
fileName notNil ifTrue:[
|
|
994 |
self withCursor:(Cursor write) do:[
|
|
995 |
startNr to:(changePositions size) do:[:changeNr |
|
|
996 |
|thisClassName|
|
51
|
997 |
|
73
|
998 |
thisClassName := self classNameOfChange:changeNr.
|
|
999 |
thisClassName = aClassName ifTrue:[
|
|
1000 |
changeListView selection:changeNr.
|
|
1001 |
(self appendChange:changeNr toFile:fileName) ifFalse:[
|
|
1002 |
^ self
|
|
1003 |
]
|
|
1004 |
]
|
|
1005 |
]
|
|
1006 |
]
|
|
1007 |
].
|
|
1008 |
]
|
|
1009 |
!
|
51
|
1010 |
|
73
|
1011 |
doDelete
|
|
1012 |
"delete currently selected change"
|
|
1013 |
|
|
1014 |
|changeNr|
|
|
1015 |
|
|
1016 |
changeNr := changeListView selection.
|
|
1017 |
changeNr notNil ifTrue:[
|
|
1018 |
self deleteChange:changeNr.
|
|
1019 |
self autoSelectOrEnd:changeNr
|
51
|
1020 |
]
|
|
1021 |
!
|
|
1022 |
|
37
|
1023 |
doSaveClassFrom:startNr
|
|
1024 |
"user wants changes from current to end to be appended to a file"
|
|
1025 |
|
|
1026 |
|changeNr classNameToSave|
|
|
1027 |
|
|
1028 |
changeNr := changeListView selection.
|
|
1029 |
changeNr notNil ifTrue:[
|
45
|
1030 |
classNameToSave := self classNameOfChange:changeNr.
|
|
1031 |
classNameToSave notNil ifTrue:[
|
|
1032 |
self saveClass:classNameToSave from:startNr
|
|
1033 |
]
|
37
|
1034 |
]
|
|
1035 |
!
|
|
1036 |
|
|
1037 |
doSaveRest
|
|
1038 |
"user wants changes from current to end to be appended to a file"
|
|
1039 |
|
73
|
1040 |
|changeNr fileName|
|
37
|
1041 |
|
|
1042 |
changeNr := changeListView selection.
|
|
1043 |
changeNr notNil ifTrue:[
|
73
|
1044 |
fileName := DialogView
|
|
1045 |
requestFileName:'append changes to:'
|
|
1046 |
default:''
|
|
1047 |
ok:'append'
|
|
1048 |
abort:'abort'
|
|
1049 |
pattern:'*.chg'.
|
37
|
1050 |
|
73
|
1051 |
fileName notNil ifTrue:[
|
|
1052 |
self withCursor:(Cursor write) do:[
|
|
1053 |
changeNr to:(changePositions size) do:[:changeNr |
|
|
1054 |
changeListView selection:changeNr.
|
|
1055 |
(self appendChange:changeNr toFile:fileName) ifFalse:[
|
|
1056 |
^ self
|
|
1057 |
]
|
|
1058 |
]
|
|
1059 |
]
|
|
1060 |
].
|
51
|
1061 |
]
|
|
1062 |
!
|
|
1063 |
|
37
|
1064 |
doSave
|
|
1065 |
"user wants a change to be appended to a file"
|
|
1066 |
|
73
|
1067 |
|changeNr fileName|
|
37
|
1068 |
|
|
1069 |
changeNr := changeListView selection.
|
|
1070 |
changeNr notNil ifTrue:[
|
73
|
1071 |
fileName := DialogView
|
|
1072 |
requestFileName:'append change to:'
|
|
1073 |
default:''
|
|
1074 |
ok:'append'
|
|
1075 |
abort:'abort'
|
|
1076 |
pattern:'*.chg'.
|
28
|
1077 |
|
73
|
1078 |
fileName notNil ifTrue:[
|
|
1079 |
self withCursor:(Cursor write) do:[
|
|
1080 |
self appendChange:changeNr toFile:fileName.
|
|
1081 |
].
|
|
1082 |
self autoSelect:(changeNr + 1)
|
|
1083 |
].
|
28
|
1084 |
]
|
|
1085 |
!
|
|
1086 |
|
51
|
1087 |
doUpdate
|
|
1088 |
"reread the changes-file"
|
|
1089 |
|
|
1090 |
self readChangesFileInBackground:true.
|
|
1091 |
realized ifTrue:[
|
|
1092 |
self setChangeList.
|
|
1093 |
]
|
73
|
1094 |
|
51
|
1095 |
!
|
|
1096 |
|
0
|
1097 |
doMakePermanent
|
|
1098 |
"user wants a change to be made permanent
|
|
1099 |
- rewrite the source file where this change has to go"
|
|
1100 |
|
51
|
1101 |
|yesNoBox|
|
0
|
1102 |
|
28
|
1103 |
yesNoBox := YesNoBox new.
|
1
|
1104 |
yesNoBox title:(resources at:'Warning: this operation cannot be undone').
|
28
|
1105 |
yesNoBox okText:(resources at:'continue').
|
1
|
1106 |
yesNoBox noText:(resources at:'abort').
|
51
|
1107 |
yesNoBox okAction:[ |changeNr|
|
|
1108 |
|
45
|
1109 |
changeNr := changeListView selection.
|
|
1110 |
changeNr notNil ifTrue:[
|
|
1111 |
self makeChangePermanent:changeNr.
|
|
1112 |
self autoSelect:(changeNr + 1)
|
|
1113 |
]
|
|
1114 |
].
|
0
|
1115 |
yesNoBox showAtPointer
|
|
1116 |
!
|
|
1117 |
|
|
1118 |
doMakePatch
|
|
1119 |
"user wants a change to be made a patch
|
|
1120 |
- copy it over to the patches file"
|
|
1121 |
|
|
1122 |
|changeNr|
|
|
1123 |
|
|
1124 |
changeNr := changeListView selection.
|
|
1125 |
changeNr notNil ifTrue:[
|
45
|
1126 |
self makeChangeAPatch:changeNr.
|
|
1127 |
self autoSelect:(changeNr + 1)
|
0
|
1128 |
]
|
|
1129 |
!
|
|
1130 |
|
49
|
1131 |
doDeleteRest
|
|
1132 |
"delete all changes from current to the end"
|
|
1133 |
|
|
1134 |
|changeNr|
|
|
1135 |
|
|
1136 |
changeNr := changeListView selection.
|
|
1137 |
changeNr notNil ifTrue:[
|
|
1138 |
self deleteChangesFrom:changeNr to:(changePositions size).
|
|
1139 |
self clearCodeView.
|
|
1140 |
self autoSelectOrEnd:changeNr-1
|
|
1141 |
]
|
|
1142 |
!
|
|
1143 |
|
45
|
1144 |
doCompress
|
|
1145 |
"compress the change-set; this replaces multiple method-changes by the last
|
|
1146 |
(i.e. the most recent) change"
|
|
1147 |
|
51
|
1148 |
|aStream searchIndex anyMore deleteSet index
|
|
1149 |
str snapshotProto snapshotPrefix snapshotNameIndex fileName|
|
45
|
1150 |
|
|
1151 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
1152 |
aStream isNil ifTrue:[^ self].
|
|
1153 |
|
58
|
1154 |
CompressSnapshotInfo == true ifTrue:[
|
|
1155 |
"
|
|
1156 |
get a prototype snapshot record (to be independent of
|
|
1157 |
the actual format ..
|
|
1158 |
"
|
|
1159 |
str := WriteStream on:String new.
|
|
1160 |
Class addChangeRecordForSnapshot:'foo' to:str.
|
|
1161 |
snapshotProto := str contents.
|
|
1162 |
snapshotPrefix := snapshotProto copyTo:10.
|
|
1163 |
snapshotNameIndex := snapshotProto findString:'foo'.
|
|
1164 |
].
|
45
|
1165 |
|
|
1166 |
self withCursor:(Cursor execute) do:[
|
51
|
1167 |
|numChanges classes selectors types excla sawExcla
|
|
1168 |
changeNr chunk aParseTree parseTreeChunk
|
|
1169 |
thisClass thisSelector codeChunk codeParser|
|
|
1170 |
|
45
|
1171 |
numChanges := changePositions size.
|
|
1172 |
classes := Array new:numChanges.
|
|
1173 |
selectors := Array new:numChanges.
|
|
1174 |
types := Array new:numChanges.
|
|
1175 |
|
|
1176 |
"starting at the end, get the change class and change selector;
|
|
1177 |
collect all in classes / selectors"
|
|
1178 |
|
|
1179 |
changeNr := numChanges.
|
|
1180 |
excla := aStream class chunkSeparator.
|
|
1181 |
|
|
1182 |
[changeNr >= 1] whileTrue:[
|
|
1183 |
aStream position:(changePositions at:changeNr).
|
|
1184 |
sawExcla := aStream peekFor:excla.
|
|
1185 |
chunk := aStream nextChunk.
|
|
1186 |
sawExcla ifTrue:[
|
|
1187 |
"optimize a bit if multiple methods for same category arrive"
|
|
1188 |
(chunk = parseTreeChunk) ifFalse:[
|
|
1189 |
aParseTree := Parser parseExpression:chunk.
|
|
1190 |
parseTreeChunk := chunk
|
|
1191 |
].
|
|
1192 |
(aParseTree notNil
|
|
1193 |
and:[(aParseTree ~~ #Error)
|
|
1194 |
and:[aParseTree isMessage]]) ifTrue:[
|
|
1195 |
(aParseTree selector == #methodsFor:) ifTrue:[
|
|
1196 |
thisClass := (aParseTree receiver evaluate).
|
|
1197 |
codeChunk := aStream nextChunk.
|
|
1198 |
codeParser := Parser
|
|
1199 |
parseMethodSpecification:codeChunk
|
|
1200 |
in:thisClass
|
|
1201 |
ignoreErrors:true
|
|
1202 |
ignoreWarnings:true.
|
|
1203 |
codeParser notNil ifTrue:[
|
|
1204 |
selectors at:changeNr put:(codeParser selector).
|
|
1205 |
classes at:changeNr put:thisClass.
|
|
1206 |
types at:changeNr put:#methodsFor
|
|
1207 |
]
|
|
1208 |
]
|
|
1209 |
]
|
|
1210 |
] ifFalse:[
|
|
1211 |
aParseTree := Parser parseExpression:chunk.
|
|
1212 |
parseTreeChunk := chunk.
|
|
1213 |
(aParseTree notNil
|
|
1214 |
and:[(aParseTree ~~ #Error)
|
|
1215 |
and:[aParseTree isMessage]]) ifTrue:[
|
|
1216 |
(aParseTree selector == #removeSelector:) ifTrue:[
|
|
1217 |
selectors at:changeNr put:(aParseTree arg1 value ).
|
|
1218 |
classes at:changeNr put:(aParseTree receiver evaluate).
|
|
1219 |
types at:changeNr put:#removeSelector
|
|
1220 |
]
|
|
1221 |
] ifFalse:[
|
58
|
1222 |
CompressSnapshotInfo == true ifTrue:[
|
|
1223 |
(chunk startsWith:snapshotPrefix) ifTrue:[
|
|
1224 |
str := chunk readStream position:snapshotNameIndex.
|
|
1225 |
fileName := str upTo:(Character space).
|
|
1226 |
"
|
|
1227 |
kludge to allow use of match-check below
|
|
1228 |
"
|
|
1229 |
selectors at:changeNr put:snapshotPrefix.
|
|
1230 |
classes at:changeNr put:fileName.
|
|
1231 |
]
|
45
|
1232 |
]
|
|
1233 |
]
|
|
1234 |
].
|
|
1235 |
changeNr := changeNr - 1
|
|
1236 |
].
|
|
1237 |
aStream close.
|
|
1238 |
|
|
1239 |
"for all changes, look for another class/selector occurence later
|
|
1240 |
in the list and, if there is one, add change number to the delete set"
|
|
1241 |
|
|
1242 |
deleteSet := OrderedCollection new.
|
|
1243 |
changeNr := 1.
|
|
1244 |
[changeNr < changePositions size] whileTrue:[
|
|
1245 |
thisClass := classes at:changeNr.
|
|
1246 |
thisSelector := selectors at:changeNr.
|
|
1247 |
searchIndex := changeNr.
|
|
1248 |
anyMore := true.
|
|
1249 |
[anyMore] whileTrue:[
|
|
1250 |
searchIndex := classes indexOf:thisClass
|
|
1251 |
startingAt:(searchIndex + 1).
|
|
1252 |
(searchIndex ~~ 0) ifTrue:[
|
|
1253 |
((selectors at:searchIndex) == thisSelector) ifTrue:[
|
|
1254 |
thisClass notNil ifTrue:[
|
|
1255 |
deleteSet add:changeNr.
|
|
1256 |
anyMore := false
|
|
1257 |
]
|
|
1258 |
]
|
|
1259 |
] ifFalse:[
|
|
1260 |
anyMore := false
|
|
1261 |
]
|
|
1262 |
].
|
|
1263 |
changeNr := changeNr + 1
|
|
1264 |
].
|
|
1265 |
|
|
1266 |
"finally delete what has been found"
|
|
1267 |
|
|
1268 |
(deleteSet size > 0) ifTrue:[
|
51
|
1269 |
changeListView deselect.
|
45
|
1270 |
index := deleteSet size.
|
|
1271 |
[index > 0] whileTrue:[
|
|
1272 |
self silentDeleteChange:(deleteSet at:index).
|
|
1273 |
index := index - 1
|
|
1274 |
].
|
|
1275 |
self setChangeList.
|
51
|
1276 |
"
|
|
1277 |
scroll back a bit, if we are left way behind the list
|
|
1278 |
"
|
49
|
1279 |
changeListView firstLineShown > changePositions size ifTrue:[
|
|
1280 |
changeListView makeLineVisible:changePositions size
|
45
|
1281 |
].
|
|
1282 |
self clearCodeView
|
|
1283 |
]
|
|
1284 |
]
|
|
1285 |
!
|
|
1286 |
|
73
|
1287 |
doApplyRest
|
|
1288 |
"user wants all changes from changeNr to be applied"
|
|
1289 |
|
|
1290 |
self withSelectedChangeDo:[:changeNr |
|
|
1291 |
self clearCodeView.
|
|
1292 |
skipSignal isNil ifTrue:[skipSignal := Signal new].
|
|
1293 |
changeNr to:(changePositions size) do:[:changeNr |
|
|
1294 |
changeListView selection:changeNr.
|
|
1295 |
self applyChange:changeNr
|
|
1296 |
].
|
|
1297 |
self autoSelect:changePositions size.
|
|
1298 |
]
|
|
1299 |
!
|
|
1300 |
|
51
|
1301 |
doApplyAll
|
|
1302 |
"user wants all changes to be applied"
|
45
|
1303 |
|
51
|
1304 |
self withCursor:(Cursor execute) do:[
|
|
1305 |
self clearCodeView.
|
|
1306 |
skipSignal isNil ifTrue:[skipSignal := Signal new].
|
|
1307 |
1 to:(changePositions size) do:[:changeNr |
|
|
1308 |
changeListView selection:changeNr.
|
|
1309 |
self applyChange:changeNr
|
|
1310 |
].
|
57
|
1311 |
self autoSelectLast
|
0
|
1312 |
]
|
|
1313 |
!
|
|
1314 |
|
51
|
1315 |
doWriteBack
|
|
1316 |
"write back the list onto the changes file"
|
|
1317 |
|
|
1318 |
anyChanges ifTrue:[
|
|
1319 |
self writeBackChanges.
|
|
1320 |
realized ifTrue:[
|
|
1321 |
self readChangesFileInBackground:false.
|
|
1322 |
realized ifTrue:[
|
|
1323 |
self setChangeList
|
|
1324 |
]
|
|
1325 |
]
|
|
1326 |
]
|
|
1327 |
!
|
|
1328 |
|
73
|
1329 |
doDeleteClassRest
|
|
1330 |
"delete rest of changes with same class as currently selected change"
|
|
1331 |
|
|
1332 |
self withSelectedChangeDo:[:changeNr |
|
|
1333 |
| classNameToDelete |
|
|
1334 |
|
|
1335 |
classNameToDelete := self classNameOfChange:changeNr.
|
|
1336 |
classNameToDelete notNil ifTrue:[
|
|
1337 |
changeListView selection:nil.
|
|
1338 |
self silentDeleteChangesFor:classNameToDelete
|
|
1339 |
from:changeNr
|
|
1340 |
to:(changePositions size).
|
|
1341 |
self setChangeList.
|
|
1342 |
self autoSelectOrEnd:changeNr
|
|
1343 |
]
|
|
1344 |
]
|
|
1345 |
!
|
|
1346 |
|
51
|
1347 |
doDeleteClassAll
|
|
1348 |
"delete all changes with same class as currently selected change"
|
|
1349 |
|
73
|
1350 |
self withSelectedChangeDo:[:changeNr |
|
|
1351 |
| classNameToDelete |
|
51
|
1352 |
|
73
|
1353 |
classNameToDelete := self classNameOfChange:changeNr.
|
|
1354 |
classNameToDelete notNil ifTrue:[
|
|
1355 |
changeListView selection:nil.
|
|
1356 |
self silentDeleteChangesFor:classNameToDelete
|
|
1357 |
from:1
|
|
1358 |
to:(changePositions size).
|
|
1359 |
self setChangeList.
|
|
1360 |
self autoSelectOrEnd:changeNr
|
51
|
1361 |
]
|
|
1362 |
]
|
|
1363 |
!
|
|
1364 |
|
|
1365 |
doApplyClassRest
|
|
1366 |
"user wants all changes for this class from changeNr to be applied"
|
|
1367 |
|
73
|
1368 |
self withSelectedChangeDo:[:changeNr |
|
|
1369 |
|thisClassName classNameToApply lastChange|
|
51
|
1370 |
|
73
|
1371 |
classNameToApply := self classNameOfChange:changeNr.
|
|
1372 |
classNameToApply notNil ifTrue:[
|
|
1373 |
self clearCodeView.
|
|
1374 |
skipSignal isNil ifTrue:[skipSignal := Signal new].
|
|
1375 |
changeNr to:(changePositions size) do:[:changeNr |
|
|
1376 |
thisClassName := self classNameOfChange:changeNr.
|
|
1377 |
thisClassName = classNameToApply ifTrue:[
|
|
1378 |
changeListView selection:changeNr.
|
|
1379 |
self applyChange:changeNr.
|
|
1380 |
lastChange := changeNr
|
51
|
1381 |
].
|
73
|
1382 |
].
|
|
1383 |
self autoSelect:lastChange.
|
51
|
1384 |
]
|
|
1385 |
]
|
|
1386 |
! !
|
|
1387 |
|
73
|
1388 |
!ChangesBrowser methodsFor:'initialize / release'!
|
|
1389 |
|
|
1390 |
initialize
|
|
1391 |
|frame v|
|
|
1392 |
|
|
1393 |
super initialize.
|
|
1394 |
|
|
1395 |
changeFileName := 'changes'.
|
|
1396 |
|
|
1397 |
frame := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1398 |
corner:(1.0 @ 1.0)
|
|
1399 |
borderWidth:0
|
|
1400 |
in:self.
|
|
1401 |
|
|
1402 |
v := ScrollableView for:SelectionInListView in:frame.
|
|
1403 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.3).
|
|
1404 |
changeListView := v scrolledView.
|
|
1405 |
changeListView delegate:self.
|
|
1406 |
changeListView model:self; menu:#changeListMenu.
|
|
1407 |
|
|
1408 |
v := HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:frame.
|
|
1409 |
v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
|
|
1410 |
codeView := v scrolledView.
|
|
1411 |
codeView readOnly.
|
|
1412 |
|
|
1413 |
anyChanges := false.
|
|
1414 |
ObjectMemory addDependent:self. "to get shutdown-update"
|
|
1415 |
!
|
|
1416 |
|
|
1417 |
focusSequence
|
|
1418 |
^ Array with:changeListView with:codeView
|
|
1419 |
!
|
|
1420 |
|
|
1421 |
realize
|
|
1422 |
super realize.
|
|
1423 |
self readChangesFileInBackground:true.
|
|
1424 |
self setChangeList.
|
|
1425 |
changeListView action:[:lineNr | self changeSelection:lineNr].
|
|
1426 |
|
|
1427 |
!
|
|
1428 |
|
|
1429 |
update:what
|
|
1430 |
|box|
|
|
1431 |
|
|
1432 |
(what == #aboutToExit) ifTrue:[
|
|
1433 |
"
|
|
1434 |
smalltalk is about to shut down -
|
|
1435 |
- if change list was modified, ask user and save if requested.
|
|
1436 |
"
|
|
1437 |
anyChanges ifTrue:[
|
|
1438 |
shown ifFalse:[
|
|
1439 |
self unrealize.
|
|
1440 |
self realize
|
|
1441 |
].
|
|
1442 |
self raise.
|
|
1443 |
|
|
1444 |
box := YesNoBox new.
|
|
1445 |
box title:(resources at:'ChangesBrowser:\changefile has not been updated from the modified changelist.\\Update before exiting ?') withCRs.
|
|
1446 |
box noText:(resources at:'don''t update').
|
|
1447 |
box okText:(resources at:'update').
|
|
1448 |
box yesAction:[self writeBackChanges]
|
|
1449 |
noAction:[].
|
|
1450 |
box showAtPointer
|
|
1451 |
].
|
|
1452 |
^ self
|
|
1453 |
].
|
|
1454 |
super update:what
|
|
1455 |
!
|
|
1456 |
|
|
1457 |
changeListMenu
|
|
1458 |
|labels selectors m|
|
|
1459 |
|
|
1460 |
labels := #(
|
|
1461 |
'apply change'
|
|
1462 |
'apply changes to end'
|
|
1463 |
'apply changes for this class to end'
|
|
1464 |
'apply all changes'
|
|
1465 |
'-'
|
|
1466 |
'delete'
|
|
1467 |
'delete to end'
|
|
1468 |
'delete changes for this class to end'
|
|
1469 |
'delete all changes for this class'
|
|
1470 |
'-'
|
|
1471 |
'update'
|
|
1472 |
'compress'
|
|
1473 |
'compare with current version'
|
|
1474 |
'browse class'
|
|
1475 |
'-'
|
|
1476 |
'make change a patch'
|
|
1477 |
"/ 'update sourcefile from change'
|
|
1478 |
"/ '-'
|
|
1479 |
'save change in file ...'
|
|
1480 |
'save changes to end in file ...'
|
|
1481 |
'save changes for this class to end in file ...'
|
|
1482 |
'save all changes for this class in file ...'
|
|
1483 |
'-'
|
|
1484 |
'writeback changeFile').
|
|
1485 |
|
|
1486 |
selectors := #(
|
|
1487 |
doApply
|
|
1488 |
doApplyRest
|
|
1489 |
doApplyClassRest
|
|
1490 |
doApplyAll
|
|
1491 |
nil
|
|
1492 |
doDelete
|
|
1493 |
doDeleteRest
|
|
1494 |
doDeleteClassRest
|
|
1495 |
doDeleteClassAll
|
|
1496 |
nil
|
|
1497 |
doUpdate
|
|
1498 |
doCompress
|
|
1499 |
doCompare
|
|
1500 |
doBrowse
|
|
1501 |
nil
|
|
1502 |
doMakePatch
|
|
1503 |
"/ doMakePermanent
|
|
1504 |
"/ nil
|
|
1505 |
doSave
|
|
1506 |
doSaveRest
|
|
1507 |
doSaveClassRest
|
|
1508 |
doSaveClassAll
|
|
1509 |
nil
|
|
1510 |
doWriteBack
|
|
1511 |
).
|
|
1512 |
|
|
1513 |
m := PopUpMenu
|
|
1514 |
labels:(resources array:labels)
|
|
1515 |
selectors:selectors.
|
|
1516 |
|
|
1517 |
changeListView hasSelection ifFalse:[
|
|
1518 |
#(doApply doApplyClassRest doApplyRest doDelete doDeleteRest doDeleteClassRest
|
|
1519 |
doDeleteClassAll doCompare doMakePatch doSaveChangeInFile doMakePermanent
|
|
1520 |
doSave doSaveRest doSaveClassAll doSaveClassRest doBrowse)
|
|
1521 |
do:[:sel |
|
|
1522 |
m disable:sel
|
|
1523 |
].
|
|
1524 |
].
|
|
1525 |
^ m
|
|
1526 |
|
|
1527 |
|
|
1528 |
! !
|
|
1529 |
|
|
1530 |
!ChangesBrowser methodsFor:'event handling '!
|
|
1531 |
|
|
1532 |
keyPress:key x:x y:y view:view
|
|
1533 |
"this method is reached via delegation from the changeListView"
|
|
1534 |
|
|
1535 |
key == #Delete ifTrue:[
|
|
1536 |
self doDelete.
|
|
1537 |
^ self
|
|
1538 |
].
|
|
1539 |
changeListView keyPress:key x:x y:y
|
|
1540 |
! !
|
|
1541 |
|
51
|
1542 |
!ChangesBrowser methodsFor:'termination'!
|
|
1543 |
|
|
1544 |
terminate
|
|
1545 |
"window manager wants us to go away"
|
|
1546 |
|
73
|
1547 |
|box action|
|
51
|
1548 |
|
|
1549 |
anyChanges ifTrue:[
|
73
|
1550 |
action := OptionBox
|
|
1551 |
request:(resources at:'changefile has not been updated from the modified changelist.\\Update before closing ?') withCRs
|
|
1552 |
label:'ChangesBrowser'
|
|
1553 |
form:(WarningBox iconBitmap)
|
|
1554 |
buttonLabels:#('abort' 'don''t update' 'update')
|
|
1555 |
values:#(#abort #ignore #save).
|
|
1556 |
action == #abort ifTrue:[^ self].
|
|
1557 |
action == #save ifTrue:[
|
|
1558 |
self writeBackChanges
|
|
1559 |
].
|
|
1560 |
].
|
|
1561 |
self destroy
|
51
|
1562 |
!
|
|
1563 |
|
|
1564 |
destroy
|
|
1565 |
"destroy the receiver; make certain, that boxes are destroyed too"
|
|
1566 |
|
|
1567 |
ObjectMemory removeDependent:self.
|
|
1568 |
super destroy
|
|
1569 |
!
|
|
1570 |
|
|
1571 |
saveAndTerminate
|
|
1572 |
"update the changes file and quit.
|
|
1573 |
Dont depend on this being sent, not all window managers
|
|
1574 |
send it; instead, they simply destroy the view."
|
|
1575 |
|
|
1576 |
anyChanges ifTrue:[
|
|
1577 |
self writeBackChanges.
|
|
1578 |
].
|
|
1579 |
self destroy
|
45
|
1580 |
! !
|
|
1581 |
|
|
1582 |
!ChangesBrowser methodsFor:'error handling'!
|
|
1583 |
|
|
1584 |
correctableError:aString position:relPos to:relEndPos
|
|
1585 |
"compiler notifys us of an error - this should really not happen since
|
|
1586 |
changes ought to be correct (did someone edit the changes file ??).
|
|
1587 |
Show the bad change in the codeView and let codeView hilight the error;
|
|
1588 |
no corrections allowed here therefore return false"
|
|
1589 |
|
73
|
1590 |
self error:aString position:relPos to:relEndPos.
|
45
|
1591 |
^ false
|
0
|
1592 |
!
|
|
1593 |
|
51
|
1594 |
warning:aString position:relPos to:relEndPos
|
|
1595 |
"compiler notifys us of a warning - ignore it"
|
|
1596 |
|
|
1597 |
^ self
|
|
1598 |
!
|
|
1599 |
|
45
|
1600 |
error:aString position:relPos to:relEndPos
|
|
1601 |
"compiler notifys us of an error - this should really not happen since
|
|
1602 |
changes ought to be correct (did someone edit the changes file ??).
|
|
1603 |
Show the bad change in the codeView and let codeView hilight the error"
|
0
|
1604 |
|
45
|
1605 |
|action|
|
0
|
1606 |
|
45
|
1607 |
(changeNrProcessed ~~ changeNrShown) ifTrue:[
|
|
1608 |
self changeSelection:changeNrProcessed
|
|
1609 |
].
|
|
1610 |
(skipSignal notNil) ifTrue:[
|
0
|
1611 |
|
45
|
1612 |
codeView highlightingErrorPosition:relPos to:relEndPos do:[
|
|
1613 |
|box|
|
0
|
1614 |
|
45
|
1615 |
"
|
|
1616 |
start dialog - make certain cleanup is done
|
|
1617 |
"
|
73
|
1618 |
action := OptionBox
|
|
1619 |
request:aString
|
|
1620 |
label:'Error'
|
|
1621 |
form:(WarningBox iconBitmap)
|
|
1622 |
buttonLabels:#('abort' 'skip' 'continue')
|
|
1623 |
values:#(#abort #skip #continue).
|
45
|
1624 |
].
|
0
|
1625 |
|
45
|
1626 |
action == #abort ifTrue:[
|
|
1627 |
Object abortSignal raise.
|
|
1628 |
^ false
|
|
1629 |
].
|
|
1630 |
action == #skip ifTrue:[
|
|
1631 |
skipSignal raise.
|
|
1632 |
^ false
|
|
1633 |
].
|
|
1634 |
^ false
|
|
1635 |
].
|
|
1636 |
^ codeView error:aString position:relPos to:relEndPos
|
|
1637 |
! !
|