ClassDefinitionChange.st
author Claus Gittinger <cg@exept.de>
Tue, 10 Sep 2002 13:53:27 +0200
changeset 1162 4af27057a3ce
parent 1134 915934e8aab8
child 1178 3d3111846c92
permissions -rw-r--r--
comment

"
 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:'definition objectType nameSpaceName package classType
		otherParameters'
	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'!

nameSpaceName
    ^ nameSpaceName ? super nameSpaceName
!

nameSpaceName: aNameSpaceName classType: aClassType otherParameters: someOtherParameters
    nameSpaceName := aNameSpaceName.
    classType := aClassType.
    otherParameters := someOtherParameters
!

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
!

source
    "return the source of the change"

    |nsName|

    (nsName := self nameSpaceName) notNil ifTrue:[
        ^ '"{ NameSpace: ' , nsName , ' }"' , 
          Character cr, Character cr , 
          super source 
    ].
    ^ super source
! !

!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'!

printOn:aStream
    aStream nextPutAll:className
!

printWithoutClassNameOn:aStream
    aStream nextPutAll:('definition of ' , className)


! !

!ClassDefinitionChange methodsFor:'queries'!

definitionSelector
    |parseTree|

    parseTree := Parser parseExpression:self source.
    parseTree isMessage ifTrue:[
        ^ parseTree selector
    ].
    self error:'should not happen'.
!

isClassDefinitionChange
    ^ true
! !

!ClassDefinitionChange methodsFor:'special'!

installAsAutoloadedClassIfNotPrivate
    |parseTree sel cat clsName catIdx|

    parseTree := Parser parseExpression:self source.
    parseTree isMessage ifFalse:[
        self error:'should not happen: 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.

    ((Smalltalk includesKey:clsName) not 
    or:[ (Smalltalk at:clsName) isBehavior not]) ifTrue:[
         Smalltalk 
            installAutoloadedClassNamed:clsName 
            category:cat 
            package:(package ? Project current package) 
            revision:nil
    ]
! !

!ClassDefinitionChange class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic3/ClassDefinitionChange.st,v 1.26 2002-09-10 11:53:02 cg Exp $'
! !