CodeGeneratorTool.st
branchjv
changeset 16445 6bc184e74f9c
parent 16408 bc62fb9a8df6
parent 16429 6c37ed85b725
child 16695 a8eda516effa
--- a/CodeGeneratorTool.st	Wed May 04 08:21:04 2016 +0200
+++ b/CodeGeneratorTool.st	Thu May 05 06:48:38 2016 +0200
@@ -364,7 +364,7 @@
     "install some code for a class.
      If refactory browser stuff is avaliable the refactory tools are used to support undo"
 
-    ^ self new compile:theCode forClass:aClass inCategory:cat
+    self new compile:theCode forClass:aClass inCategory:cat
 ! !
 
 !CodeGeneratorTool class methodsFor:'defaults'!
@@ -1715,10 +1715,9 @@
     "install some code for a class.
      If refactory browser stuff is avaliable the refactory tools are used to support undo"
 
-    |change compiler selector oldMethod isSame category|
+    |change compiler selector oldMethod category|
 
-    isSame := false.
-    category := categoryOrNil ? (Compiler defaultMethodCategory).
+    category := categoryOrNil.
 
     skipIfSame ifTrue:[
         "JV: Do not use class's compilerClass, it may differ from
@@ -1735,31 +1734,38 @@
         selector := compiler selector.
         selector notNil ifTrue:[
             oldMethod := aClass compiledMethodAt:selector.
-            isSame := (oldMethod notNil and:[oldMethod source = theCode]).
-            isSame ifTrue:[^ self ].
             oldMethod notNil ifTrue:[
-                category := categoryOrNil ? (oldMethod category).
+                oldMethod source = theCode ifTrue:[^ self ]. "/ the same.
+            
+                categoryOrNil isNil ifTrue:[
+                    "/ if no category given, take the existing one.
+                    category := oldMethod category.
+                ].
             ].
         ].
     ].
 
+    category isNil ifTrue:[
+        category := Compiler defaultMethodCategory.
+    ].    
+
     self canUseRefactoringSupport ifFalse:[
         "/ compile immediately
-        aClass compile:theCode classified:category.
-        ^ self.
+        ^ aClass compile:theCode classified:category.
     ].
 
     change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:category.
     change controller:(CompilationErrorHandlerQuery query).
 
-    "/ if collecting, add to changes (to be executed as one change at the end,
-    "/ in order to have only one change in the undo-list (instead of many)
     compositeChangeCollector notNil ifTrue:[
-        compositeChangeCollector addChange:change
+        "/ if collecting, add to changes, to be executed as one change at the end.
+        "/ In order to have only one change in the undo-list (instead of many)
+        compositeChangeCollector addChange:change.
     ] ifFalse:[
+        "/ do it now.
         RefactoryChangeManager performChange:change.
-    ]
-
+    ].
+    
     "Modified: / 21-08-2006 / 18:39:06 / cg"
     "Modified (format): / 21-01-2012 / 10:40:59 / cg"
     "Modified (format): / 05-08-2014 / 21:06:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"