author | boris |
Wed, 15 Nov 2006 12:50:15 +0100 | |
changeset 1905 | 51e766803c45 |
parent 1903 | fc7a6b27312e |
child 2019 | 685031a55645 |
permissions | -rw-r--r-- |
3 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
85 | 3 |
All Rights Reserved |
3 | 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 |
" |
|
932 | 12 |
"{ Package: 'stx:libbasic3' }" |
13 |
||
0 | 14 |
Change subclass:#ClassChange |
1233 | 15 |
instanceVariableNames:'className package' |
235 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Changes' |
|
0 | 19 |
! |
20 |
||
634 | 21 |
!ClassChange class methodsFor:'documentation'! |
9 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
38 | 26 |
All Rights Reserved |
9 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
45 | 39 |
Abstract superclass for class related changes |
1162 | 40 |
They are typically held in a ChangeSet. |
235 | 41 |
|
42 |
[author:] |
|
43 |
Claus Gittinger |
|
9 | 44 |
" |
100 | 45 |
! ! |
46 |
||
634 | 47 |
!ClassChange class methodsFor:'instance creation'! |
85 | 48 |
|
100 | 49 |
class:aClass |
50 |
^ self new class:aClass |
|
51 |
||
52 |
"Created: 3.12.1995 / 14:01:32 / cg" |
|
1096 | 53 |
! |
54 |
||
55 |
class:aClass source:source |
|
56 |
^ self new class:aClass source:source |
|
57 |
||
58 |
"Created: 3.12.1995 / 14:01:32 / cg" |
|
1903 | 59 |
! |
60 |
||
61 |
className:aClassName |
|
62 |
^ self new className:aClassName |
|
63 |
||
64 |
"Created: / 13-11-2006 / 10:37:39 / cg" |
|
65 |
! |
|
66 |
||
67 |
className:aClassName source:source |
|
68 |
^ self new className:aClassName source:source |
|
69 |
||
70 |
"Created: / 12-11-2006 / 20:11:26 / cg" |
|
9 | 71 |
! ! |
72 |
||
0 | 73 |
!ClassChange methodsFor:'accessing'! |
74 |
||
850 | 75 |
changeClass |
76 |
"the class of the change (nil if not present)" |
|
77 |
||
1897 | 78 |
"do not autoload an owning class of a private class!!" |
1196 | 79 |
|
1870
55f67b913779
+owner access and other support for private classes
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
80 |
|className cls owner| |
1855
0c365a83ffc2
care for class name aliases when getting an existing
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
81 |
|
0c365a83ffc2
care for class name aliases when getting an existing
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
82 |
className := self className. |
1905
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
83 |
cls := Smalltalk loadedClassNamed:className. |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
84 |
cls isNil ifTrue:[ |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
85 |
self isPrivateClassDefinitionChange ifTrue:[ |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
86 |
owner := Smalltalk loadedClassNamed:(self owningClassName). |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
87 |
owner notNil ifTrue:[ |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
88 |
cls := owner privateClassesAt:className. |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
89 |
^ cls. |
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
90 |
]. |
1870
55f67b913779
+owner access and other support for private classes
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
91 |
]. |
1905
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
92 |
^ nil. |
1870
55f67b913779
+owner access and other support for private classes
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
93 |
]. |
1855
0c365a83ffc2
care for class name aliases when getting an existing
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
94 |
"/ care for aliases... |
0c365a83ffc2
care for class name aliases when getting an existing
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
95 |
cls name ~= className ifTrue:[ ^ nil ]. |
0c365a83ffc2
care for class name aliases when getting an existing
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
96 |
^ cls. |
1201 | 97 |
|
1305 | 98 |
"/ |className ns cls| |
99 |
"/ |
|
100 |
"/ className := self className. |
|
101 |
"/ className isNil ifTrue:[^ nil]. |
|
102 |
"/ |
|
103 |
"/ ns := (Class nameSpaceQuerySignal query) ? Smalltalk. |
|
104 |
"/ ns isNameSpace ifFalse:[ |
|
105 |
"/ ns := Smalltalk |
|
106 |
"/ ]. |
|
107 |
"/ |
|
108 |
"/ cls := ns classNamed:className. |
|
109 |
"/ cls isNil ifTrue:[ |
|
110 |
"/ ns ~~ Smalltalk ifTrue:[ |
|
111 |
"/ cls := Smalltalk classNamed:className |
|
112 |
"/ ]. |
|
113 |
"/ ]. |
|
1492
69d6894f0d81
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
1469
diff
changeset
|
114 |
"/ ^ cls |
1855
0c365a83ffc2
care for class name aliases when getting an existing
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
115 |
|
1897 | 116 |
"Modified: / 10-11-2006 / 16:42:28 / cg" |
850 | 117 |
! |
118 |
||
1040 | 119 |
changeClass:aClass |
120 |
"set the class of the change" |
|
121 |
||
122 |
className := aClass name. |
|
123 |
! |
|
124 |
||
100 | 125 |
class:aClass |
378 | 126 |
"set the class of the change" |
127 |
||
1903 | 128 |
self className:aClass name. |
100 | 129 |
|
1903 | 130 |
"Created: / 03-12-1995 / 14:01:45 / cg" |
131 |
"Modified: / 12-11-2006 / 20:10:28 / cg" |
|
100 | 132 |
! |
133 |
||
1096 | 134 |
class:aClass source:newSource |
135 |
"set both class and source of the change" |
|
136 |
||
1286
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
137 |
self className:(aClass name) source:newSource |
1096 | 138 |
! |
139 |
||
1305 | 140 |
classBaseName |
378 | 141 |
"return the className of the change" |
142 |
||
1196 | 143 |
^ self cutNameSpaceOf:className |
378 | 144 |
|
145 |
"Modified: 15.7.1996 / 09:28:35 / cg" |
|
654 | 146 |
! |
147 |
||
148 |
className:aString |
|
149 |
"set the className of the change" |
|
150 |
||
151 |
className := aString |
|
152 |
||
153 |
"Modified: / 15.7.1996 / 09:28:35 / cg" |
|
154 |
"Created: / 16.2.1998 / 13:05:36 / cg" |
|
1233 | 155 |
! |
156 |
||
1286
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
157 |
className:newClassName source:newSource |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
158 |
"set both className and source of the change" |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
159 |
|
1469 | 160 |
self assert:(newSource isString). |
161 |
self assert:(newClassName isString). |
|
162 |
||
1286
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
163 |
className := newClassName. |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
164 |
source := newSource. |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
165 |
|
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
166 |
"Created: 3.12.1995 / 14:01:45 / cg" |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
167 |
"Modified: 15.7.1996 / 09:28:26 / cg" |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
168 |
! |
621aac0264a7
catch non-string source args
Claus Gittinger <cg@exept.de>
parents:
1233
diff
changeset
|
169 |
|
1305 | 170 |
classNameWithoutNamespace |
171 |
"return the className of the change" |
|
172 |
||
173 |
^ self cutNameSpaceOf:className |
|
174 |
||
175 |
"Modified: 15.7.1996 / 09:28:35 / cg" |
|
176 |
! |
|
177 |
||
1233 | 178 |
package |
179 |
"return the value of the instance variable 'package' (automatically generated)" |
|
180 |
||
181 |
^ package |
|
182 |
! |
|
183 |
||
184 |
package:something |
|
185 |
"set the value of the instance variable 'package' (automatically generated)" |
|
186 |
||
187 |
package := something. |
|
0 | 188 |
! ! |
189 |
||
859 | 190 |
!ClassChange methodsFor:'applying'! |
191 |
||
192 |
apply |
|
193 |
"apply the change" |
|
194 |
||
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
195 |
Parser evaluate:(self source) |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
196 |
"/ |ns| |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
197 |
"/ |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
198 |
"/ ns := Class nameSpaceQuerySignal isHandled |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
199 |
"/ ifTrue:[ Class nameSpaceQuerySignal query ] |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
200 |
"/ ifFalse:[ self nameSpace ]. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
201 |
"/ |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
202 |
"/ Class nameSpaceQuerySignal answer:ns do:[ |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
203 |
"/ Parser evaluate:(self source) |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
204 |
"/ ]. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
205 |
! |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
206 |
|
1305 | 207 |
className |
208 |
|ns| |
|
209 |
||
210 |
"/ used to be ^ className; |
|
211 |
"/ |
|
212 |
"/ now include a translation from vw namespace to stx nameSpace |
|
213 |
||
214 |
ns := self nameSpaceName. |
|
215 |
(ns isNil or:[ns = 'Smalltalk']) ifTrue:[^ className]. |
|
216 |
||
217 |
^ ns , '::' , (self classNameWithoutNamespace) |
|
218 |
! |
|
219 |
||
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
220 |
fullClassName |
1196 | 221 |
|ns| |
222 |
||
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
223 |
"/ used to be ^ className; |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
224 |
"/ |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
225 |
"/ now include a translation from vw namespace to stx nameSpace |
1196 | 226 |
|
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
227 |
ns := self nameSpaceName. |
1304 | 228 |
(ns isNil or:[ns = 'Smalltalk']) ifTrue:[^ self className]. |
229 |
||
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
230 |
^ ns , '::' , self className |
1046
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
231 |
! |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
232 |
|
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
233 |
nameSpace |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
234 |
|nsName nameSpace| |
859 | 235 |
|
1046
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
236 |
(nsName := self nameSpaceName) notNil ifTrue:[ |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
237 |
^ NameSpace name:nsName. |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
238 |
]. |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
239 |
^ Smalltalk |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
240 |
! |
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
241 |
|
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
242 |
nameSpaceName |
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
243 |
|ns cnm idx| |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
244 |
|
1513 | 245 |
className isNil ifTrue:[^ nil]. |
246 |
||
859 | 247 |
(className includes:$:) ifTrue:[ |
248 |
"/ in a namespace |
|
1046
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
249 |
^ className upTo:$:. |
859 | 250 |
]. |
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
251 |
(idx := className indexOf:$.) ~~ 0 ifTrue:[ |
1196 | 252 |
"/ in a namespace |
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
253 |
ns := className copyTo:(idx - 1). |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
254 |
cnm := className copyFrom:(idx + 1). |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
255 |
"cheat: VW namespaces" |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
256 |
^ self nameSpaceForVWNamespace:ns class:cnm ifAbsent:ns |
1196 | 257 |
]. |
1046
450ef3136cc3
care for the nameSpace in a class-definition
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
258 |
^ nil |
1513 | 259 |
|
260 |
"Modified: / 03-08-2006 / 02:04:03 / cg" |
|
859 | 261 |
! ! |
262 |
||
962 | 263 |
!ClassChange methodsFor:'printing & storing'! |
101 | 264 |
|
265 |
printOn:aStream |
|
801 | 266 |
"append a user printed representation of the receiver to aStream. |
267 |
The format is suitable for a human - not meant to be read back." |
|
268 |
||
911 | 269 |
source isNil ifTrue:[ |
270 |
aStream nextPutAll:'an empty change'. |
|
271 |
^ self |
|
272 |
]. |
|
1469 | 273 |
aStream nextPutAll:(self class name , ' - ' , source string firstLine , '...'). |
101 | 274 |
! ! |
275 |
||
932 | 276 |
!ClassChange methodsFor:'queries'! |
277 |
||
1196 | 278 |
cutNameSpaceOf:aString |
1304 | 279 |
|dotIndex colonIndex| |
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
280 |
|
1197 | 281 |
aString notNil ifTrue:[ |
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
282 |
dotIndex := aString indexOf:$.. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
283 |
dotIndex ~~ 0 ifTrue:[ |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
284 |
^ aString copyFrom:dotIndex+1 |
1197 | 285 |
]. |
1304 | 286 |
colonIndex := aString indexOf:$:. |
287 |
colonIndex ~~ 0 ifTrue:[ |
|
288 |
^ aString copyFrom:colonIndex+2 |
|
289 |
]. |
|
1196 | 290 |
]. |
291 |
^ aString |
|
292 |
! |
|
293 |
||
932 | 294 |
isClassChange |
295 |
^ true |
|
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
296 |
! |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
297 |
|
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
298 |
nameSpaceForVWNamespace:ns class:className ifAbsent:default |
1303 | 299 |
"map the namespace for a given class" |
300 |
||
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
301 |
ns = 'Core' ifTrue:[^ 'Smalltalk']. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
302 |
ns = 'Kernel' ifTrue:[^ 'Smalltalk']. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
303 |
ns = 'Graphics' ifTrue:[^ 'Smalltalk']. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
304 |
ns = 'OS' ifTrue:[^ 'Smalltalk']. |
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
305 |
ns = 'Smalltalk' ifTrue:[^ 'Smalltalk']. |
1303 | 306 |
ns = 'UI' ifTrue:[^ 'Smalltalk']. |
1300
3847c8f8a4f5
handle NS.Classname (vw files)
Claus Gittinger <cg@exept.de>
parents:
1286
diff
changeset
|
307 |
^ default value |
932 | 308 |
! ! |
309 |
||
634 | 310 |
!ClassChange class methodsFor:'documentation'! |
100 | 311 |
|
312 |
version |
|
1905
51e766803c45
avoid endless recursion, if change is for a namespace definition.
boris
parents:
1903
diff
changeset
|
313 |
^ '$Header: /cvs/stx/stx/libbasic3/ClassChange.st,v 1.47 2006-11-15 11:50:15 boris Exp $' |
100 | 314 |
! ! |