"
COPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libtool' }"
"{ NameSpace: Tools }"
Object subclass:#MethodCategoryCache
instanceVariableNames:'cachedMethodCategories lock'
classVariableNames:'TheOneAndOnlyCache'
poolDictionaries:''
category:'Interface-Browsers-New'
!
!MethodCategoryCache class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
! !
!MethodCategoryCache class methodsFor:'instance creation'!
new
TheOneAndOnlyCache isNil ifTrue:[
TheOneAndOnlyCache := self basicNew initialize.
].
^ TheOneAndOnlyCache
! !
!MethodCategoryCache methodsFor:'accessing'!
allMethodCategories
cachedMethodCategories isNil ifTrue:[
self updateCachedMethodCategories
].
^ cachedMethodCategories
!
updateCachedMethodCategories
lock critical:[
cachedMethodCategories := Set new.
Smalltalk allBehaviorsDo:[:eachClass |
cachedMethodCategories addAll:eachClass categories
].
].
! !
!MethodCategoryCache methodsFor:'change & update'!
update:something with:aParameter from:changedObject
|removed|
changedObject == Smalltalk ifTrue:[
something == #methodInClassRemoved ifTrue:[
cachedMethodCategories := nil.
^ self.
].
(something == #classOrganization) ifTrue:[
cachedMethodCategories := nil.
^ self.
].
(something == #methodCategoryAdded) ifTrue:[
cachedMethodCategories notNil ifTrue:[
cachedMethodCategories add:(aParameter second).
].
^ self.
].
(something == #methodCategoryRemoved) ifTrue:[
cachedMethodCategories := nil.
^ self.
].
(something == #methodCategoriesRemoved) ifTrue:[
cachedMethodCategories := nil.
"/ removed := aParameter second asSet.
"/ Smalltalk allMethodsDo:[:m |
"/ |mCat|
"/ mCat := m category.
"/ (removed includes:mCat) ifTrue:[
"/ removed remove:mCat.
"/ removed isEmpty ifTrue:[^ self ].
"/ ].
"/ ].
"/ cachedMethodCategories removeAll:removed.
^ self.
].
(something == #methodCategoryRenamed) ifTrue:[
cachedMethodCategories := nil.
^ self.
].
something == #methodInClass ifTrue:[
^ self.
].
^ self.
].
super update:something with:aParameter from:changedObject
! !
!MethodCategoryCache methodsFor:'initialization'!
initialize
lock := Semaphore forMutualExclusion.
Smalltalk addDependent:self.
! !
!MethodCategoryCache class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/Tools__MethodCategoryCache.st,v 1.3 2008-02-29 10:29:41 cg Exp $'
! !