author | Claus Gittinger <cg@exept.de> |
Thu, 05 Mar 2020 11:17:28 +0100 | |
changeset 4561 | eace75531554 |
parent 4408 | c80555d631e2 |
permissions | -rw-r--r-- |
4408 | 1 |
"{ Encoding: utf8 }" |
2 |
||
906 | 3 |
" |
4 |
COPYRIGHT (c) 1998 eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
969 | 14 |
"{ Package: 'stx:libbasic3' }" |
15 |
||
4066 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
688 | 18 |
Object subclass:#SystemOrganizer |
901 | 19 |
instanceVariableNames:'categoryArray nameSpace' |
994 | 20 |
classVariableNames:'AllCategories CachedOrganizerForSmalltalk' |
688 | 21 |
poolDictionaries:'' |
22 |
category:'Kernel-Support' |
|
23 |
! |
|
24 |
||
901 | 25 |
!SystemOrganizer class methodsFor:'documentation'! |
26 |
||
906 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1998 eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
||
40 |
||
41 |
! |
|
42 |
||
901 | 43 |
documentation |
44 |
" |
|
45 |
In ST80, there is a systemOrganization, which groups classes |
|
46 |
to categories. |
|
47 |
All of this here is mimicri - ST/X keeps the category in the class. |
|
48 |
This class simulates the ST80 behavior. |
|
49 |
" |
|
50 |
! ! |
|
688 | 51 |
|
52 |
!SystemOrganizer class methodsFor:'instance creation'! |
|
53 |
||
1061 | 54 |
for:aNameSpaceOrNil |
901 | 55 |
"create & return a new instance of myself, to organize aNameSpace. |
56 |
All of this here is mimicri - ST/X keeps the category in the class." |
|
688 | 57 |
|
1061 | 58 |
(aNameSpaceOrNil isNil or:[aNameSpaceOrNil == Smalltalk]) ifTrue:[ |
994 | 59 |
CachedOrganizerForSmalltalk isNil ifTrue:[ |
1061 | 60 |
CachedOrganizerForSmalltalk := self new nameSpace:aNameSpaceOrNil. |
994 | 61 |
]. |
62 |
^ CachedOrganizerForSmalltalk |
|
63 |
]. |
|
1061 | 64 |
^ self new nameSpace:aNameSpaceOrNil. |
688 | 65 |
|
1061 | 66 |
"Modified: / 21.8.2001 / 15:22:20 / cg" |
688 | 67 |
! ! |
68 |
||
69 |
!SystemOrganizer methodsFor:'accessing'! |
|
70 |
||
901 | 71 |
addCategory:aCategory before:someOtherCategory |
72 |
(categoryArray isNil |
|
73 |
or:[(categoryArray includes:aCategory) not]) ifTrue:[ |
|
74 |
categoryArray := nil. |
|
75 |
AllCategories add:aCategory. |
|
76 |
]. |
|
77 |
||
78 |
"Created: / 6.2.2000 / 20:42:20 / cg" |
|
79 |
"Modified: / 6.2.2000 / 20:44:34 / cg" |
|
80 |
! |
|
81 |
||
688 | 82 |
categories |
83 |
"return a collection of my classes class-categories. |
|
84 |
If my nameSpace is nil, all classes' categories are included; |
|
85 |
otherwise, only the categories of that particular namespace." |
|
86 |
||
901 | 87 |
|addClassAction categorySet searchedNamespace allNames| |
688 | 88 |
|
901 | 89 |
categoryArray notNil ifTrue:[ |
90 |
^ categoryArray |
|
91 |
]. |
|
688 | 92 |
|
901 | 93 |
addClassAction := [:aClass | |
94 |
|cat| |
|
688 | 95 |
|
901 | 96 |
aClass isMeta ifFalse:[ |
2251 | 97 |
aClass isNameSpace ifFalse:[ |
4408 | 98 |
cat := aClass category ? '* no category *'. |
901 | 99 |
cat ~= 'obsolete' ifTrue:[ |
100 |
categorySet add:cat |
|
688 | 101 |
] |
102 |
] |
|
103 |
]. |
|
901 | 104 |
]. |
105 |
||
106 |
AllCategories isNil ifTrue:[ |
|
107 |
categorySet := Set new. |
|
969 | 108 |
Smalltalk allClassesDo:addClassAction. |
901 | 109 |
AllCategories := categorySet. |
688 | 110 |
]. |
901 | 111 |
|
112 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
113 |
searchedNamespace := Smalltalk. |
|
114 |
]. |
|
1061 | 115 |
allNames := (searchedNamespace == Smalltalk). |
901 | 116 |
searchedNamespace == Smalltalk ifTrue:[ |
117 |
categorySet := AllCategories. |
|
118 |
] ifFalse:[ |
|
119 |
categorySet := Set new. |
|
969 | 120 |
searchedNamespace allClassesDo:addClassAction. |
901 | 121 |
]. |
122 |
categoryArray := categorySet asArray sort. |
|
688 | 123 |
^ categoryArray |
124 |
||
125 |
" |
|
126 |
(SystemOrganizer for:nil) categories |
|
127 |
(SystemOrganizer for:Smalltalk) categories |
|
128 |
(SystemOrganizer for:Demos) categories |
|
129 |
" |
|
130 |
||
4408 | 131 |
"Modified: / 21-08-2001 / 15:24:10 / cg" |
132 |
"Modified: / 03-03-2019 / 22:31:26 / Claus Gittinger" |
|
689 | 133 |
! |
134 |
||
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
135 |
categoryOfElement:aClassName |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
136 |
"return a classes category; |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
137 |
the argument is the classes name" |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
138 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
139 |
|cls| |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
140 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
141 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
901 | 142 |
cls notNil ifTrue:[ |
143 |
^ cls category |
|
144 |
]. |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
145 |
self error:'no such class'. |
901 | 146 |
|
147 |
"Modified: / 6.2.2000 / 20:12:10 / cg" |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
148 |
! |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
149 |
|
899 | 150 |
classify:aClassName under:newCategory |
151 |
"change a classes category; |
|
152 |
the argument is the classes name" |
|
153 |
||
901 | 154 |
|cls cats| |
899 | 155 |
|
156 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
|
901 | 157 |
cls notNil ifTrue:[ |
158 |
(AllCategories includes:newCategory) ifFalse:[ |
|
159 |
cats := AllCategories asOrderedCollection. |
|
160 |
cats add:newCategory. |
|
161 |
cats sort. |
|
162 |
AllCategories := cats. |
|
163 |
]. |
|
2251 | 164 |
(categoryArray notNil and:[categoryArray includes:newCategory]) |
165 |
ifFalse:[ |
|
901 | 166 |
categoryArray := nil. |
167 |
]. |
|
3437 | 168 |
cls category:newCategory. |
169 |
^ self |
|
901 | 170 |
]. |
899 | 171 |
self error:'no such class'. |
172 |
||
173 |
"Created: / 4.2.2000 / 18:30:11 / cg" |
|
901 | 174 |
"Modified: / 6.2.2000 / 20:36:30 / cg" |
899 | 175 |
! |
176 |
||
2488 | 177 |
environment |
178 |
||
179 |
^Smalltalk |
|
180 |
! |
|
181 |
||
689 | 182 |
listAtCategoryNamed:aCategory |
183 |
"return a collection of classes in aCategory." |
|
184 |
||
1670 | 185 |
|classSet searchedNamespace allNames| |
689 | 186 |
|
187 |
classSet := IdentitySet new. |
|
188 |
||
189 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
190 |
searchedNamespace := Smalltalk. |
|
191 |
]. |
|
1061 | 192 |
"/ hack to enable ported tools (RefactoryBrowser) to see all classes |
193 |
allNames := (searchedNamespace == Smalltalk). |
|
689 | 194 |
|
969 | 195 |
searchedNamespace allClassesDo:[:aClass | |
689 | 196 |
|cat| |
197 |
||
198 |
aClass isMeta ifFalse:[ |
|
2251 | 199 |
aClass isRealNameSpace ifFalse:[ |
689 | 200 |
(allNames or:[aClass nameSpace == nameSpace]) ifTrue:[ |
201 |
cat := aClass category. |
|
202 |
cat = aCategory ifTrue:[ |
|
203 |
classSet add:aClass name |
|
204 |
] |
|
205 |
] |
|
206 |
] |
|
207 |
] |
|
208 |
]. |
|
209 |
^ classSet asArray sort. |
|
210 |
||
211 |
" |
|
212 |
(SystemOrganizer for:nil) listAtCategoryNamed:'Collections-Abstract' |
|
213 |
(SystemOrganizer for:Smalltalk) listAtCategoryNamed:'Collections-Abstract' |
|
214 |
(SystemOrganizer for:Demos) listAtCategoryNamed:'Collections-Abstract' |
|
215 |
" |
|
216 |
||
1895
c3b43165a0cc
changed #listAtCategoryNamed:
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
217 |
"Modified: / 10-11-2006 / 17:12:56 / cg" |
688 | 218 |
! ! |
219 |
||
4066 | 220 |
!SystemOrganizer methodsFor:'change & update'! |
901 | 221 |
|
222 |
update:something with:anArgument from:changedObject |
|
994 | 223 |
"/ flush cached categories ... |
901 | 224 |
categoryArray := nil. |
225 |
||
226 |
"Created: / 6.2.2000 / 20:08:52 / cg" |
|
227 |
"Modified: / 6.2.2000 / 20:10:21 / cg" |
|
228 |
! ! |
|
229 |
||
230 |
!SystemOrganizer methodsFor:'private accessing'! |
|
688 | 231 |
|
232 |
nameSpace:aNameSpace |
|
233 |
"set the nameSpace - nil is allowed and stands for: any" |
|
234 |
||
994 | 235 |
nameSpace := aNameSpace ? Smalltalk. |
236 |
nameSpace addDependent:self. |
|
237 |
nameSpace ~~ Smalltalk ifTrue:[Smalltalk addDependent:self]. |
|
688 | 238 |
|
239 |
" |
|
240 |
(SystemOrganizer for:nil) organization |
|
241 |
(SystemOrganizer for:Demos) organization |
|
242 |
" |
|
243 |
||
244 |
"Modified: / 20.6.1998 / 12:35:34 / cg" |
|
245 |
! ! |
|
246 |
||
247 |
!SystemOrganizer class methodsFor:'documentation'! |
|
248 |
||
249 |
version |
|
4066 | 250 |
^ '$Header$' |
2251 | 251 |
! |
252 |
||
253 |
version_CVS |
|
4066 | 254 |
^ '$Header$' |
688 | 255 |
! ! |
3437 | 256 |