Tools__MethodCategoryCache.st
author Stefan Vogel <sv@exept.de>
Fri, 17 May 2019 17:11:44 +0200
changeset 18767 0478d93cdb75
parent 17563 db396151b268
child 18776 231e558179dc
permissions -rw-r--r--
#REFACTORING by stefan Sanitize BlockValues class: Tools::Inspector2 changed: #toolbarBackgroundHolder
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7926
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
     1
"
10034
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     2
 Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     3
 Copyright (c) 2009-2010 eXept Software AG
7926
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
     4
10034
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     5
 Permission is hereby granted, free of charge, to any person
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     6
 obtaining a copy of this software and associated documentation
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     7
 files (the 'Software'), to deal in the Software without
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     8
 restriction, including without limitation the rights to use,
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
     9
 copy, modify, merge, publish, distribute, sublicense, and/or sell
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    10
 copies of the Software, and to permit persons to whom the
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    11
 Software is furnished to do so, subject to the following
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    12
 conditions:
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    13
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    14
 The above copyright notice and this permission notice shall be
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    15
 included in all copies or substantial portions of the Software.
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    16
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    17
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    18
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    19
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    20
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    21
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    22
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    23
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    24
 OTHER DEALINGS IN THE SOFTWARE.
7926
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    25
"
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"{ Package: 'stx:libtool' }"
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"{ NameSpace: Tools }"
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
Object subclass:#MethodCategoryCache
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	instanceVariableNames:'cachedMethodCategories lock'
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	classVariableNames:'TheOneAndOnlyCache'
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	poolDictionaries:''
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	category:'Interface-Browsers-New'
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
7926
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    37
!MethodCategoryCache class methodsFor:'documentation'!
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    38
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    39
copyright
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    40
"
10034
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    41
 Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    42
 Copyright (c) 2009-2010 eXept Software AG
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    43
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    44
 Permission is hereby granted, free of charge, to any person
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    45
 obtaining a copy of this software and associated documentation
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    46
 files (the 'Software'), to deal in the Software without
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    47
 restriction, including without limitation the rights to use,
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    48
 copy, modify, merge, publish, distribute, sublicense, and/or sell
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    49
 copies of the Software, and to permit persons to whom the
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    50
 Software is furnished to do so, subject to the following
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    51
 conditions:
7926
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    52
10034
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    53
 The above copyright notice and this permission notice shall be
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    54
 included in all copies or substantial portions of the Software.
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    55
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    56
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    57
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    58
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    59
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    60
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    61
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    62
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
    63
 OTHER DEALINGS IN THE SOFTWARE.
7926
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    64
"
4f88f615ad7f copyright
Claus Gittinger <cg@exept.de>
parents: 6660
diff changeset
    65
! !
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!MethodCategoryCache class methodsFor:'instance creation'!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
new
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    TheOneAndOnlyCache isNil ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
        TheOneAndOnlyCache := self basicNew initialize.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    ^ TheOneAndOnlyCache
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
! !
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
!MethodCategoryCache methodsFor:'accessing'!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
allMethodCategories
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    cachedMethodCategories isNil ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        self updateCachedMethodCategories
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    ^ cachedMethodCategories
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
updateCachedMethodCategories
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    lock critical:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        cachedMethodCategories := Set new.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
        Smalltalk allBehaviorsDo:[:eachClass |
17563
db396151b268 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 10034
diff changeset
    89
            cachedMethodCategories addAll:eachClass methodCategories 
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    ].
17563
db396151b268 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 10034
diff changeset
    92
db396151b268 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 10034
diff changeset
    93
    "Modified: / 05-07-2017 / 09:31:55 / cg"
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!MethodCategoryCache methodsFor:'change & update'!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
update:something with:aParameter from:changedObject
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    |removed|
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    changedObject == Smalltalk ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
        something == #methodInClassRemoved ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
            cachedMethodCategories := nil.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
        (something == #classOrganization) ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
            cachedMethodCategories := nil.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
        (something == #methodCategoryAdded) ifTrue:[
7991
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   111
            cachedMethodCategories notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   112
                cachedMethodCategories add:(aParameter second).
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   113
            ].
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        (something == #methodCategoryRemoved) ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
            cachedMethodCategories := nil.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        (something == #methodCategoriesRemoved) ifTrue:[
7991
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   121
            cachedMethodCategories := nil.
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   122
"/            removed := aParameter second asSet.
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   123
"/            Smalltalk allMethodsDo:[:m |
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   124
"/                |mCat|
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   125
"/                mCat := m category.
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   126
"/                (removed includes:mCat) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   127
"/                    removed remove:mCat.
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   128
"/                    removed isEmpty ifTrue:[^ self ].
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   129
"/                ].
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   130
"/            ].
Claus Gittinger <cg@exept.de>
parents: 7926
diff changeset
   131
"/            cachedMethodCategories removeAll:removed.
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
        (something == #methodCategoryRenamed) ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
            cachedMethodCategories := nil.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
        something == #methodInClass ifTrue:[
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
            ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
        ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
        ^ self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    ].
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    super update:something with:aParameter from:changedObject
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
! !
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!MethodCategoryCache methodsFor:'initialization'!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
initialize
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    lock := Semaphore forMutualExclusion.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    Smalltalk addDependent:self.
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
! !
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
!MethodCategoryCache class methodsFor:'documentation'!
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
10034
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
   155
version_CVS
17563
db396151b268 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 10034
diff changeset
   156
    ^ '$Header$'
10034
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
   157
!
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
   158
04af374bf48f changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 7991
diff changeset
   159
version_SVN
17563
db396151b268 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 10034
diff changeset
   160
    ^ '$Id$'
6660
9510b89eed9d initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
! !
17563
db396151b268 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 10034
diff changeset
   162