Make CustomContext>>selectedClasses always return a collection of RBClass...
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 14 Nov 2014 20:15:29 +0100
changeset 746 a25dc307d4e8
parent 745 2dd476349eba
child 747 008860f4cbd4
Make CustomContext>>selectedClasses always return a collection of RBClass... ...as opposed to real classes which it used to return.
CustomBrowserContext.st
CustomContext.st
CustomRefactoryBuilder.st
CustomSimpleGetterMethodsCodeGeneratorTests.st
CustomSubContext.st
--- a/CustomBrowserContext.st	Fri Nov 14 20:11:00 2014 +0100
+++ b/CustomBrowserContext.st	Fri Nov 14 20:15:29 2014 +0100
@@ -42,10 +42,10 @@
     "Returns a set of classes currently selected in
      the browser"
 
-    ^ state selectedClasses value
+    ^ state selectedClasses value collect:[ :cls | self asRBClass: cls ]
 
     "Created: / 26-01-2014 / 22:06:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-01-2014 / 23:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-11-2014 / 20:08:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 selectedCodes
--- a/CustomContext.st	Fri Nov 14 20:11:00 2014 +0100
+++ b/CustomContext.st	Fri Nov 14 20:15:29 2014 +0100
@@ -2,12 +2,22 @@
 
 Object subclass:#CustomContext
 	instanceVariableNames:''
-	classVariableNames:''
+	classVariableNames:'SmalltalkNamespace'
 	poolDictionaries:''
 	category:'Interface-Refactoring-Custom'
 !
 
 
+!CustomContext class methodsFor:'initialization'!
+
+initialize
+    "Invoked at system start or when the class is dynamically loaded."
+
+    SmalltalkNamespace := RBNamespace onEnvironment: BrowserEnvironment new.
+
+    "Modified: / 14-11-2014 / 19:28:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CustomContext class methodsFor:'queries'!
 
 isAbstract
@@ -79,6 +89,20 @@
     "Created: / 05-05-2014 / 00:14:59 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
 ! !
 
+!CustomContext methodsFor:'private'!
+
+asRBClass: cls 
+    "For given real class, return a curresponding RBClass"
+
+    ^ Object isMetaclass 
+        ifTrue:[ SmalltalkNamespace metaclassNamed: cls theNonMetaclass name]
+        ifFalse:[SmalltalkNamespace classNamed: cls name ]
+
+    "Ceated: / 14-11-2014 / 19:26:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
+    "Created: / 14-11-2014 / 19:26:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CustomContext methodsFor:'testing'!
 
 isInteractiveContext
@@ -101,3 +125,5 @@
     ^ '$Changeset: <not expanded> $'
 ! !
 
+
+CustomContext initialize!
--- a/CustomRefactoryBuilder.st	Fri Nov 14 20:11:00 2014 +0100
+++ b/CustomRefactoryBuilder.st	Fri Nov 14 20:15:29 2014 +0100
@@ -260,13 +260,14 @@
 
     change := InteractiveAddMethodChange
         compile: (formatter formatParseTree: (self parseMethod: newTree newSource))
-        in: aMethod mclass 
+        in: aMethod modelClass 
         classified: aMethod category.
 
     changes add: change
 
     "Created: / 17-08-2014 / 18:45:20 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
     "Modified: / 31-08-2014 / 17:41:35 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+    "Modified: / 14-11-2014 / 19:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 initializeChange: aChangeClass
--- a/CustomSimpleGetterMethodsCodeGeneratorTests.st	Fri Nov 14 20:11:00 2014 +0100
+++ b/CustomSimpleGetterMethodsCodeGeneratorTests.st	Fri Nov 14 20:15:29 2014 +0100
@@ -7,6 +7,7 @@
 	category:'Interface-Refactoring-Custom-Generators-Tests'
 !
 
+
 !CustomSimpleGetterMethodsCodeGeneratorTests methodsFor:'accessing'!
 
 generatorOrRefactoring
@@ -49,3 +50,10 @@
     "Modified: / 14-06-2014 / 10:41:19 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
 ! !
 
+!CustomSimpleGetterMethodsCodeGeneratorTests class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/CustomSubContext.st	Fri Nov 14 20:11:00 2014 +0100
+++ b/CustomSubContext.st	Fri Nov 14 20:15:29 2014 +0100
@@ -25,11 +25,18 @@
     selectedClassCategories := something.
 !
 
-selectedClasses: aClassCollection
+selectedClasses: classes
+    "Sets the list of classes"
+    | rbclasses |
 
-    selectedClasses := aClassCollection
+    "classes is supposed to be a collection of RBClass. However, if real classes
+     are passed, they are converted to RBClasses here for your convenience"
+
+    rbclasses := classes collect:[ :cls | cls isBehavior ifTrue:[ self asRBClass:cls ] ifFalse:[ cls ] ].
+    selectedClasses := rbclasses
 
     "Created: / 26-04-2014 / 16:05:34 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+    "Modified: / 14-11-2014 / 19:26:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 selectedCodes: something