1231
|
1 |
"{ Package: 'stx:libbasic3' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Packages }"
|
|
4 |
|
|
5 |
AbstractPackageManager subclass:#PackageManager
|
|
6 |
instanceVariableNames:'workingPackage'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Package-Managers'
|
|
10 |
!
|
|
11 |
|
|
12 |
PackageManager class instanceVariableNames:'currentPackage currentManager imageChanges'
|
|
13 |
|
|
14 |
"
|
|
15 |
No other class instance variables are inherited by this class.
|
|
16 |
"
|
|
17 |
!
|
|
18 |
|
|
19 |
!PackageManager class methodsFor:'documentation'!
|
|
20 |
|
|
21 |
documentation
|
|
22 |
"
|
|
23 |
PackageManager smalltalkPackageManager
|
|
24 |
|
|
25 |
[author:]
|
|
26 |
(james@miraculix)
|
|
27 |
|
|
28 |
[instance variables:]
|
|
29 |
|
|
30 |
[class variables:]
|
|
31 |
|
|
32 |
[see also:]
|
|
33 |
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
|
37 |
documentation_exceptions
|
|
38 |
"
|
|
39 |
|
|
40 |
ClassDescription fileOutErrorSignal
|
|
41 |
can occur when a class within a package is autoloaded. Handle in application
|
|
42 |
|
|
43 |
[author:]
|
|
44 |
(james@miraculix)
|
|
45 |
|
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
examples
|
|
50 |
"
|
|
51 |
|
|
52 |
more examples to be added:
|
|
53 |
[exBegin]
|
|
54 |
... add code fragment for
|
|
55 |
... executable example here ...
|
|
56 |
[exEnd]
|
|
57 |
"
|
|
58 |
!
|
|
59 |
|
|
60 |
history
|
|
61 |
"Created: / 27.1.2003 / 13:57:50 / james"
|
|
62 |
! !
|
|
63 |
|
|
64 |
!PackageManager class methodsFor:'instance creation'!
|
|
65 |
|
|
66 |
initialize
|
|
67 |
"Uninitialize Singleton"
|
|
68 |
currentManager ifNotNil:[
|
|
69 |
currentManager uninitialize.
|
|
70 |
currentManager := nil.
|
|
71 |
currentPackage := nil.
|
|
72 |
]
|
|
73 |
|
|
74 |
"
|
|
75 |
self initialize
|
|
76 |
"
|
|
77 |
!
|
|
78 |
|
|
79 |
newManagerOfCurrentImage
|
|
80 |
| anInstance |
|
|
81 |
anInstance := self new.
|
|
82 |
|
|
83 |
self basicPackagesInImage do:[:aPackage |
|
|
84 |
package isInstalled:true.
|
|
85 |
anInstance addPackage:aPackage
|
|
86 |
].
|
|
87 |
^ anInstance
|
|
88 |
|
|
89 |
"
|
|
90 |
currentManager := self newManagerOfCurrentImage.
|
|
91 |
"
|
|
92 |
! !
|
|
93 |
|
|
94 |
!PackageManager class methodsFor:'accessing'!
|
|
95 |
|
|
96 |
changes
|
|
97 |
imageChanges ifNil:[
|
|
98 |
imageChanges := OrderedCollection new.
|
|
99 |
].
|
|
100 |
^ imageChanges
|
|
101 |
!
|
|
102 |
|
|
103 |
smalltalkPackageManager
|
|
104 |
"/ to clear the singleton for the moment
|
|
105 |
| workingPackage packagesInImage|
|
|
106 |
|
|
107 |
"/ self initialize.
|
|
108 |
currentManager
|
|
109 |
ifNil:[
|
|
110 |
currentManager := self new.
|
|
111 |
|
|
112 |
packagesInImage := self basicPackagesInImage.
|
1242
|
113 |
workingPackage := packagesInImage removeKey:#'__NoProject__' ifAbsent:[Package named:#'__NoProject__'].
|
1231
|
114 |
|
|
115 |
currentManager addPackages:(packagesInImage).
|
|
116 |
currentManager workingPackage:workingPackage.
|
|
117 |
].
|
|
118 |
^ currentManager
|
|
119 |
! !
|
|
120 |
|
|
121 |
!PackageManager class methodsFor:'defaults'!
|
|
122 |
|
|
123 |
defaultPackages
|
|
124 |
^ DictionaryStack new.
|
|
125 |
! !
|
|
126 |
|
|
127 |
!PackageManager class methodsFor:'factory'!
|
|
128 |
|
|
129 |
packageClass
|
|
130 |
^ Package
|
|
131 |
! !
|
|
132 |
|
|
133 |
!PackageManager class methodsFor:'temporary'!
|
|
134 |
|
|
135 |
basicPackagesInImage
|
|
136 |
"builds up dictionary of the packages in the system taking the information of the classes and
|
|
137 |
methods so we have a complete picture but without the prerequisite information.
|
|
138 |
returns the dictionary"
|
|
139 |
| packagesInImage extentions clsPkg |
|
|
140 |
|
|
141 |
packagesInImage := Dictionary new.
|
|
142 |
extentions := Dictionary new.
|
|
143 |
|
|
144 |
"collect the classes and mark where the extentions are"
|
|
145 |
Smalltalk allClasses do:[:aClass |
|
|
146 |
clsPkg := aClass package.
|
|
147 |
(packagesInImage at: clsPkg
|
|
148 |
ifAbsentPut:[clsPkg == #'__NoProject__' ifTrue:[
|
|
149 |
(DefaultPackage named:clsPkg)
|
|
150 |
] ifFalse:[(Package named:clsPkg)
|
|
151 |
]. ])
|
|
152 |
addedClass:aClass.
|
|
153 |
|
|
154 |
"/ aClass hasExtensions ifTrue:[
|
|
155 |
aClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|
|
156 |
|mthdPkg|
|
|
157 |
mthdPkg := mthd package.
|
|
158 |
mthdPkg ~= clsPkg ifTrue:[| methodPackage |
|
|
159 |
"this is found out when you add a class!!"
|
|
160 |
"/ (packagesInImage at: clsPkg) removeMethod:mthd. "does not belong to the package"
|
|
161 |
methodPackage :=
|
|
162 |
(packagesInImage at: mthdPkg ifAbsentPut:[
|
|
163 |
mthdPkg == #'__NoProject__' ifTrue:[
|
|
164 |
(DefaultPackage named:mthdPkg)
|
|
165 |
] ifFalse:[(Package named:mthdPkg)
|
|
166 |
].
|
|
167 |
]).
|
|
168 |
methodPackage addedMethod:mthd
|
|
169 |
|
|
170 |
].
|
|
171 |
"/ ].
|
|
172 |
]
|
|
173 |
].
|
|
174 |
packagesInImage removeKey:#''. "remove namespaces"
|
|
175 |
packagesInImage do:[:aPackage |
|
|
176 |
aPackage initializeInstalled.
|
|
177 |
].
|
|
178 |
^ packagesInImage
|
|
179 |
! !
|
|
180 |
|
|
181 |
!PackageManager methodsFor:'accessing'!
|
|
182 |
|
|
183 |
changes
|
|
184 |
^ self class changes
|
|
185 |
!
|
|
186 |
|
|
187 |
packageNamed:anIdentifier
|
|
188 |
anIdentifier ifNil:[
|
|
189 |
^ nil
|
|
190 |
].
|
|
191 |
workingPackage name == anIdentifier ifTrue:[
|
|
192 |
^ workingPackage
|
|
193 |
].
|
|
194 |
^ packages atKey:anIdentifier ifAbsent:[nil]
|
|
195 |
!
|
|
196 |
|
|
197 |
packagesNamed:aCollectionOfPackageNames
|
|
198 |
| aCol |
|
|
199 |
aCol := OrderedCollection new.
|
|
200 |
|
|
201 |
(aCollectionOfPackageNames includes:workingPackage name) ifTrue:[
|
|
202 |
aCol add:workingPackage
|
|
203 |
].
|
|
204 |
|
|
205 |
aCol addAll: (aCollectionOfPackageNames collect:[:aName |
|
|
206 |
self packageNamed:aName
|
|
207 |
]).
|
|
208 |
|
|
209 |
^ aCol
|
|
210 |
!
|
|
211 |
|
|
212 |
workingPackage
|
|
213 |
"return the value of the instance variable 'workingPackage' (automatically generated)"
|
|
214 |
|
|
215 |
^ workingPackage
|
|
216 |
!
|
|
217 |
|
|
218 |
workingPackage:aPackage
|
|
219 |
workingPackage removeDependent:self.
|
|
220 |
workingPackage:= aPackage.
|
|
221 |
workingPackage addDependent:self.
|
|
222 |
! !
|
|
223 |
|
|
224 |
!PackageManager methodsFor:'adding & removing'!
|
|
225 |
|
|
226 |
addChange:aChange
|
|
227 |
^ self class changes add:aChange.
|
|
228 |
!
|
|
229 |
|
|
230 |
addPackage:aPackage
|
|
231 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
232 |
aPackage addDependent:self.
|
|
233 |
self basicAddPackage:aPackage.
|
|
234 |
self changed:#addPackage: with:aPackage
|
|
235 |
!
|
|
236 |
|
|
237 |
addPackages:aPackages
|
|
238 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
239 |
aPackages do:[:aPackage |
|
|
240 |
self basicAddPackage:aPackage.
|
|
241 |
].
|
|
242 |
self changed:#addPackages: with:aPackages
|
|
243 |
!
|
|
244 |
|
|
245 |
basicAddPackage:aPackage
|
|
246 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
247 |
packages push:aPackage.
|
|
248 |
!
|
|
249 |
|
|
250 |
basicRemovePackage:aPackage
|
|
251 |
^ packages removeKey:aPackage name
|
|
252 |
!
|
|
253 |
|
|
254 |
removeChange:aChange
|
|
255 |
^ self class changes remove:aChange.
|
|
256 |
!
|
|
257 |
|
|
258 |
removePackage:aPackage
|
|
259 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
260 |
aPackage removeDependent:self.
|
|
261 |
self basicRemovePackage:aPackage.
|
|
262 |
self changed:#removePackage: with:aPackage
|
|
263 |
!
|
|
264 |
|
|
265 |
removePackageNamed:aPackageName
|
|
266 |
| aPackage |
|
|
267 |
aPackage := (packages removeKey:aPackageName).
|
|
268 |
aPackage removeDependent:self.
|
|
269 |
self changed:#removePackage: with:aPackage
|
|
270 |
! !
|
|
271 |
|
|
272 |
!PackageManager methodsFor:'api'!
|
|
273 |
|
|
274 |
addClass:aClass toPackage:aPackage
|
|
275 |
(self includesPackage:aPackage) ifFalse:[
|
|
276 |
self error:'The package manager does not know of the package ', aPackage name.
|
|
277 |
].
|
|
278 |
self moveClass:aClass toPackage:aPackage.
|
|
279 |
!
|
|
280 |
|
|
281 |
addMethod:aMethod toPackage:aPackage
|
|
282 |
"add method to a package. At this point it is determined to be a loose method or not"
|
|
283 |
(self includesPackage:aPackage) ifFalse:[
|
|
284 |
self error:'The package manager does not know of the package ', aPackage name.
|
|
285 |
].
|
|
286 |
aPackage addedMethod:aMethod
|
|
287 |
!
|
|
288 |
|
|
289 |
installPackage:aPackage
|
|
290 |
"installs a package that the receiver is aware of into the image if not raise an error
|
|
291 |
for the sender to catch so it is able to handle it"
|
|
292 |
(self includesPackage:aPackage) ifFalse:[
|
|
293 |
self error:'The package manager does not know of the package ', aPackage name,' so it cannot be installed!!'
|
|
294 |
].
|
|
295 |
^ (self getPackageHandlerForPackage:aPackage) installPackageIn:self
|
|
296 |
!
|
|
297 |
|
|
298 |
loadPackageFromFile:aFilename
|
|
299 |
"install a starter package which comes from a file. This is the
|
|
300 |
a state where the package has not yet entered the image but it
|
|
301 |
is a package that the receiver is aware of and has some initial
|
|
302 |
information about. Return the installed Package"
|
|
303 |
|
|
304 |
^ (self getPackageReaderForFile:aFilename) loadPackageIn:self .
|
|
305 |
!
|
|
306 |
|
|
307 |
moveClass:aClass toPackage:newOwnerPackage
|
|
308 |
"i have the responsibilty to set aClasses new variable (newOwnerPackage name) and
|
|
309 |
all the methods in aClass with the same package name!!
|
|
310 |
"
|
|
311 |
| oldOwnerPackage oldOwnerPackageName newOwnerPackageName|
|
|
312 |
|
|
313 |
oldOwnerPackageName := aClass package.
|
|
314 |
oldOwnerPackage := self packageNamed:aClass package.
|
|
315 |
newOwnerPackageName := newOwnerPackage name.
|
|
316 |
|
|
317 |
aClass package:newOwnerPackageName.
|
|
318 |
aClass methodDictionary copy keysAndValuesDo:[:aMethodName :aMethod |
|
|
319 |
aMethod package == oldOwnerPackageName ifTrue:[
|
|
320 |
aMethod package:newOwnerPackageName
|
|
321 |
].
|
|
322 |
].
|
|
323 |
|
|
324 |
oldOwnerPackage ifNil:[
|
|
325 |
"error handling"
|
|
326 |
aClass setPackage:workingPackage name.
|
|
327 |
workingPackage addedClass:aClass.
|
|
328 |
oldOwnerPackage := workingPackage.
|
|
329 |
].
|
|
330 |
|
|
331 |
self recoveryHandlerDo:[
|
|
332 |
oldOwnerPackage movedClass:aClass toPackage:newOwnerPackage
|
|
333 |
] forException:PackageError.
|
|
334 |
!
|
|
335 |
|
|
336 |
moveMethod:aMethod to:newOwnerPackage
|
|
337 |
| oldOwnerPackage |
|
|
338 |
|
|
339 |
oldOwnerPackage := self packageNamed:aMethod package.
|
|
340 |
oldOwnerPackage movedMethod:aMethod toPackage:newOwnerPackage
|
|
341 |
!
|
|
342 |
|
|
343 |
removeClass:aClass fromPackage:aPackage
|
|
344 |
(self includesPackage:aPackage) ifFalse:[
|
|
345 |
self error:'The package manager does not know of the package ', aPackage name.
|
|
346 |
].
|
|
347 |
self moveClass:aClass toPackage:workingPackage.
|
|
348 |
!
|
|
349 |
|
|
350 |
removeMethod:aMethod fromPackage:aPackage
|
|
351 |
"add method to a package. At this point it is determined to be a loose method or not"
|
|
352 |
(self includesPackage:aPackage) ifFalse:[
|
|
353 |
self error:'The package manager does not know of the package ', aPackage name.
|
|
354 |
].
|
|
355 |
aPackage removedMethod:aMethod
|
|
356 |
!
|
|
357 |
|
|
358 |
savePackage:aPackage
|
|
359 |
self savePackage:aPackage as:aPackage filename.
|
|
360 |
!
|
|
361 |
|
|
362 |
savePackage:aPackage as:aFilename
|
|
363 |
"saves a package that the receiver is aware of if not raise an error
|
|
364 |
for the sender to catch so it is able to handle it"
|
|
365 |
(self includesPackage:aPackage) ifFalse:[
|
|
366 |
self error:'This package manager is not responsible of the package ', aPackage name,' so it cannot be saved!!'
|
|
367 |
].
|
|
368 |
|
|
369 |
(self getPackageHandlerForPackage:aPackage) savePackageAs:aFilename.
|
|
370 |
^ aPackage.
|
|
371 |
!
|
|
372 |
|
|
373 |
uninstallPackage:aPackage
|
|
374 |
"need to include the restoration of packages aPackage has overridden!!!!!!!!"
|
|
375 |
(self includesPackage:aPackage) ifFalse:[
|
|
376 |
self error:'The package manager does not know of the package ', aPackage name,' so it cannot be uninstalled!!'
|
|
377 |
].
|
|
378 |
|
|
379 |
^ aPackage uninstall.
|
|
380 |
!
|
|
381 |
|
|
382 |
unloadPackage:aPackage
|
|
383 |
"unloads the package from the receiver.Does not need to
|
|
384 |
make any checks here as it is not installed."
|
|
385 |
|
|
386 |
(self includesPackage:aPackage) ifFalse:[
|
|
387 |
self error:'The package manager does not know of the package ', aPackage name.
|
|
388 |
].
|
|
389 |
|
|
390 |
aPackage isInstalled ifTrue:[
|
|
391 |
self uninstallPackage:aPackage.
|
|
392 |
].
|
|
393 |
self removePackage:aPackage.
|
|
394 |
^ aPackage.
|
|
395 |
! !
|
|
396 |
|
|
397 |
!PackageManager methodsFor:'change & update'!
|
|
398 |
|
|
399 |
changeSetChanged:something with:aChange from:changedObject
|
|
400 |
"find out what type of change it is and send the packages the corresponding
|
|
401 |
message to is if they are affected. If they are they should (if they are behaving)
|
|
402 |
send me a change notification to inform me about it(see packageChanged:with:from:)!!
|
|
403 |
"
|
|
404 |
aChange isCollection ifTrue:[
|
|
405 |
"after checking in"
|
|
406 |
^ self "do i need to do anything???"
|
|
407 |
].
|
|
408 |
(aChange isClassChange) ifFalse:[
|
|
409 |
self halt:' What is this???'.
|
|
410 |
].
|
|
411 |
|
|
412 |
(aChange isMethodCategoryChange) ifTrue:[
|
|
413 |
self packagesDo:[:aPackage |
|
|
414 |
(aPackage isDependentOnMethodCategoryChange:aChange) ifTrue:[
|
|
415 |
aPackage methodCategoryChange:aChange.
|
|
416 |
].
|
|
417 |
].
|
|
418 |
^ self
|
|
419 |
].
|
|
420 |
|
|
421 |
"the following is similar to the one above"
|
|
422 |
(aChange isMethodCategoryRenameChange) ifTrue:[
|
|
423 |
self packagesDo:[:aPackage |
|
|
424 |
(aPackage isDependentOnMethodCategoryRenameChange:aChange) ifTrue:[
|
|
425 |
aPackage methodCategoryRenameChange:aChange.
|
|
426 |
].
|
|
427 |
].
|
|
428 |
^ self
|
|
429 |
].
|
|
430 |
|
|
431 |
aChange isMethodRemoveChange ifTrue:[
|
|
432 |
self packagesDo:[:aPackage |
|
|
433 |
(aPackage isDependentOnMethodRemoveChange:aChange) ifTrue:[
|
|
434 |
aPackage methodRemoveChange:aChange.
|
|
435 |
].
|
|
436 |
].
|
|
437 |
^ self
|
|
438 |
].
|
|
439 |
|
|
440 |
aChange isMethodChange ifTrue:[
|
|
441 |
"A new created method or a modified method"
|
|
442 |
self packagesDo:[:aPackage |
|
|
443 |
(aPackage isDependentOnMethodChange:aChange) ifTrue:[
|
|
444 |
aPackage methodChanged:aChange.
|
|
445 |
].
|
|
446 |
].
|
|
447 |
^ self
|
|
448 |
].
|
|
449 |
|
|
450 |
aChange isClassChange ifTrue:[
|
|
451 |
(aChange isClassRemoveChange) ifTrue:[
|
|
452 |
self packagesDo:[:aPackage |
|
|
453 |
(aPackage isDependentOnClassRemoveChange:aChange) ifTrue:[
|
|
454 |
aPackage classRemoveChange:aChange.
|
|
455 |
].
|
|
456 |
].
|
|
457 |
^ self
|
|
458 |
].
|
|
459 |
|
|
460 |
aChange isClassDefinitionChange ifTrue:[
|
|
461 |
"changes to instance variables, classVariableNames, poolDictionaries, category"
|
|
462 |
self packagesDo:[:aPackage |
|
|
463 |
(aPackage isDependentOnClassDefinitionChange:aChange) ifTrue:[
|
|
464 |
aPackage classDefinitionChange:aChange.
|
|
465 |
].
|
|
466 |
].
|
|
467 |
^ self
|
|
468 |
|
|
469 |
].
|
|
470 |
(aChange isClassInstVarDefinitionChange) ifTrue:[
|
|
471 |
self packagesDo:[:aPackage |
|
|
472 |
(aPackage isDependentOnClassInstVarDefinitionChange:aChange) ifTrue:[
|
|
473 |
aPackage classInstVarDefinitionChange:aChange.
|
|
474 |
].
|
|
475 |
].
|
|
476 |
^ self
|
|
477 |
].
|
|
478 |
(aChange isClassRenameChange) ifTrue:[
|
|
479 |
self packagesDo:[:aPackage |
|
|
480 |
(aPackage isDependentOnClassRenameChange:aChange) ifTrue:[
|
|
481 |
aPackage classRenameChange:aChange.
|
|
482 |
].
|
|
483 |
].
|
|
484 |
^ self
|
|
485 |
].
|
|
486 |
|
|
487 |
|
|
488 |
self halt.
|
|
489 |
].
|
|
490 |
|
|
491 |
self halt.
|
|
492 |
!
|
|
493 |
|
|
494 |
classPackageChange:classToMove oldPackageName:oldPackageName
|
|
495 |
"reacts to a class package change
|
|
496 |
Assertion:
|
|
497 |
aClass package ~= oldPackageName
|
|
498 |
"
|
|
499 |
| newPackageName oldOwnerPackage newOwnerPackage|
|
|
500 |
|
|
501 |
newPackageName := classToMove package.
|
|
502 |
newOwnerPackage := self packageNamed:newPackageName.
|
|
503 |
oldOwnerPackage := self packageNamed:oldPackageName.
|
|
504 |
oldOwnerPackage movedClass:classToMove toPackage:newOwnerPackage.
|
|
505 |
!
|
|
506 |
|
|
507 |
methodPackageChange:aMethod class:methodOwnedClass oldPackageName:oldPackageName
|
|
508 |
| newPackageName oldOwnerPackage newOwnerPackage|
|
|
509 |
|
|
510 |
newPackageName := aMethod package.
|
|
511 |
oldOwnerPackage :=(self packageNamed:oldPackageName).
|
|
512 |
newOwnerPackage := (self packageNamed:newPackageName).
|
|
513 |
|
|
514 |
newOwnerPackage ifNil:[
|
|
515 |
PackageError raiseErrorString:'The package ', newPackageName, ' is not known',
|
|
516 |
' to this packageManager', ' and so cannot realise this methodPackageChange'
|
|
517 |
|
|
518 |
].
|
|
519 |
|
|
520 |
oldOwnerPackage ifNil:[
|
|
521 |
PackageError raiseErrorString:'The package ', oldPackageName, ' is not known',
|
|
522 |
' to this packageManager', ' and so cannot realise this methodPackageChange'
|
|
523 |
].
|
|
524 |
|
|
525 |
oldOwnerPackage movedMethod:aMethod toPackage:newOwnerPackage
|
|
526 |
!
|
|
527 |
|
|
528 |
packageChanged:something with:aParameter from:changedObject
|
|
529 |
"maybe send a change notification for views here???"
|
|
530 |
"/ self halt.
|
|
531 |
self addChange:aParameter
|
|
532 |
!
|
|
533 |
|
|
534 |
update:something with:aParameter from:changedObject
|
|
535 |
#mayChange.
|
|
536 |
(self packagesIncludes:changedObject) ifTrue:[
|
|
537 |
self packageChanged:something with:aParameter from:changedObject.
|
|
538 |
^ self.
|
|
539 |
].
|
|
540 |
(changedObject == ChangeSet current) ifTrue:[
|
|
541 |
self changeSetChanged:something with:aParameter from:changedObject.
|
|
542 |
^ self.
|
|
543 |
].
|
|
544 |
|
|
545 |
(something == #projectOrganization) ifTrue:[
|
|
546 |
aParameter ifNil:[
|
|
547 |
"no need to know about this. It has probably already been past here already!!"
|
|
548 |
^ self
|
|
549 |
].
|
|
550 |
aParameter size == 2 ifTrue:[| oldPackageName |
|
|
551 |
(oldPackageName := aParameter second).
|
|
552 |
(oldPackageName isSymbol) ifTrue:[
|
|
553 |
self
|
|
554 |
classPackageChange:aParameter first
|
|
555 |
oldPackageName:aParameter second.
|
|
556 |
^ self.
|
|
557 |
] ifFalse:[
|
|
558 |
"ignore"
|
|
559 |
^ self.
|
|
560 |
].
|
|
561 |
].
|
|
562 |
aParameter size == 3 ifTrue:[
|
|
563 |
self
|
|
564 |
methodPackageChange:(aParameter second)
|
|
565 |
class:(aParameter first)
|
|
566 |
oldPackageName:(aParameter third).
|
|
567 |
^ self.
|
|
568 |
].
|
|
569 |
aParameter size == 1 ifTrue:[
|
|
570 |
Transcript
|
|
571 |
nextPutAll:'From PackageManager>>update:with:from:' ;
|
|
572 |
cr;
|
|
573 |
nextPutAll:'When does this happen' ;
|
|
574 |
cr.
|
|
575 |
"checking out changedObject = Smalltalk"
|
|
576 |
|
|
577 |
^ self.
|
|
578 |
].
|
|
579 |
self halt.
|
|
580 |
].
|
|
581 |
!
|
|
582 |
|
|
583 |
xxxchangeSetChanged:something with:aChange from:changedObject
|
|
584 |
"find out what type of change it is and send the packages the corresponding
|
|
585 |
message to is if they are affected. If they are they should (if they are behaving)
|
|
586 |
send me a change notification to inform me about it(see packageChanged:with:from:)!!
|
|
587 |
"
|
|
588 |
|
|
589 |
|currentPackageID currentPackage previousPackageID previousPackage |
|
|
590 |
|
|
591 |
"will this still be ok when we change package names? is this the same as
|
|
592 |
currentPackage := workingPackage. ??"
|
|
593 |
currentPackageID := Class packageQuerySignal query.
|
|
594 |
currentPackage :=(self packageNamed:currentPackageID).
|
|
595 |
|
|
596 |
"------------------------------- method changes -------------------------------"
|
|
597 |
|
|
598 |
(aChange isMethodCategoryChange) ifTrue:[
|
|
599 |
currentPackage methodCategoryChange:aChange.
|
|
600 |
^ self
|
|
601 |
].
|
|
602 |
"the following is similar to the one above"
|
|
603 |
(aChange isMethodCategoryRenameChange) ifTrue:[
|
|
604 |
self halt.
|
|
605 |
currentPackage methodCategoryRenameChange:aChange.
|
|
606 |
|
|
607 |
previousPackageID := aChange previousPackage.
|
|
608 |
previousPackage := (self packageNamed:previousPackageID).
|
|
609 |
previousPackage ~= currentPackage ifTrue:[
|
|
610 |
previousPackage methodCategoryRenameChange:aChange.
|
|
611 |
].
|
|
612 |
^ self
|
|
613 |
].
|
|
614 |
|
|
615 |
aChange isMethodChange ifTrue:[| isInitialMethod |
|
|
616 |
"A new created method or a modified method"
|
|
617 |
currentPackage methodChanged:aChange.
|
|
618 |
|
|
619 |
previousPackageID := aChange previousPackage.
|
|
620 |
isInitialMethod := previousPackageID isNil.
|
|
621 |
|
|
622 |
isInitialMethod ifFalse:[
|
|
623 |
previousPackage := (self packageNamed:previousPackageID).
|
|
624 |
previousPackage methodChanged:aChange.
|
|
625 |
].
|
|
626 |
^ self
|
|
627 |
].
|
|
628 |
|
|
629 |
aChange isMethodRemoveChange ifTrue:[
|
|
630 |
"there is no current version for this type of change!!"
|
|
631 |
previousPackageID := aChange previousPackage.
|
|
632 |
previousPackage := (self packageNamed:previousPackageID).
|
|
633 |
previousPackage methodRemoveChange:aChange.
|
|
634 |
^ self
|
|
635 |
].
|
|
636 |
|
|
637 |
|
|
638 |
"------------------------------- class changes -------------------------------"
|
|
639 |
|
|
640 |
aChange isClassChange ifTrue:[
|
|
641 |
(aChange isClassRemoveChange) ifTrue:[
|
|
642 |
previousPackage := currentPackage.
|
|
643 |
previousPackage classRemoveChange:aChange.
|
|
644 |
^ self
|
|
645 |
].
|
|
646 |
|
|
647 |
aChange isClassDefinitionChange ifTrue:[
|
|
648 |
"changes to instance variables class variables"
|
|
649 |
currentPackage classDefinitionChange:aChange.
|
|
650 |
ClassDefinitionChange::ClassBeingChangedQuery query ifNotNil:[
|
|
651 |
self halt.
|
|
652 |
].
|
|
653 |
previousPackageID := aChange previousPackage. "does not work"
|
|
654 |
previousPackage := (self packageNamed:previousPackageID).
|
|
655 |
previousPackage ~= currentPackage ifTrue:[
|
|
656 |
previousPackage classDefinitionChange:aChange.
|
|
657 |
].
|
|
658 |
^ self
|
|
659 |
].
|
|
660 |
(aChange isClassInstVarDefinitionChange) ifTrue:[
|
|
661 |
previousPackage classInstVarDefinitionChange:aChange.
|
|
662 |
previousPackage ~= currentPackage ifTrue:[
|
|
663 |
currentPackage classInstVarDefinitionChange:aChange.
|
|
664 |
].
|
|
665 |
^ self
|
|
666 |
].
|
|
667 |
|
|
668 |
(aChange isClassRenameChange) ifTrue:[
|
|
669 |
previousPackage classRenameChange:aChange.
|
|
670 |
previousPackage ~= currentPackage ifTrue:[
|
|
671 |
currentPackage classRenameChange:aChange.
|
|
672 |
].
|
|
673 |
^ self
|
|
674 |
].
|
|
675 |
(aChange isClassCommentChange) ifTrue:[
|
|
676 |
previousPackage classRenameChange:aChange.
|
|
677 |
previousPackage ~= currentPackage ifTrue:[
|
|
678 |
currentPackage classRenameChange:aChange.
|
|
679 |
].
|
|
680 |
^ self
|
|
681 |
].
|
|
682 |
|
|
683 |
self halt.
|
|
684 |
].
|
|
685 |
|
|
686 |
(aChange isClassChange) ifFalse:[
|
|
687 |
self halt:' What is this???'.
|
|
688 |
].
|
|
689 |
|
|
690 |
self halt.
|
|
691 |
! !
|
|
692 |
|
|
693 |
!PackageManager methodsFor:'checks'!
|
|
694 |
|
|
695 |
canLoadPackage:aPackage
|
|
696 |
""
|
|
697 |
(self includesPackage:aPackage) ifTrue:[
|
|
698 |
Notification raise.
|
|
699 |
].
|
|
700 |
! !
|
|
701 |
|
|
702 |
!PackageManager methodsFor:'enumarating'!
|
|
703 |
|
|
704 |
packagesDo:aOneArgBlock
|
|
705 |
aOneArgBlock value:workingPackage.
|
|
706 |
super packagesDo:aOneArgBlock.
|
|
707 |
! !
|
|
708 |
|
|
709 |
!PackageManager methodsFor:'errors'!
|
|
710 |
|
|
711 |
recoveryHandlerDo:aBlock forException:packageErrorClass
|
|
712 |
"an atomic action is about to happen. This should succeed or
|
|
713 |
fail and return to the previous state."
|
|
714 |
|
|
715 |
"to do - this could be done by an extra class.
|
|
716 |
could save the state of the receiver before this action is done
|
|
717 |
along with a 'transaction number' held in the receivers class to make
|
|
718 |
sure we are consistant. The hard copy could then be the backup. This
|
|
719 |
all depends on how long it takes to make the backup and how often
|
|
720 |
we are going to do this.
|
|
721 |
"
|
|
722 |
packageErrorClass handle:[:ex |
|
|
723 |
Transcript show:ex errorString.
|
|
724 |
] do:[
|
|
725 |
aBlock value
|
|
726 |
]
|
|
727 |
! !
|
|
728 |
|
|
729 |
!PackageManager methodsFor:'factory'!
|
|
730 |
|
|
731 |
getPackageSaverForPackage:aPackage
|
|
732 |
^ StxPackageFileWriter forPackage:aPackage
|
|
733 |
!
|
|
734 |
|
|
735 |
newPackageNamed:aString
|
|
736 |
| newPackage |
|
|
737 |
|
|
738 |
(self includesPackageNamed:aString) ifTrue:[
|
|
739 |
self breakPoint:''. "put some sort of error here"
|
|
740 |
].
|
|
741 |
|
|
742 |
newPackage := self packageClass named:aString addToManager:self.
|
|
743 |
newPackage initializeInstalled.
|
|
744 |
^ newPackage
|
|
745 |
!
|
|
746 |
|
|
747 |
packageClass
|
|
748 |
^ Package
|
|
749 |
! !
|
|
750 |
|
|
751 |
!PackageManager methodsFor:'initialization'!
|
|
752 |
|
|
753 |
initialize
|
|
754 |
super initialize.
|
|
755 |
!
|
|
756 |
|
|
757 |
uninitialize
|
|
758 |
|
|
759 |
self packagesDo:[:aPackage |
|
|
760 |
self removeDependent:aPackage.
|
|
761 |
].
|
|
762 |
workingPackage removeDependent:self.
|
|
763 |
|
|
764 |
packages := nil.
|
|
765 |
super uninitialize.
|
|
766 |
! !
|
|
767 |
|
|
768 |
!PackageManager methodsFor:'private-opening'!
|
|
769 |
|
|
770 |
getPackageHandlerForPackage:aPackage
|
|
771 |
|
|
772 |
| aPackageHandler |
|
|
773 |
|
|
774 |
(aPackageHandler := aPackage packageHandler) ifNil:[
|
|
775 |
aPackageHandler := PackageHandler forPackage:aPackage.
|
|
776 |
].
|
|
777 |
|
|
778 |
^ aPackageHandler
|
|
779 |
!
|
|
780 |
|
|
781 |
getPackageReaderForFile:aFilename
|
|
782 |
^ StxPackageFileReader forFilename:aFilename
|
|
783 |
! !
|
|
784 |
|
|
785 |
!PackageManager methodsFor:'queries'!
|
|
786 |
|
|
787 |
packagesIncludes:anObject
|
|
788 |
^ ((packages includes:anObject)or:[workingPackage == anObject])
|
|
789 |
! !
|
|
790 |
|
|
791 |
!PackageManager class methodsFor:'documentation'!
|
|
792 |
|
|
793 |
version
|
1242
|
794 |
^ '$Header: /cvs/stx/stx/libbasic3/packages/PackageManager.st,v 1.2 2003-04-10 12:42:47 james Exp $'
|
1231
|
795 |
! !
|
|
796 |
|
|
797 |
PackageManager initialize!
|