BrowserView.st
changeset 2781 01e49ccd049e
parent 2753 a22517af548d
child 2799 562ffeb2dc62
--- a/BrowserView.st	Sat Sep 16 15:12:40 2000 +0200
+++ b/BrowserView.st	Sat Sep 16 20:43:34 2000 +0200
@@ -5127,7 +5127,19 @@
                                            title:'choose and rename as required'
                 ]
             ] ifFalse:[
-                self warn:'oops - could not find that class'
+                Class allSubInstancesDo:[:aClass |
+                    aClass isMeta ifFalse:[
+                        (Smalltalk at:aClass name) ~~ aClass ifTrue:[
+                            classes add:aClass
+                        ]
+                    ]
+                ].
+                classes size > 0 ifTrue:[
+                    self warn:'oops - could not a class with that name.\\Please see all classes which are not found in Smalltalk and fix things manually.' withCRs.
+                    classes inspect
+                ] ifFalse:[
+                    self warn:'oops - could not a class with that name.'.
+                ]
             ]
         ]
     ].
@@ -5608,17 +5620,68 @@
     "Modified: 30.7.1997 / 17:47:24 / cg"
 !
 
-renameCurrentClassTo:aString
+renameCurrentClassTo:newNameString
     "helper - do the class-rename"
 
     self doClassMenu:[:currentClass |
-        |oldSym oldBaseSym cls|
+        |oldSym oldBaseSym cls newOwnerOrNameSpacePath nsOrOwner s nextWord t hardRename|
+
+        newNameString = currentClass name ifTrue:[^ self].
+
+        newOwnerOrNameSpacePath := OrderedCollection new.
+
+        nsOrOwner := Smalltalk.
+        s := newNameString readStream.
+        [s atEnd] whileFalse:[
+            nextWord := s nextAlphaNumericWord.
+            s skipSeparators.
+            s atEnd ifFalse:[
+                nsOrOwner isNameSpace ifTrue:[
+                    t := nsOrOwner at:nextWord asSymbol
+                ] ifFalse:[
+                    t := nsOrOwner privateClassesAt:nextWord asSymbol
+                ].
+                t isNil ifTrue:[
+                    self warn:('Name: ''' , newNameString , ''' specifies a non-existing NameSpace or Ownerclass.\\(no ''' , nextWord , ''' in ''' , nsOrOwner name , ')') withCRs.
+                    ^ self
+                ].
+                nsOrOwner := t.
+                s peek == $. ifTrue:[
+                    s next.
+                ] ifFalse:[
+                    s peek == $: ifTrue:[
+                        s next.
+                        s next ~= $: ifTrue:[
+                            self warn:'Bad name: ''' , newNameString , ''' (either use ''.'' or ''::'' as nameSpace separator)'.
+                            ^ self
+                        ]
+                    ]
+                ]
+            ]
+        ].
+        nsOrOwner isNil ifTrue:[
+            self warn:'Name ''' , newNameString , ''' specifies a non-existing NameSpace or Ownerclass'.
+            ^ self
+        ].
+
+        hardRename := false.
+        currentClass isPrivate ifTrue:[
+            "/ check if the new name implies an owner-change
+            hardRename := (nsOrOwner ~~ currentClass owningClass)
+        ] ifFalse:[
+            hardRename := (nsOrOwner ~~ Smalltalk)
+        ].
+        hardRename ifTrue:[
+            (self confirm:'New name implies a NameSpace or OwningClass change - is this what you want ?') ifFalse:[
+                ^ self
+            ]
+        ].
 
         "/ check if the target already exists - confirm if so.
 
-        (cls := Smalltalk classNamed:aString) notNil ifTrue:[
+        (cls := Smalltalk classNamed:newNameString) notNil ifTrue:[
             (self confirm:(resources string:'WARN_RENAME' 
-                                     with:aString 
+                                     with:newNameString 
                                      with:cls category) withCRs)
                 ifFalse:[^ self]
         ].
@@ -5631,7 +5694,7 @@
         "/ think (care for classVariables, privateClasses etc.)
         "/ Smalltalk knows all about that ...
 
-        Smalltalk renameClass:currentClass to:aString.
+        Smalltalk renameClass:currentClass to:newNameString.
 
         self updateClassList.
         self updateMethodCategoryListWithScroll:false.
@@ -13815,6 +13878,6 @@
 !BrowserView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.636 2000-09-03 15:43:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.637 2000-09-16 18:43:34 cg Exp $'
 ! !
 BrowserView initialize!