class: Metaclass
authorClaus Gittinger <cg@exept.de>
Wed, 31 Dec 2014 10:15:58 +0100
changeset 17277 41175deb61ee
parent 17276 6642666dd477
child 17278 7813956ffab4
class: Metaclass changed: #basicFileOutDefinitionOf:on:withNameSpace:withPackage:syntaxHilighting: always write a namespace pragma - even for classes in the smalltalk namespace
Metaclass.st
--- a/Metaclass.st	Wed Dec 31 10:09:55 2014 +0100
+++ b/Metaclass.st	Wed Dec 31 10:15:58 2014 +0100
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic' }"
 
+"{ NameSpace: Smalltalk }"
+
 ClassDescription subclass:#Metaclass
 	instanceVariableNames:'myClass'
 	classVariableNames:'ConfirmationQuerySignal'
@@ -109,6 +111,7 @@
     "Modified: 23.4.1996 / 15:59:44 / cg"
 ! !
 
+
 !Metaclass methodsFor:'Compatibility-ST80'!
 
 comment:aString
@@ -127,6 +130,7 @@
     "Created: / 1.11.1997 / 13:16:45 / cg"
 ! !
 
+
 !Metaclass methodsFor:'autoload check'!
 
 isLoaded
@@ -403,7 +407,7 @@
 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage syntaxHilighting:syntaxHilighting
     "append an expression on aStream, which defines myself."
 
-    |s owner ns nsName fullName forceNoNameSpace superNameWithoutNameSpacePrefix cls topOwner
+    |s owner namespace nsName fullName forceNoNameSpace superNameWithoutNameSpacePrefix cls topOwner
      superclass superclassNamespace nm useStoreString boldOn boldOff pkg|
 
     syntaxHilighting ifTrue:[
@@ -413,7 +417,7 @@
 
     fullName := FileOutNameSpaceQuerySignal query == true.
     owner := aClass owningClass.
-    ns := aClass topNameSpace.
+    namespace := aClass topNameSpace.
 
     (showPackage and:[owner isNil]) ifTrue:[
         pkg := aClass getPackage.
@@ -444,8 +448,8 @@
 
     fullName ifFalse:[
         (owner isNil or:[forceNameSpace]) ifTrue:[
-            (ns notNil and:[ns ~~ Smalltalk]) ifTrue:[
-                nsName := ns name.
+            (namespace notNil and:[namespace ~~ Smalltalk]) ifTrue:[
+                nsName := namespace name.
                 (nsName includes:$:) ifTrue:[
                     nsName := '''' , nsName , ''''
                 ].
@@ -454,7 +458,13 @@
                 aStream nextPutAll:nsName.
                 boldOff value.
                 aStream nextPutAll:' }"'; cr; cr.
-            ]
+            ] ifFalse:[
+                "/ always write a namespace directive - even for smalltalk classes.
+                "/ reason: the fileout might go into a big file containing multiple classes
+                "/ in different namespaces (otherwise, the smalltalk class would later be filed into
+                "/ the previous class's namespace)
+                aStream nextPutAll:'"{ NameSpace: Smalltalk }"'; cr; cr.
+            ].
         ].
     ].
 
@@ -480,7 +490,7 @@
             fullName ifTrue:[
                 s := superclass name.
             ] ifFalse:[
-                (ns == superclassNamespace
+                (namespace == superclassNamespace
                 and:[superclass owningClass isNil]) ifTrue:[
                     "/ superclass is in the same namespace and not private;
                     "/ still prepend namespace prefix for private classes,
@@ -501,9 +511,9 @@
                     cls := aClass privateClassesAt:superNameWithoutNameSpacePrefix.
                     cls isNil ifTrue:[
                         (topOwner := aClass topOwningClass) isNil ifTrue:[
-                            ns := aClass nameSpace.
-                            ns notNil ifTrue:[
-                                cls := ns privateClassesAt:superNameWithoutNameSpacePrefix
+                            namespace := aClass nameSpace.
+                            namespace notNil ifTrue:[
+                                cls := namespace privateClassesAt:superNameWithoutNameSpacePrefix
                             ] ifFalse:[
                                 "/ aClass error:'unexpected nil namespace'
                             ]
@@ -526,7 +536,7 @@
                             ]]) ifTrue:[
                                 s := superNameWithoutNameSpacePrefix
                             ] ifFalse:[
-                                ns == superclass topNameSpace ifTrue:[
+                                namespace == superclass topNameSpace ifTrue:[
                                     s := superNameWithoutNameSpacePrefix
                                 ] ifFalse:[
                                     s := superclass name
@@ -918,7 +928,7 @@
 !Metaclass class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.214 2014-07-11 12:22:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.215 2014-12-31 09:15:58 cg Exp $'
 ! !