MCClassDefinition.st
changeset 470 ce343aed87ed
parent 464 3968b4ac1483
child 521 ac7de5d52ead
--- a/MCClassDefinition.st	Wed Sep 07 13:01:18 2011 +0200
+++ b/MCClassDefinition.st	Wed Sep 07 14:04:26 2011 +0200
@@ -2,7 +2,7 @@
 
 MCDefinition subclass:#MCClassDefinition
 	instanceVariableNames:'name superclassName variables category type comment commentStamp
-		traitComposition classTraitComposition'
+		traitComposition classTraitComposition installedClassName'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Monticello-Modeling'
@@ -173,6 +173,21 @@
 	^ self selectVariables: #isInstanceVariable
 !
 
+installedClass
+        ^Smalltalk classNamed: self installedClassName
+
+    "Created: / 07-09-2011 / 13:33:10 / cg"
+!
+
+installedClassName
+    "if there was a namespace override, the installedClassName might be different
+     from the class name"
+
+    ^ installedClassName ? name
+
+    "Created: / 07-09-2011 / 13:29:21 / cg"
+!
+
 poolDictionaries
 	^ self selectVariables: #isPoolImport
 !
@@ -286,20 +301,38 @@
 !MCClassDefinition methodsFor:'installing'!
 
 createClass
-        | superClass class |
-        superClass := Smalltalk at: superclassName.
+        "cg: changed to honor any nameSpace query override"
+
+        | env superClass class installedSuperclassName|
+
+        env := MCStXNamespaceQuery query ? Smalltalk.
+        superClass := env at: superclassName.
+        (superClass isNil and:[env ~~ Smalltalk]) ifTrue:[
+            superClass := Smalltalk at: superclassName.
+        ].
+
         "Create class if not exists"
-        superClass ifNil:[superClass := Class undeclared: superclassName].
+        superClass isNil ifTrue:[
+            installedSuperclassName := (env == Smalltalk)
+                                            ifTrue:[ superclassName ]
+                                            ifFalse:[ env name ,'::',superclassName].
+            superClass := Class undeclared: installedSuperclassName
+        ].
+
+        "/ env := superClass environment. 
 
         class := (ClassBuilder new)
                         name: name 
-                        inEnvironment: superClass environment 
+                        inEnvironment: env
                         subclassOf: superClass
                         type: type 
                         instanceVariableNames: self instanceVariablesString 
                         classVariableNames: self classVariablesString 
                         poolDictionaries: self sharedPoolsString
                         category: category.
+
+        installedClassName := class name.
+
         self traitComposition ifNotNil: [
                 class setTraitComposition: (Compiler
                         evaluate: self traitComposition) asTraitComposition ].
@@ -309,17 +342,20 @@
         ^class.
 
     "Modified: / 09-11-2010 / 08:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 07-09-2011 / 13:32:38 / cg"
 !
 
 load
     | class |
 
-    (class := self createClass) ifNotNil:
-        [class class instanceVariableNames: self classInstanceVariablesString.
-        self hasComment ifTrue: [class classComment: comment stamp: commentStamp]].
+    (class := self createClass) notNil ifTrue:[
+        class class instanceVariableNames: self classInstanceVariablesString.
+        self hasComment ifTrue: [class classComment: comment stamp: commentStamp]
+    ].
     class package: MCStXPackageQuery query.
 
     "Modified: / 14-09-2010 / 22:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-09-2011 / 13:01:53 / cg"
 !
 
 stringForSortedVariablesOfType: aSymbol
@@ -531,11 +567,11 @@
 !MCClassDefinition class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.5 2011-09-05 05:26:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.6 2011-09-07 12:04:26 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.5 2011-09-05 05:26:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCClassDefinition.st,v 1.6 2011-09-07 12:04:26 cg Exp $'
 !
 
 version_SVN