"
COPYRIGHT (c) 1993 by Claus Gittinger
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:libbasic3' }"
ClassChange subclass:#ClassDefinitionChange
instanceVariableNames:'objectType nameSpaceName superClassName classType indexedType
otherParameters instanceVariableNames classVariableNames
classInstanceVariableNames poolDictionaries category private
definitionSelector owningClassName'
classVariableNames:''
poolDictionaries:''
category:'System-Changes'
!
!ClassDefinitionChange class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1993 by Claus Gittinger
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.
"
!
documentation
"
instances represent class definition-changes.
They are typically held in a ChangeSet.
[author:]
Claus Gittinger
"
! !
!ClassDefinitionChange methodsFor:'accessing'!
basicSuperClassName
^ superClassName
!
category
category isNil ifTrue:[
self setupFromSource.
].
^ category
"Modified: / 11-10-2006 / 14:12:01 / cg"
!
category:something
category := something.
!
classInstanceVariableNames
^ classInstanceVariableNames
!
classInstanceVariableNames:something
classInstanceVariableNames := something.
!
classVariableNames
^ classVariableNames
!
classVariableNames:something
classVariableNames := something.
!
instanceVariableNames
^ instanceVariableNames
!
instanceVariableNames:something
instanceVariableNames := something.
!
nameSpaceName
objectType == #variable ifTrue:[
^ nil
].
^ self cutNameSpaceOf:(nameSpaceName ? super nameSpaceName)
!
nameSpaceName: aNameSpaceName classType: aClassType otherParameters:otherParametersArg
"this instance setup message is used when reading from a VW-xml change file.
Support for this is not yet complete."
|indexedType imports|
nameSpaceName := aNameSpaceName.
classType := aClassType.
otherParameters := Dictionary new addAll:otherParametersArg; yourself.
superClassName := otherParameters at:#superclass: ifAbsent:nil.
superClassName notNil ifTrue:[
superClassName := superClassName pathString.
].
indexedType := otherParameters at:#indexedType: ifAbsent:nil.
private := otherParameters at:#private: ifAbsent:nil.
instanceVariableNames := otherParameters at:#instanceVariableNames: ifAbsent:nil.
classInstanceVariableNames := otherParameters at:#classInstanceVariableNames: ifAbsent:nil.
imports := otherParameters at:#imports: ifAbsent:nil.
category := otherParameters at:#category: ifAbsent:nil.
"Modified: / 11-10-2006 / 14:06:47 / cg"
!
objectType
"return the value of the instance variable 'objectType' (automatically generated)"
^ objectType
!
objectType:something
"set the value of the instance variable 'objectType' (automatically generated)"
objectType := something.
!
package:aPackageID
package := aPackageID
!
poolDictionaries
^ poolDictionaries
!
poolDictionaries:something
poolDictionaries := something.
!
source
"return the source of the change"
|src nsName|
(src := source) isNil ifTrue:[
src := self definitionString
].
(nsName := self nameSpaceName) notNil ifTrue:[
^ '"{ NameSpace: ' , nsName , ' }"' ,
Character cr, Character cr ,
src
].
^ src
!
superClassName
|nm|
nm := superClassName.
nm notNil ifTrue:[
(nm includes:$.) ifTrue:[
^ nm copyReplaceAll:$. withAll:'::'.
]
].
^ nm
!
superClassName:something
superClassName := something.
!
superClassNameWithoutMyNamespace
|nm|
nm := self cutMyNameSpaceOf:superClassName.
(nm includes:$.) ifTrue:[
^ nm copyReplaceAll:$. withAll:'::'.
].
^ nm
!
superClassNameWithoutNamespace
|nm|
nm := self cutNameSpaceOf:superClassName.
(nm includes:$.) ifTrue:[
^ nm copyReplaceAll:$. withAll:'::'.
].
^ nm
! !
!ClassDefinitionChange methodsFor:'comparing'!
isForSameAs:changeB
"return true, if the given change represents a change for the same
thingy as the receiver (i.e. same method, same definition etc.)."
changeB isClassDefinitionChange ifFalse:[^ false].
className ~= changeB className ifTrue:[^ false].
^ true
!
sameAs:changeB
"return true, if the given change represents the same change as the receiver."
(self isForSameAs:changeB) ifFalse:[^ false].
^ self sameSourceAs:changeB
! !
!ClassDefinitionChange methodsFor:'printing & storing'!
definitionString
objectType == #variable ifTrue:[
^ String streamContents:[:stream |
stream
nextPutAll:((nameSpaceName asCollectionOfSubstringsSeparatedBy:$.) asStringWith:'::');
nextPutAll:' addClassVarName:';
nextPutAll:className asString storeString
].
].
^ String streamContents:[:stream |
stream
nextPutAll:self superClassNameWithoutMyNamespace;
nextPutAll:' subclass:';
nextPutAll:"self" className asSymbol storeString
;
cr;
spaces:4;
nextPutAll:'instanceVariableNames: ';
nextPutAll:(instanceVariableNames ? '') storeString;
cr;
spaces:4;
nextPutAll:'classVariableNames: ';
nextPutAll:(classVariableNames ? '') storeString;
cr;
spaces:4;
nextPutAll:'poolDictionaries: ';
nextPutAll:(poolDictionaries ? '') storeString;
cr;
spaces:4;
nextPutAll:'category: ';
nextPutAll:(category ? '') storeString
]
!
printOn:aStream
aStream
nextPutAll:className; nextPutAll:' {definition}'
"Modified: / 12-10-2006 / 17:48:28 / cg"
!
printWithoutClassNameOn:aStream
aStream nextPutAll:('definition of ' , className)
! !
!ClassDefinitionChange methodsFor:'queries'!
cutMyNameSpaceOf:aString
|dotIndex colonIndex|
aString isNil ifTrue:[ ^ aString ].
nameSpaceName isNil ifTrue:[ ^ aString ].
(aString startsWith:(nameSpaceName , '.')) ifTrue:[ ^ self cutNameSpaceOf:aString ].
(aString startsWith:(nameSpaceName , '::')) ifTrue:[ ^ self cutNameSpaceOf:aString ].
^ aString
!
definitionSelector
definitionSelector isNil ifTrue:[
self setupFromSource.
].
^ definitionSelector
"Modified: / 11-10-2006 / 14:11:44 / cg"
!
isClassDefinitionChange
^ true
!
isPrivateClassDefinitionChange
private isNil ifTrue:[
(className includes:$:) ifFalse:[
"/ cannot be private
private := false
] ifTrue:[
(self changeClass notNil
and:[self changeClass isLoaded not]) ifTrue:[
"/ cannot be private
private := false
] ifTrue:[
self setupFromSource.
].
].
].
^ private
"Created: / 11-10-2006 / 14:19:03 / cg"
"Modified: / 13-11-2006 / 17:04:32 / cg"
!
owningClassName
self isPrivateClassDefinitionChange ifTrue:[
owningClassName isNil ifTrue:[
self setupFromSource.
].
].
^ owningClassName
"Created: / 12-10-2006 / 23:07:25 / cg"
! !
!ClassDefinitionChange methodsFor:'special'!
installAsAutoloadedClassIfPublicWithFilename:aFilenameString
"install the class defined by this change as autoloaded.
Skip private classes.
Enter class file name as abbreviation"
|parseTree sel cat clsName cls catIdx pkg|
parseTree := Parser parseExpression:self source.
parseTree isMessage ifFalse:[
self error:'bad change source'.
].
sel := parseTree selector.
(sel endsWith:':privateIn:') ifTrue:[^ self].
catIdx := sel keywords indexOf:'category:'.
catIdx ~~ 0 ifTrue:[
cat := (parseTree args at:catIdx) evaluate.
].
clsName := self className asSymbol.
cls := Smalltalk at:clsName.
pkg := package ? Project current package.
(cls isNil
or:[cls isBehavior not
or:[cls isLoaded not]]) ifTrue:[
|autoloadedClass|
autoloadedClass := Smalltalk
installAutoloadedClassNamed:clsName
category:cat
package:pkg
revision:nil.
aFilenameString notNil ifTrue:[
autoloadedClass setClassFilename:aFilenameString.
"/ Smalltalk setFilename:aFilenameString forClass:clsName package:pkg.
]
] ifFalse:[
cls notNil ifTrue:[
cls isBehavior ifTrue:[
cls package ~= pkg ifTrue:[
Transcript showCR:'oops - package change in ',clsName.
]
].
].
].
"Modified: / 13-11-2006 / 17:18:50 / cg"
!
setupFromSource
"extract privacy, category and selector from the source"
|parseTree catIdx|
source notNil ifTrue:[
parseTree := Parser parseExpression:source.
(parseTree notNil and:[parseTree isMessage]) ifFalse:[
self error:'bad change source' mayProceed:true.
^ self
].
definitionSelector := parseTree selector.
private := (definitionSelector endsWith:':privateIn:').
private ifTrue:[
owningClassName := parseTree args last name.
].
catIdx := definitionSelector keywords indexOf:'category:'.
catIdx ~~ 0 ifTrue:[
category := (parseTree args at:catIdx) evaluate.
].
].
"Created: / 11-10-2006 / 14:10:02 / cg"
"Modified: / 26-10-2006 / 19:29:17 / cg"
! !
!ClassDefinitionChange class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libbasic3/ClassDefinitionChange.st,v 1.44 2006-11-13 16:29:06 cg Exp $'
! !