0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
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 |
|
|
13 |
StandardSystemView subclass:#ChangesBrowser
|
|
14 |
instanceVariableNames:'changeListView codeView changeFileName
|
|
15 |
changeChunks changePositions
|
|
16 |
changeClassNames
|
|
17 |
anyChanges changeNrShown changeNrProcessed
|
|
18 |
closeBox'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Browsers'
|
|
22 |
!
|
|
23 |
|
|
24 |
ChangesBrowser comment:'
|
|
25 |
|
4
|
26 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
0
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
this class implements a changes browser.
|
|
30 |
|
15
|
31 |
$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.6 1994-01-08 17:22:50 claus Exp $
|
0
|
32 |
written jan 90 by claus
|
|
33 |
'!
|
|
34 |
|
|
35 |
!ChangesBrowser class methodsFor:'behavior'!
|
|
36 |
|
|
37 |
autoSelectNext
|
|
38 |
"returning true here, makes a Delete operation automatically
|
|
39 |
select the next change"
|
|
40 |
|
|
41 |
^ true
|
|
42 |
! !
|
|
43 |
|
|
44 |
!ChangesBrowser class methodsFor:'instance creation'!
|
|
45 |
|
|
46 |
new
|
|
47 |
"create a new changes browser"
|
|
48 |
|
|
49 |
^ super label:'Changes Browser'
|
|
50 |
icon:(Form fromFile:'CBrowser.xbm' resolution:100)
|
|
51 |
!
|
|
52 |
|
|
53 |
startOn:aFileName
|
|
54 |
"create c changes browser on a change file"
|
|
55 |
|
6
|
56 |
^ ((self new label:'Changes Browser:', aFileName) changeFileName:aFileName) open
|
0
|
57 |
! !
|
|
58 |
|
|
59 |
!ChangesBrowser methodsFor:'initialize / release'!
|
|
60 |
|
|
61 |
initialize
|
|
62 |
|frame v|
|
|
63 |
|
|
64 |
super initialize.
|
|
65 |
|
|
66 |
changeFileName := 'changes'.
|
|
67 |
|
|
68 |
frame := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
69 |
corner:(1.0 @ 1.0)
|
|
70 |
borderWidth:0
|
|
71 |
in:self.
|
|
72 |
|
|
73 |
v := ScrollableView for:SelectionInListView in:frame.
|
|
74 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.3).
|
|
75 |
changeListView := v scrolledView.
|
|
76 |
|
|
77 |
v := ScrollableView for:CodeView in:frame.
|
|
78 |
v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
|
|
79 |
codeView := v scrolledView.
|
|
80 |
|
|
81 |
anyChanges := false.
|
|
82 |
!
|
|
83 |
|
|
84 |
initializeMiddleButtonMenu
|
|
85 |
|labels|
|
|
86 |
|
1
|
87 |
labels := resources array:#(
|
0
|
88 |
'apply change'
|
|
89 |
'apply changes to end'
|
|
90 |
'apply all changes'
|
|
91 |
'-'
|
|
92 |
'delete'
|
|
93 |
'delete to end'
|
|
94 |
'delete changes for this class to end'
|
|
95 |
'delete all changes for this class'
|
|
96 |
'-'
|
|
97 |
'update'
|
|
98 |
'compress'
|
|
99 |
'compare with current version'
|
|
100 |
'-'
|
|
101 |
'make change a patch'
|
|
102 |
'update sourcefile from change'
|
|
103 |
'-'
|
|
104 |
'writeback changeFile').
|
|
105 |
|
|
106 |
changeListView
|
|
107 |
middleButtonMenu:(PopUpMenu
|
|
108 |
labels:labels
|
|
109 |
selectors:#(
|
|
110 |
doApply
|
|
111 |
doApplyRest
|
|
112 |
doApplyAll
|
|
113 |
nil
|
|
114 |
doDelete
|
|
115 |
doDeleteRest
|
|
116 |
doDeleteClassRest
|
|
117 |
doDeleteClassAll
|
|
118 |
nil
|
|
119 |
doUpdate
|
|
120 |
doCompress
|
|
121 |
doCompare
|
|
122 |
nil
|
|
123 |
doMakePatch
|
|
124 |
doMakePermanent
|
|
125 |
nil
|
|
126 |
doWriteBack)
|
|
127 |
receiver:self
|
|
128 |
for:changeListView)
|
|
129 |
!
|
|
130 |
|
|
131 |
realize
|
|
132 |
super realize.
|
|
133 |
self readChangesFile.
|
|
134 |
changeListView contents:changeChunks.
|
15
|
135 |
changeListView action:[:lineNr | self changeSelection:lineNr].
|
|
136 |
self disableMenuEntries.
|
0
|
137 |
!
|
|
138 |
|
|
139 |
destroy
|
6
|
140 |
closeBox notNil ifTrue:[closeBox destroy. closeBox := nil].
|
0
|
141 |
super destroy
|
|
142 |
! !
|
|
143 |
|
|
144 |
!ChangesBrowser methodsFor:'private'!
|
|
145 |
|
15
|
146 |
enableMenuEntries
|
|
147 |
"enable all entries refering to a class"
|
|
148 |
|
|
149 |
changeListView middleButtonMenu enable:#doApply.
|
|
150 |
changeListView middleButtonMenu enable:#doApplyRest.
|
|
151 |
changeListView middleButtonMenu enable:#doDelete.
|
|
152 |
changeListView middleButtonMenu enable:#doDeleteRest.
|
|
153 |
changeListView middleButtonMenu enable:#doDeleteClassRest.
|
|
154 |
changeListView middleButtonMenu enable:#doDeleteClassAll.
|
|
155 |
changeListView middleButtonMenu enable:#doCompare.
|
|
156 |
changeListView middleButtonMenu enable:#doMakePatch.
|
|
157 |
changeListView middleButtonMenu enable:#doMakePermanent.
|
|
158 |
!
|
|
159 |
|
|
160 |
disableMenuEntries
|
|
161 |
"enable all entries refering to a class"
|
|
162 |
|
|
163 |
changeListView middleButtonMenu disable:#doApply.
|
|
164 |
changeListView middleButtonMenu disable:#doApplyRest.
|
|
165 |
changeListView middleButtonMenu disable:#doDelete.
|
|
166 |
changeListView middleButtonMenu disable:#doDeleteRest.
|
|
167 |
changeListView middleButtonMenu disable:#doDeleteClassRest.
|
|
168 |
changeListView middleButtonMenu disable:#doDeleteClassAll.
|
|
169 |
changeListView middleButtonMenu disable:#doCompare.
|
|
170 |
changeListView middleButtonMenu disable:#doMakePatch.
|
|
171 |
changeListView middleButtonMenu disable:#doMakePermanent.
|
|
172 |
!
|
|
173 |
|
|
174 |
unselect
|
|
175 |
"common unselect"
|
|
176 |
|
|
177 |
changeListView deselect.
|
|
178 |
self disableMenuEntries
|
|
179 |
!
|
|
180 |
|
6
|
181 |
queryCloseText
|
15
|
182 |
"made this a method for easy redefinition in subclasses"
|
|
183 |
|
6
|
184 |
^ 'Quit without updating changeFile ?'
|
|
185 |
!
|
|
186 |
|
0
|
187 |
changeFileName:aFileName
|
|
188 |
changeFileName := aFileName
|
|
189 |
!
|
|
190 |
|
|
191 |
withCursor:aCursor do:aBlock
|
|
192 |
"evaluate aBlock while showing another cursor"
|
|
193 |
|
|
194 |
|oldListCursor oldCodeViewCursor|
|
|
195 |
|
|
196 |
oldListCursor := changeListView cursor.
|
|
197 |
oldCodeViewCursor := codeView cursor.
|
|
198 |
|
|
199 |
changeListView cursor:aCursor.
|
|
200 |
codeView cursor:aCursor.
|
|
201 |
|
|
202 |
aBlock valueNowOrOnUnwindDo:[
|
|
203 |
changeListView cursor:oldListCursor.
|
|
204 |
codeView cursor:oldCodeViewCursor
|
|
205 |
]
|
|
206 |
!
|
|
207 |
|
|
208 |
classNameOfChange:changeNr
|
|
209 |
"return the classname of a change (for xxx class - changes xxx is returned)
|
|
210 |
- since parsing ascii methods is slow, keep result cached in
|
|
211 |
changeClassNames for the next query"
|
|
212 |
|
|
213 |
|chunk aParseTree recTree sel name arg1Tree|
|
|
214 |
|
|
215 |
changeNr notNil ifTrue:[
|
|
216 |
name := changeClassNames at:changeNr.
|
|
217 |
name notNil ifTrue:[^ name].
|
|
218 |
|
|
219 |
chunk := changeChunks at:changeNr.
|
|
220 |
chunk notNil ifTrue:[
|
|
221 |
aParseTree := Parser parseExpression:chunk.
|
|
222 |
(aParseTree isKindOf:MessageNode) ifTrue:[
|
|
223 |
sel := aParseTree selector.
|
|
224 |
"a change for a method or a comment-change"
|
6
|
225 |
(#(methodsFor: removeSelector: comment:) includes:sel) ifTrue:[
|
0
|
226 |
recTree := aParseTree receiver.
|
|
227 |
(recTree isKindOf:UnaryNode) ifTrue:[
|
|
228 |
(recTree selector ~~ #class) ifTrue:[^ nil].
|
|
229 |
"id class methodsFor:..."
|
|
230 |
recTree := recTree receiver
|
|
231 |
].
|
|
232 |
(recTree isKindOf:PrimaryNode) ifTrue:[
|
|
233 |
name := recTree name.
|
|
234 |
changeClassNames at:changeNr put:name.
|
|
235 |
^ name
|
|
236 |
]
|
|
237 |
].
|
|
238 |
"a change in a class-description"
|
|
239 |
('subclass:*' match:sel) ifTrue:[
|
|
240 |
arg1Tree := aParseTree arg1.
|
|
241 |
(arg1Tree isKindOf:ConstantNode) ifTrue:[
|
|
242 |
name := arg1Tree value asString.
|
|
243 |
changeClassNames at:changeNr put:name.
|
|
244 |
^ name
|
|
245 |
]
|
|
246 |
]
|
|
247 |
]
|
|
248 |
]
|
|
249 |
].
|
|
250 |
^ nil
|
|
251 |
!
|
|
252 |
|
|
253 |
streamForChange:changeNr
|
|
254 |
"answer a stream for change"
|
|
255 |
|
|
256 |
|aStream|
|
|
257 |
|
|
258 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
259 |
aStream isNil ifTrue:[^ nil].
|
|
260 |
aStream position:(changePositions at:changeNr).
|
|
261 |
^ aStream
|
|
262 |
!
|
|
263 |
|
|
264 |
clearCodeView
|
15
|
265 |
self unselect "changeListView deselect".
|
0
|
266 |
codeView contents:nil.
|
|
267 |
changeNrShown := nil
|
|
268 |
!
|
|
269 |
|
|
270 |
autoSelect:changeNr
|
|
271 |
self class autoSelectNext ifTrue:[
|
|
272 |
(changeNr <= changeChunks size) ifTrue:[
|
|
273 |
changeListView selection:changeNr.
|
|
274 |
self changeSelection:changeNr.
|
|
275 |
^ self
|
|
276 |
]
|
|
277 |
].
|
|
278 |
self clearCodeView
|
|
279 |
!
|
|
280 |
|
|
281 |
writeBackChanges
|
|
282 |
"write back the changes file"
|
|
283 |
|
|
284 |
|inStream outStream chunk sawExcla excla done dir|
|
|
285 |
|
|
286 |
outStream := FileStream newFileNamed:'n_changes'.
|
|
287 |
outStream isNil ifTrue:[
|
|
288 |
self warn:'cannot create temporary file'.
|
|
289 |
^ self
|
|
290 |
].
|
|
291 |
|
|
292 |
inStream := FileStream readonlyFileNamed:changeFileName.
|
|
293 |
inStream isNil ifTrue:[^ nil].
|
|
294 |
|
|
295 |
self withCursor:(Cursor write) do:[
|
|
296 |
excla := inStream class chunkSeparator.
|
|
297 |
1 to:(changeChunks size) do:[:index |
|
|
298 |
inStream position:(changePositions at:index).
|
|
299 |
sawExcla := inStream peekFor:excla.
|
|
300 |
chunk := inStream nextChunk.
|
|
301 |
|
|
302 |
sawExcla ifTrue:[
|
|
303 |
outStream nextPut:excla.
|
|
304 |
outStream nextChunkPut:chunk.
|
|
305 |
outStream cr.
|
|
306 |
"a method-definition chunk - skip followups"
|
|
307 |
done := false.
|
|
308 |
[done] whileFalse:[
|
|
309 |
chunk := inStream nextChunk.
|
|
310 |
chunk isNil ifTrue:[
|
|
311 |
done := true
|
|
312 |
] ifFalse:[
|
|
313 |
outStream nextChunkPut:chunk.
|
|
314 |
outStream cr.
|
|
315 |
done := chunk isEmpty
|
|
316 |
]
|
|
317 |
].
|
|
318 |
0 "compiler kludge"
|
|
319 |
] ifFalse:[
|
|
320 |
outStream nextChunkPut:chunk.
|
|
321 |
outStream cr
|
|
322 |
]
|
|
323 |
].
|
|
324 |
outStream close.
|
|
325 |
inStream close.
|
|
326 |
dir := FileDirectory currentDirectory.
|
|
327 |
dir removeFile:changeFileName.
|
|
328 |
dir renameFile:'n_changes' newName:changeFileName.
|
|
329 |
anyChanges := false
|
|
330 |
]
|
|
331 |
!
|
|
332 |
|
|
333 |
readChangesFile
|
|
334 |
"read the changes file, create a list of header-lines and
|
|
335 |
a list of chunk-poritions"
|
|
336 |
|
|
337 |
|aStream index text done sawExcla chunkPos excla|
|
|
338 |
|
|
339 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
340 |
aStream isNil ifTrue:[^ nil].
|
|
341 |
|
|
342 |
self withCursor:(Cursor read) do:[
|
|
343 |
changeChunks := OrderedCollection new.
|
|
344 |
changePositions := OrderedCollection new.
|
|
345 |
excla := aStream class chunkSeparator.
|
|
346 |
|
|
347 |
[aStream atEnd] whileFalse:[
|
|
348 |
aStream skipSeparators.
|
|
349 |
chunkPos := aStream position.
|
|
350 |
sawExcla := aStream peekFor:excla.
|
|
351 |
text := aStream nextChunk.
|
|
352 |
text notNil ifTrue:[
|
|
353 |
changePositions add:chunkPos.
|
6
|
354 |
|
|
355 |
"only first line is saved in changeChunks ..."
|
0
|
356 |
index := text indexOf:(Character cr).
|
|
357 |
(index ~~ 0) ifTrue:[
|
6
|
358 |
text := text copyFrom:1 to:(index - 1).
|
|
359 |
|
|
360 |
"take care for comment changes - must still be a
|
|
361 |
valid expression for classNameOfChange: to work"
|
|
362 |
|
|
363 |
(text endsWith:'comment:''') ifTrue:[
|
|
364 |
text := text , '...'''
|
|
365 |
]
|
|
366 |
|
0
|
367 |
].
|
|
368 |
changeChunks add:text.
|
|
369 |
sawExcla ifTrue:[
|
|
370 |
"a method-definition chunk - skip followups"
|
|
371 |
done := false.
|
|
372 |
[done] whileFalse:[
|
|
373 |
text := aStream nextChunk.
|
|
374 |
text isNil ifTrue:[
|
|
375 |
done := true
|
|
376 |
] ifFalse:[
|
|
377 |
done := text isEmpty
|
|
378 |
]
|
|
379 |
]
|
|
380 |
]
|
|
381 |
]
|
|
382 |
].
|
1
|
383 |
changeClassNames := VariableArray new:(changeChunks size).
|
6
|
384 |
aStream close.
|
|
385 |
anyChanges := false
|
0
|
386 |
]
|
|
387 |
!
|
|
388 |
|
|
389 |
silentDeleteChange:changeNr
|
|
390 |
"delete a change do not update changeListView"
|
|
391 |
|
|
392 |
anyChanges := true.
|
|
393 |
changeChunks removeIndex:changeNr.
|
|
394 |
changePositions removeIndex:changeNr.
|
|
395 |
changeClassNames removeIndex:changeNr
|
|
396 |
!
|
|
397 |
|
|
398 |
|
|
399 |
deleteChange:changeNr
|
|
400 |
"delete a change"
|
|
401 |
|
|
402 |
changeListView deselect.
|
|
403 |
self silentDeleteChange:changeNr.
|
|
404 |
changeListView setContents:changeChunks
|
|
405 |
!
|
|
406 |
|
|
407 |
deleteChangesFrom:start to:stop
|
|
408 |
"delete a range of changes"
|
|
409 |
|
|
410 |
changeListView deselect.
|
|
411 |
stop to:start by:-1 do:[:changeNr |
|
|
412 |
self silentDeleteChange:changeNr
|
|
413 |
].
|
|
414 |
changeListView setContents:changeChunks
|
|
415 |
!
|
|
416 |
|
|
417 |
deleteChangesFor:aClassName from:start to:stop
|
|
418 |
"delete changes for a given class in a range"
|
|
419 |
|
|
420 |
|thisClassName index|
|
|
421 |
|
|
422 |
index := stop.
|
|
423 |
[index >= start] whileTrue:[
|
|
424 |
thisClassName := self classNameOfChange:index.
|
|
425 |
thisClassName = aClassName ifTrue:[
|
|
426 |
self silentDeleteChange:index
|
|
427 |
].
|
|
428 |
index := index - 1
|
|
429 |
]
|
|
430 |
!
|
|
431 |
|
|
432 |
applyChange:changeNr
|
|
433 |
"filein a change"
|
|
434 |
|
|
435 |
|aStream chunk sawExcla upd|
|
|
436 |
|
|
437 |
aStream := self streamForChange:changeNr.
|
|
438 |
aStream isNil ifTrue:[^ self].
|
|
439 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
440 |
chunk := aStream nextChunk.
|
1
|
441 |
upd := Class updateChanges:false.
|
|
442 |
codeView abortAction:[Class updateChanges:upd.
|
0
|
443 |
codeView abortAction:nil.
|
|
444 |
aStream close.
|
|
445 |
^self].
|
|
446 |
changeNrProcessed := changeNr.
|
|
447 |
[
|
|
448 |
sawExcla ifFalse:[
|
|
449 |
Compiler evaluate:chunk notifying:self
|
|
450 |
] ifTrue:[
|
|
451 |
(Compiler evaluate:chunk notifying:self) fileInFrom:aStream
|
|
452 |
notifying:self
|
|
453 |
].
|
|
454 |
changeNrProcessed := nil.
|
|
455 |
codeView abortAction:nil
|
|
456 |
] valueNowOrOnUnwindDo:[Class updateChanges:upd].
|
|
457 |
aStream close
|
|
458 |
!
|
|
459 |
|
|
460 |
compareChange:changeNr
|
|
461 |
"compare a change with current version"
|
|
462 |
|
|
463 |
|aStream chunk sawExcla parseTree thisClass cat oldSource newSource
|
|
464 |
parser sel oldMethod|
|
|
465 |
|
|
466 |
aStream := self streamForChange:changeNr.
|
|
467 |
aStream isNil ifTrue:[^ self].
|
|
468 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
469 |
chunk := aStream nextChunk.
|
|
470 |
sawExcla ifFalse:[
|
|
471 |
Transcript showCr:'not comparable ...'
|
|
472 |
] ifTrue:[
|
|
473 |
parseTree := Parser parseExpression:chunk.
|
|
474 |
(parseTree isKindOf:MessageNode) ifTrue:[
|
|
475 |
(parseTree selector == #methodsFor:) ifTrue:[
|
|
476 |
thisClass := (parseTree receiver evaluate).
|
|
477 |
(thisClass isBehavior "isKindOf:Class") ifTrue:[
|
|
478 |
cat := parseTree arg1 evaluate.
|
|
479 |
newSource := aStream nextChunk.
|
|
480 |
parser := Parser parseMethod:newSource in:thisClass.
|
|
481 |
parser notNil ifTrue:[
|
|
482 |
sel := parser selector.
|
|
483 |
oldMethod := thisClass compiledMethodAt:sel.
|
|
484 |
oldMethod notNil ifTrue:[
|
|
485 |
(oldMethod category = cat) ifFalse:[
|
|
486 |
Transcript showCr:'category changed.'
|
|
487 |
].
|
|
488 |
oldSource := oldMethod source.
|
|
489 |
(oldSource = newSource) ifTrue:[
|
|
490 |
Transcript showCr:'same source'
|
|
491 |
] ifFalse:[
|
|
492 |
Transcript showCr:'source changed.'
|
|
493 |
]
|
|
494 |
] ifFalse:[
|
|
495 |
Transcript showCr:'method does not exist.'
|
|
496 |
]
|
|
497 |
] ifFalse:[
|
|
498 |
Transcript showCr:'change unparsable.'
|
|
499 |
]
|
|
500 |
] ifFalse:[
|
|
501 |
Transcript showCr:'class does not exist.'
|
|
502 |
]
|
|
503 |
] ifFalse:[
|
|
504 |
Transcript showCr:'not comparable.'
|
|
505 |
]
|
|
506 |
] ifFalse:[
|
|
507 |
Transcript showCr:'not comparable.'
|
|
508 |
]
|
|
509 |
].
|
|
510 |
aStream close
|
|
511 |
!
|
|
512 |
|
|
513 |
makeChangeAPatch:changeNr
|
|
514 |
"copy change to patchfile"
|
|
515 |
|
|
516 |
|aStream outStream chunk sawExcla|
|
|
517 |
|
|
518 |
outStream := FileStream oldFileNamed:'patches'.
|
|
519 |
outStream isNil ifTrue:[
|
|
520 |
outStream isNil ifTrue:[
|
|
521 |
outStream := FileStream newFileNamed:'patches'.
|
|
522 |
outStream isNil ifTrue:[
|
|
523 |
self error:'cannot update patches file'.
|
|
524 |
^ self
|
|
525 |
]
|
|
526 |
]
|
|
527 |
].
|
|
528 |
outStream setToEnd.
|
|
529 |
aStream := self streamForChange:changeNr.
|
|
530 |
aStream isNil ifTrue:[^ self].
|
|
531 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
532 |
sawExcla ifTrue:[
|
|
533 |
outStream nextPut:$!!
|
|
534 |
].
|
|
535 |
chunk := aStream nextChunk.
|
|
536 |
outStream nextChunkPut:chunk.
|
|
537 |
outStream cr.
|
|
538 |
sawExcla ifTrue:[
|
|
539 |
chunk := aStream nextChunk.
|
|
540 |
outStream nextChunkPut:chunk.
|
|
541 |
outStream space
|
|
542 |
].
|
|
543 |
sawExcla ifTrue:[
|
|
544 |
outStream nextPut:$!!
|
|
545 |
].
|
|
546 |
outStream cr.
|
|
547 |
aStream close.
|
|
548 |
outStream close
|
|
549 |
!
|
|
550 |
|
|
551 |
makeChangePermanent:changeNr
|
|
552 |
"rewrite the source where change changeNr lies"
|
|
553 |
|
|
554 |
self notify:'this is not yet implemented'
|
|
555 |
! !
|
|
556 |
|
|
557 |
!ChangesBrowser methodsFor:'error handling'!
|
|
558 |
|
|
559 |
correctableError:aString position:relPos to:relEndPos
|
|
560 |
"compiler notifys us of an error - this should really not happen since
|
|
561 |
changes ought to be correct (did someone edit the changes file ??).
|
|
562 |
Show the bad change in the codeView and let codeView hilight the error;
|
|
563 |
no corrections allowed here therefore return false"
|
|
564 |
|
|
565 |
(changeNrProcessed ~~ changeNrShown) ifTrue:[
|
|
566 |
self changeSelection:changeNrProcessed
|
|
567 |
].
|
|
568 |
codeView error:aString position:relPos to:relEndPos.
|
|
569 |
^ false
|
|
570 |
!
|
|
571 |
|
|
572 |
error:aString position:relPos to:relEndPos
|
|
573 |
"compiler notifys us of an error - this should really not happen since
|
|
574 |
changes ought to be correct (did someone edit the changes file ??).
|
|
575 |
Show the bad change in the codeView and let codeView hilight the error"
|
|
576 |
|
|
577 |
(changeNrProcessed ~~ changeNrShown) ifTrue:[
|
|
578 |
self changeSelection:changeNrProcessed
|
|
579 |
].
|
|
580 |
^ codeView error:aString position:relPos to:relEndPos
|
|
581 |
!
|
|
582 |
|
|
583 |
warning:aString position:relPos to:relEndPos
|
|
584 |
"compiler notifys us of a warning - ignore it"
|
|
585 |
|
|
586 |
^ self
|
|
587 |
! !
|
|
588 |
|
|
589 |
!ChangesBrowser methodsFor:'user interaction'!
|
|
590 |
|
|
591 |
noChangesAllowed
|
|
592 |
"show a warning that changes cannot be changed"
|
|
593 |
|
1
|
594 |
self warn:(resources at:'changes are not allowed to be changed')
|
0
|
595 |
!
|
|
596 |
|
|
597 |
changeSelection:lineNr
|
|
598 |
"show a change in the codeView"
|
|
599 |
|
|
600 |
|aStream sawExcla chunk|
|
|
601 |
|
|
602 |
aStream := self streamForChange:lineNr.
|
|
603 |
aStream isNil ifTrue:[^ self].
|
|
604 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
605 |
chunk := aStream nextChunk.
|
|
606 |
sawExcla ifTrue:[
|
|
607 |
chunk := aStream nextChunk
|
|
608 |
].
|
|
609 |
aStream close.
|
|
610 |
codeView contents:chunk.
|
13
|
611 |
codeView acceptAction:[:theCode | self doApply "noChangesAllowed"].
|
15
|
612 |
changeNrShown := lineNr.
|
|
613 |
self enableMenuEntries
|
0
|
614 |
!
|
|
615 |
|
|
616 |
doMakePermanent
|
|
617 |
"user wants a change to be made permanent
|
|
618 |
- rewrite the source file where this change has to go"
|
|
619 |
|
|
620 |
|changeNr yesNoBox|
|
|
621 |
|
|
622 |
yesNoBox isNil ifTrue:[
|
|
623 |
yesNoBox := YesNoBox new
|
|
624 |
].
|
1
|
625 |
yesNoBox title:(resources at:'Warning: this operation cannot be undone').
|
|
626 |
yesNoBox okText:(resources at:'apply').
|
|
627 |
yesNoBox noText:(resources at:'abort').
|
0
|
628 |
yesNoBox okAction:[
|
|
629 |
changeNr := changeListView selection.
|
|
630 |
changeNr notNil ifTrue:[
|
|
631 |
self makeChangePermanent:changeNr.
|
|
632 |
self autoSelect:(changeNr + 1)
|
|
633 |
]
|
|
634 |
].
|
|
635 |
yesNoBox showAtPointer
|
|
636 |
!
|
|
637 |
|
|
638 |
doMakePatch
|
|
639 |
"user wants a change to be made a patch
|
|
640 |
- copy it over to the patches file"
|
|
641 |
|
|
642 |
|changeNr|
|
|
643 |
|
|
644 |
changeNr := changeListView selection.
|
|
645 |
changeNr notNil ifTrue:[
|
|
646 |
self makeChangeAPatch:changeNr.
|
|
647 |
self autoSelect:(changeNr + 1)
|
|
648 |
]
|
|
649 |
!
|
|
650 |
|
|
651 |
doApply
|
|
652 |
"user wants a change to be applied"
|
|
653 |
|
|
654 |
|changeNr|
|
|
655 |
|
|
656 |
changeNr := changeListView selection.
|
|
657 |
changeNr notNil ifTrue:[
|
|
658 |
self withCursor:(Cursor execute) do:[
|
|
659 |
self applyChange:changeNr.
|
|
660 |
self autoSelect:(changeNr + 1)
|
|
661 |
]
|
|
662 |
]
|
|
663 |
!
|
|
664 |
|
|
665 |
doApplyAll
|
|
666 |
"user wants all changes to be applied"
|
|
667 |
|
|
668 |
self withCursor:(Cursor execute) do:[
|
|
669 |
self clearCodeView.
|
|
670 |
1 to:(changePositions size) do:[:changeNr |
|
|
671 |
changeListView selection:changeNr.
|
|
672 |
self applyChange:changeNr
|
|
673 |
]
|
|
674 |
]
|
|
675 |
!
|
|
676 |
|
|
677 |
doApplyRest
|
|
678 |
"user wants all changes from changeNr to be applied"
|
|
679 |
|
|
680 |
|changeNr|
|
|
681 |
|
|
682 |
changeNr := changeListView selection.
|
|
683 |
changeNr notNil ifTrue:[
|
|
684 |
self withCursor:(Cursor execute) do:[
|
|
685 |
self clearCodeView.
|
|
686 |
changeNr to:(changePositions size) do:[:changeNr |
|
|
687 |
changeListView selection:changeNr.
|
|
688 |
self applyChange:changeNr
|
|
689 |
]
|
|
690 |
]
|
|
691 |
]
|
|
692 |
!
|
|
693 |
|
|
694 |
doDelete
|
|
695 |
"delete currently selected change"
|
|
696 |
|
|
697 |
|changeNr|
|
|
698 |
|
|
699 |
changeNr := changeListView selection.
|
|
700 |
changeNr notNil ifTrue:[
|
|
701 |
self deleteChange:changeNr.
|
|
702 |
self autoSelect:changeNr
|
|
703 |
]
|
|
704 |
!
|
|
705 |
|
|
706 |
doDeleteClassRest
|
|
707 |
"delete rest of changes with same class as currently selected change"
|
|
708 |
|
|
709 |
|changeNr classNameToDelete|
|
|
710 |
|
|
711 |
changeNr := changeListView selection.
|
|
712 |
changeNr notNil ifTrue:[
|
|
713 |
self withCursor:(Cursor execute) do:[
|
|
714 |
classNameToDelete := self classNameOfChange:changeNr.
|
|
715 |
classNameToDelete notNil ifTrue:[
|
|
716 |
changeListView selection:nil.
|
|
717 |
self deleteChangesFor:classNameToDelete
|
|
718 |
from:changeNr
|
|
719 |
to:(changeChunks size).
|
|
720 |
changeListView setContents:changeChunks.
|
|
721 |
self autoSelect:changeNr
|
|
722 |
]
|
|
723 |
]
|
|
724 |
]
|
|
725 |
!
|
|
726 |
|
|
727 |
doDeleteRest
|
|
728 |
"delete all changes from current to the end"
|
|
729 |
|
|
730 |
|changeNr|
|
|
731 |
|
|
732 |
changeNr := changeListView selection.
|
|
733 |
changeNr notNil ifTrue:[
|
|
734 |
self deleteChangesFrom:changeNr to:(changeChunks size).
|
|
735 |
self clearCodeView
|
|
736 |
]
|
|
737 |
!
|
|
738 |
|
|
739 |
doDeleteClassAll
|
|
740 |
"delete all changes with same class as currently selected change"
|
|
741 |
|
|
742 |
|changeNr classNameToDelete|
|
|
743 |
|
|
744 |
changeNr := changeListView selection.
|
|
745 |
changeNr notNil ifTrue:[
|
|
746 |
self withCursor:(Cursor execute) do:[
|
|
747 |
classNameToDelete := self classNameOfChange:changeNr.
|
|
748 |
classNameToDelete notNil ifTrue:[
|
|
749 |
changeListView selection:nil.
|
|
750 |
self deleteChangesFor:classNameToDelete
|
|
751 |
from:1
|
|
752 |
to:(changeChunks size).
|
|
753 |
changeListView contents:changeChunks.
|
|
754 |
self autoSelect:changeNr
|
|
755 |
]
|
|
756 |
]
|
|
757 |
]
|
|
758 |
!
|
|
759 |
|
|
760 |
doWriteBack
|
15
|
761 |
"write back the list onto the changes file"
|
|
762 |
|
0
|
763 |
anyChanges ifTrue:[
|
|
764 |
self writeBackChanges.
|
|
765 |
self doUpdate
|
|
766 |
]
|
|
767 |
!
|
|
768 |
|
|
769 |
saveAndTerminate
|
15
|
770 |
"update the changes file and quit"
|
0
|
771 |
|
|
772 |
self doWriteBack.
|
|
773 |
self destroy
|
|
774 |
!
|
|
775 |
|
|
776 |
terminate
|
|
777 |
"window manager wants ChangeBrowser to vanish"
|
|
778 |
|
|
779 |
anyChanges ifTrue:[
|
|
780 |
closeBox isNil ifTrue:[closeBox := YesNoBox new].
|
6
|
781 |
closeBox title:(resources at:(self queryCloseText)).
|
0
|
782 |
closeBox yesAction:[self destroy] noAction:nil.
|
|
783 |
closeBox showAtPointer
|
|
784 |
] ifFalse:[
|
|
785 |
self destroy
|
|
786 |
]
|
|
787 |
!
|
|
788 |
|
|
789 |
doUpdate
|
15
|
790 |
"reread the changes-file"
|
0
|
791 |
|
|
792 |
self readChangesFile.
|
15
|
793 |
changeListView setContents:changeChunks
|
0
|
794 |
!
|
|
795 |
|
|
796 |
doCompare
|
|
797 |
"compare change with current system version
|
|
798 |
- give a note in transcript"
|
|
799 |
|
|
800 |
|changeNr|
|
|
801 |
|
|
802 |
changeNr := changeListView selection.
|
|
803 |
changeNr notNil ifTrue:[
|
|
804 |
self compareChange:changeNr
|
|
805 |
]
|
|
806 |
!
|
|
807 |
|
|
808 |
doCompress
|
|
809 |
"compress the change-set; this replaces multiple method-changes by the last
|
|
810 |
(i.e. the most recent) change"
|
|
811 |
|
|
812 |
|classes types selectors thisClass thisSelector
|
|
813 |
aStream chunk changeNr sawExcla aParseTree codeChunk codeParser
|
|
814 |
searchIndex anyMore deleteSet index parseTreeChunk numChanges
|
|
815 |
excla|
|
|
816 |
|
|
817 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
818 |
aStream isNil ifTrue:[^ self].
|
|
819 |
|
|
820 |
self withCursor:(Cursor execute) do:[
|
|
821 |
numChanges := changePositions size.
|
|
822 |
classes := Array new:numChanges.
|
|
823 |
selectors := Array new:numChanges.
|
|
824 |
types := Array new:numChanges.
|
|
825 |
|
|
826 |
"starting at the end, get the change class and change selector;
|
|
827 |
collect all in classes / selectors"
|
|
828 |
|
|
829 |
changeNr := numChanges.
|
|
830 |
excla := aStream class chunkSeparator.
|
|
831 |
|
|
832 |
[changeNr >= 1] whileTrue:[
|
|
833 |
aStream position:(changePositions at:changeNr).
|
|
834 |
sawExcla := aStream peekFor:excla.
|
|
835 |
chunk := aStream nextChunk.
|
|
836 |
sawExcla ifTrue:[
|
|
837 |
"optimize a bit if multiple methods for same category arrive"
|
|
838 |
(chunk = parseTreeChunk) ifFalse:[
|
|
839 |
aParseTree := Parser parseExpression:chunk.
|
|
840 |
parseTreeChunk := chunk
|
|
841 |
].
|
|
842 |
(aParseTree isKindOf:MessageNode) ifTrue:[
|
|
843 |
(aParseTree selector == #methodsFor:) ifTrue:[
|
|
844 |
thisClass := (aParseTree receiver evaluate).
|
|
845 |
codeChunk := aStream nextChunk.
|
|
846 |
codeParser := Parser parseMethodSpecification:codeChunk
|
|
847 |
in:thisClass.
|
|
848 |
codeParser notNil ifTrue:[
|
|
849 |
selectors at:changeNr put:(codeParser selector).
|
|
850 |
classes at:changeNr put:thisClass.
|
|
851 |
types at:changeNr put:#methodsFor
|
|
852 |
]
|
|
853 |
]
|
|
854 |
]
|
|
855 |
] ifFalse:[
|
|
856 |
aParseTree := Parser parseExpression:chunk.
|
|
857 |
parseTreeChunk := chunk.
|
|
858 |
(aParseTree isKindOf:MessageNode) ifTrue:[
|
|
859 |
(aParseTree selector == #removeSelector:) ifTrue:[
|
|
860 |
selectors at:changeNr put:(aParseTree arg1 value ).
|
|
861 |
classes at:changeNr put:(aParseTree receiver evaluate).
|
|
862 |
types at:changeNr put:#removeSelector
|
|
863 |
]
|
|
864 |
]
|
|
865 |
].
|
|
866 |
changeNr := changeNr - 1
|
|
867 |
].
|
|
868 |
aStream close.
|
|
869 |
|
|
870 |
"for all changes, look for another class/selector occurence and
|
|
871 |
add change number to delete set if found"
|
|
872 |
|
|
873 |
deleteSet := OrderedCollection new.
|
|
874 |
changeNr := 1.
|
|
875 |
[changeNr < changePositions size] whileTrue:[
|
|
876 |
thisClass := classes at:changeNr.
|
|
877 |
thisSelector := selectors at:changeNr.
|
|
878 |
searchIndex := changeNr.
|
|
879 |
anyMore := true.
|
|
880 |
[anyMore] whileTrue:[
|
|
881 |
searchIndex := classes indexOf:thisClass
|
|
882 |
startingAt:(searchIndex + 1).
|
|
883 |
(searchIndex ~~ 0) ifTrue:[
|
|
884 |
((selectors at:searchIndex) == thisSelector) ifTrue:[
|
|
885 |
thisClass notNil ifTrue:[
|
|
886 |
deleteSet add:changeNr.
|
|
887 |
anyMore := false
|
|
888 |
]
|
|
889 |
]
|
|
890 |
] ifFalse:[
|
|
891 |
anyMore := false
|
|
892 |
]
|
|
893 |
].
|
|
894 |
changeNr := changeNr + 1
|
|
895 |
].
|
|
896 |
|
|
897 |
"finally delete what has been found"
|
|
898 |
|
|
899 |
(deleteSet size > 0) ifTrue:[
|
|
900 |
changeListView selection:nil.
|
|
901 |
index := deleteSet size.
|
|
902 |
[index > 0] whileTrue:[
|
|
903 |
self silentDeleteChange:(deleteSet at:index).
|
|
904 |
index := index - 1
|
|
905 |
].
|
15
|
906 |
changeListView setContents:changeChunks.
|
|
907 |
changeListView firstLineShown > changeChunks size ifTrue:[
|
|
908 |
changeListView makeLineVisible:changeChunks size
|
|
909 |
].
|
0
|
910 |
self clearCodeView
|
|
911 |
]
|
|
912 |
]
|
|
913 |
! !
|