#REFACTORING by cg
class: CodeGeneratorTool
changed:
#compile:forClass:inCategory:
#compile:forClass:inCategory:skipIfSame:
--- a/CodeGeneratorTool.st Wed May 04 12:58:02 2016 +0200
+++ b/CodeGeneratorTool.st Wed May 04 12:58:24 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'!
@@ -1709,10 +1709,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
@@ -1729,31 +1728,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>"