ChangesBrowser.st
changeset 11397 5b04140c959f
parent 11396 c0b421d2e7aa
child 11475 b6fdfe902263
equal deleted inserted replaced
11396:c0b421d2e7aa 11397:5b04140c959f
    60 "
    60 "
    61 !
    61 !
    62 
    62 
    63 documentation
    63 documentation
    64 "
    64 "
    65     this implements a browser for the changes-file (actually, it can display
    65     this implements a browser for the changes-file 
    66     any sourceFiles contents).
    66     (actually, it can display any sourceFile's contents).
    67     See the extra document 'doc/misc/cbrowser.doc' for how to use this browser.
    67     See the extra document 'doc/misc/cbrowser.doc' for how to use this browser.
    68 
    68 
    69     written jan 90 by claus
    69     written jan 90 by claus
    70 
    70 
    71     This is a very old leftover class (The Merovingian has not yet detected this one ;-)
    71     This is a very old leftover class (it was one of the very first apps in ST/X
       
    72     and the Merovingian has not yet detected this one ;-)
    72     It will be completely replaced by the ChangeSetBrowser class in the near future.
    73     It will be completely replaced by the ChangeSetBrowser class in the near future.
    73 
    74 
    74 
    75 
    75     [Class variables:]
    76     [Class variables:]
    76 	CompressSnapshotInfo            if true (the default), snapshot entries
    77         CompressSnapshotInfo            if true (the default), snapshot entries
    77 					are also compressed in the compress function.
    78                                         are also compressed in the compress function.
    78 					Some users prefer them to be not compressed.
    79                                         Some users prefer them to be not compressed.
    79 					Set it to false for this.
    80                                         Set it to false for this.
    80 
    81 
    81     Notice:
    82     Notice:
    82 	this needs a total rewrite, to build up a changeSet from the file
    83         this needs a total rewrite, to build up a changeSet from the file
    83 	(which did not exist when the ChangesBrowser was originally written)
    84         (which did not exist when the ChangesBrowser was originally written)
    84 	and manipulate that changeSet.
    85         and manipulate that changeSet.
    85 
    86 
    86 	This way, we get a browser for any upcoming incore changeSets for
    87         This way, we get a browser for any upcoming incore changeSets for
    87 	free. Also, this will put the chunk analyzation code into Change and
    88         free. Also, this will put the chunk analysation code into Change and
    88 	subclasses (where it belongs) and give a better encapsulation and
    89         subclasses (where it belongs) and give a better encapsulation and
    89 	overall structure. Do not take this as an example for good style ;-)
    90         overall structure. Do not take this as an example for good style ;-)
    90 
    91 
    91 	The Change hierarchy is currently been completed, and the changes browser
    92         The Change hierarchy is currently been completed, and the changes browser
    92 	will be adapted soon.
    93         will be adapted soon.
    93 
    94 
    94     [author:]
    95     [author:]
    95 	Claus Gittinger
    96         Claus Gittinger
    96 
    97 
    97     [start with:]
    98     [start with:]
    98 	ChangesBrowser open
    99         ChangesBrowser open
    99 
   100 
   100     [see also:]
   101     [see also:]
   101 	( Using the ChangesBrowser :html: tools/cbrowser/TOP.html )
   102         ( Using the ChangesBrowser :html: tools/cbrowser/TOP.html )
   102 
   103 
   103 "
   104 "
   104 ! !
   105 ! !
   105 
   106 
   106 !ChangesBrowser class methodsFor:'instance creation'!
   107 !ChangesBrowser class methodsFor:'instance creation'!
  2158 !
  2159 !
  2159 
  2160 
  2160 classNameFromAttributeChangeParseTree:aParseTree
  2161 classNameFromAttributeChangeParseTree:aParseTree
  2161     "mhmh - seems to always return the name of the nonMeta class - is this OK?"
  2162     "mhmh - seems to always return the name of the nonMeta class - is this OK?"
  2162 
  2163 
  2163     |recTree isMeta|
  2164     |recTree isMeta name|
  2164 
  2165 
  2165     recTree := aParseTree receiver.
  2166     recTree := aParseTree receiver.
  2166 
  2167 
  2167     (recTree notNil
  2168     (recTree notNil
  2168     and:[recTree ~~ #Error
  2169     and:[recTree ~~ #Error
  2188 
  2189 
  2189     "Created: / 08-03-2012 / 09:42:36 / cg"
  2190     "Created: / 08-03-2012 / 09:42:36 / cg"
  2190 !
  2191 !
  2191 
  2192 
  2192 classNameFromClassDefinitionChange:changeNr
  2193 classNameFromClassDefinitionChange:changeNr
  2193     |changeStream chunk fullParseTree sel arg1Tree ownerTree ownerName|
  2194     |changeStream chunk fullParseTree sel arg1Tree ownerTree ownerName name|
  2194 
  2195 
  2195     "/ must parse the full changes text, to get privacy information.
  2196     "/ must parse the full changes text, to get privacy information.
  2196 
  2197 
  2197     changeStream := self streamForChange:changeNr.
  2198     changeStream := self streamForChange:changeNr.
  2198     changeStream isNil ifTrue:[ ^ nil].
  2199     changeStream isNil ifTrue:[ ^ nil].
  2261 
  2262 
  2262     "Created: / 08-03-2012 / 09:26:57 / cg"
  2263     "Created: / 08-03-2012 / 09:26:57 / cg"
  2263 !
  2264 !
  2264 
  2265 
  2265 classNameFromRemoveClassParseTree:aParseTree
  2266 classNameFromRemoveClassParseTree:aParseTree
       
  2267     "tree is: Smalltalk removeClass: class"
       
  2268 
  2266     |recTree arg1Tree|
  2269     |recTree arg1Tree|
  2267 
  2270 
  2268     recTree := aParseTree receiver.
  2271     recTree := aParseTree receiver.
  2269 
  2272 
  2270     (recTree notNil
  2273     (recTree notNil
  2271     and:[recTree ~~ #Error
  2274     and:[recTree ~~ #Error
  2272     and:[recTree isPrimary
  2275     and:[recTree isPrimary
  2273     and:[recTree name = 'Smalltalk']]]) ifTrue:[
  2276     and:[recTree name = 'Smalltalk']]]) ifTrue:[
  2274         arg1Tree := aParseTree arg1.
  2277         arg1Tree := aParseTree arg1.
  2275         (arg1Tree notNil and:[arg1Tree isPrimary]) ifTrue:[
  2278         (arg1Tree notNil and:[arg1Tree isPrimary]) ifTrue:[
  2276             name := arg1Tree name.
  2279             ^ arg1Tree name.
  2277             ^ name
       
  2278         ].
  2280         ].
  2279     ].
  2281     ].
  2280     "very strange"
  2282     "very strange"
  2281     ^ nil
  2283     ^ nil
  2282 
  2284 
  2283     "Created: / 08-03-2012 / 09:36:59 / cg"
  2285     "Created: / 08-03-2012 / 09:36:59 / cg"
       
  2286 !
       
  2287 
       
  2288 classNameFromRenameClassParseTree:aParseTree
       
  2289     "tree is: Smalltalk renameClass: oldClass to: 'newName'"
       
  2290 
       
  2291     |recTree arg1Tree arg2Tree oldName newName|
       
  2292 
       
  2293     recTree := aParseTree receiver.
       
  2294 
       
  2295     (recTree notNil
       
  2296     and:[recTree ~~ #Error
       
  2297     and:[recTree isPrimary
       
  2298     and:[recTree name = 'Smalltalk']]]) ifTrue:[
       
  2299         arg1Tree := aParseTree arg1.
       
  2300         (arg1Tree notNil and:[arg1Tree isPrimary]) ifTrue:[
       
  2301             oldName := arg1Tree name.
       
  2302             arg2Tree := aParseTree arg2.
       
  2303             (arg2Tree notNil and:[arg2Tree isConstant]) ifTrue:[
       
  2304                 newName := arg2Tree evaluate.
       
  2305                 (Smalltalk classNamed:oldName) notNil ifTrue:[^ oldName ].
       
  2306                 (Smalltalk classNamed:newName) notNil ifTrue:[^ newName ].
       
  2307             ].
       
  2308         ].
       
  2309     ].
       
  2310     "very strange"
       
  2311     ^ nil
       
  2312 
       
  2313     "Created: / 08-03-2012 / 11:42:25 / cg"
  2284 !
  2314 !
  2285 
  2315 
  2286 classNameOfChange:changeNr
  2316 classNameOfChange:changeNr
  2287     "return the classname of a change
  2317     "return the classname of a change
  2288      (for classChanges (i.e. xxx class), the non-metaClassName (i.e. xxx) is returned)"
  2318      (for classChanges (i.e. xxx class), the non-metaClassName (i.e. xxx) is returned)"
  2480     or:[sel == #privacy:]]) ifTrue:[
  2510     or:[sel == #privacy:]]) ifTrue:[
  2481         ^ self classNameFromAttributeChangeParseTree:aParseTree
  2511         ^ self classNameFromAttributeChangeParseTree:aParseTree
  2482     ].
  2512     ].
  2483 
  2513 
  2484     sel == #renameClass:to: ifTrue:[
  2514     sel == #renameClass:to: ifTrue:[
       
  2515         ^ self classNameFromRenameClassParseTree:aParseTree
  2485     ].
  2516     ].
  2486 
  2517 
  2487     ^ nil
  2518     ^ nil
  2488 
  2519 
  2489     "Modified (format): / 08-03-2012 / 09:51:54 / cg"
  2520     "Modified: / 08-03-2012 / 11:42:32 / cg"
  2490 !
  2521 !
  2491 
  2522 
  2492 numberOfChanges
  2523 numberOfChanges
  2493     ^ changePositions size
  2524     ^ changePositions size
  2494 
  2525 
  5342 !
  5373 !
  5343 
  5374 
  5344 findNextForWhich:aBlock startingAt:changeNrToStartSearch
  5375 findNextForWhich:aBlock startingAt:changeNrToStartSearch
  5345     "helper: select the next change for which aBlock evaluates to true"
  5376     "helper: select the next change for which aBlock evaluates to true"
  5346 
  5377 
       
  5378     ^ self     
       
  5379         findNextOrPrevious:#next 
       
  5380         forWhich:aBlock startingAt:changeNrToStartSearch
       
  5381 
       
  5382     "Created: / 20-11-2006 / 16:34:06 / cg"
       
  5383 !
       
  5384 
       
  5385 findNextOrPrevious:direction forWhich:aBlock startingAt:changeNrToStartSearch
       
  5386     "helper: find and select the next or previous change for which aBlock evaluates to true"
       
  5387 
  5347     self withCursor:Cursor questionMark do:[
  5388     self withCursor:Cursor questionMark do:[
  5348         Object userInterruptSignal handle:[:ex |
  5389         Object userInterruptSignal handle:[:ex |
  5349             self beep.
  5390             self beep.
  5350             ^ 0
  5391             ^ 0
  5351         ] do:[
  5392         ] do:[
  5352             |lastNr nr|
  5393             |increment nr lastNr|
  5353 
  5394 
       
  5395             increment := (direction == #previous) ifTrue:[-1] ifFalse:[1].
  5354             lastNr := self numberOfChanges.
  5396             lastNr := self numberOfChanges.
  5355             nr := changeNrToStartSearch.
  5397             nr := changeNrToStartSearch.
  5356             [nr <= lastNr] whileTrue:[
  5398             [ (direction == #previous and:[nr >= 1])
       
  5399               or:[ direction == #next and:[ nr <= lastNr]] 
       
  5400             ] whileTrue:[
  5357                 (aBlock value:nr) ifTrue:[
  5401                 (aBlock value:nr) ifTrue:[
  5358                     changeListView setSelection:nr .
  5402                     changeListView setSelection:nr.
  5359                     self changeSelection:nr.
  5403                     self changeSelection:nr.
  5360                     ^ nr
  5404                     ^ nr
  5361                 ].
  5405                 ].
  5362                 nr := nr + 1.
  5406                 nr := nr + increment.
  5363             ].
  5407             ].
  5364         ].
  5408         ]
  5365     ].
  5409     ].
  5366     self showNotFound.
  5410     self showNotFound.
  5367     self windowGroup sensor flushKeyboard. "/ avoid multiple beeps, in case of type ahead
  5411     self windowGroup sensor flushKeyboard. "/ avoid multiple beeps, in case of type ahead
  5368     ^ 0
  5412     ^ 0
  5369 
  5413 
  5370     "Created: / 20-11-2006 / 16:34:06 / cg"
  5414     "Created: / 08-03-2012 / 11:57:26 / cg"
  5371 !
  5415 !
  5372 
  5416 
  5373 findNextSnapshot
  5417 findNextSnapshot
  5374     "findNextSnapshot menu action: select the next change which is for a snapShot-image save action"
  5418     "findNextSnapshot menu action: select the next change which is for a snapShot-image save action"
  5375 
  5419 
  5518 !
  5562 !
  5519 
  5563 
  5520 findPreviousForWhich:aBlock startingAt:changeNrToStartSearch
  5564 findPreviousForWhich:aBlock startingAt:changeNrToStartSearch
  5521     "helper: select the previous change for which aBlock evaluates to true"
  5565     "helper: select the previous change for which aBlock evaluates to true"
  5522 
  5566 
  5523     self withCursor:Cursor questionMark do:[
  5567     ^ self     
  5524         Object userInterruptSignal handle:[:ex |
  5568         findNextOrPrevious:#previous 
  5525             self beep.
  5569         forWhich:aBlock startingAt:changeNrToStartSearch
  5526             ^ 0
       
  5527         ] do:[
       
  5528             |nr|
       
  5529 
       
  5530             nr := changeNrToStartSearch.
       
  5531             [nr >= 1] whileTrue:[
       
  5532                 (aBlock value:nr) ifTrue:[
       
  5533                     changeListView setSelection:nr.
       
  5534                     self changeSelection:nr.
       
  5535                     ^ nr
       
  5536                 ].
       
  5537                 nr := nr - 1.
       
  5538             ].
       
  5539         ]
       
  5540     ].
       
  5541     self showNotFound.
       
  5542     self windowGroup sensor flushKeyboard. "/ avoid multiple beeps, in case of type ahead
       
  5543     ^ 0
       
  5544 
  5570 
  5545     "Created: / 06-10-2006 / 11:01:09 / cg"
  5571     "Created: / 06-10-2006 / 11:01:09 / cg"
  5546 !
  5572 !
  5547 
  5573 
  5548 findPreviousSnapshot
  5574 findPreviousSnapshot
  6418 ! !
  6444 ! !
  6419 
  6445 
  6420 !ChangesBrowser class methodsFor:'documentation'!
  6446 !ChangesBrowser class methodsFor:'documentation'!
  6421 
  6447 
  6422 version
  6448 version
  6423     ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.424 2012-03-08 10:40:46 cg Exp $'
  6449     ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.425 2012-03-08 11:03:32 cg Exp $'
  6424 !
  6450 !
  6425 
  6451 
  6426 version_CVS
  6452 version_CVS
  6427     ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.424 2012-03-08 10:40:46 cg Exp $'
  6453     ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.425 2012-03-08 11:03:32 cg Exp $'
  6428 ! !
  6454 ! !