CodeGeneratorTool.st
changeset 6938 6cf52649971c
parent 6937 490dab626876
child 6972 81a87b7dc932
--- a/CodeGeneratorTool.st	Mon Aug 21 18:38:07 2006 +0200
+++ b/CodeGeneratorTool.st	Mon Aug 21 18:38:59 2006 +0200
@@ -1845,6 +1845,43 @@
     ].
 ! !
 
+!CodeGeneratorTool methodsFor:'compilation'!
+
+compile:theCode forClass:aClass inCategory:cat 
+    "install some code for a class.
+     If refactory browser stuff is avaliable the refactory tools are used to support undo"
+
+    |change compiler oldMthd|
+
+    "/ skip if same
+    compiler := aClass compilerClass new.
+    compiler parseMethod:theCode in:aClass ignoreErrors:true ignoreWarnings:true.
+
+    compiler selector notNil ifTrue:[
+        oldMthd := aClass compiledMethodAt:compiler selector.
+        (oldMthd notNil and:[oldMthd source = theCode]) ifTrue:[
+            ^ self.
+        ].
+    ].
+
+    self canUseRefactoringSupport ifFalse:[
+        "/ compile immediately
+        aClass compile:theCode classified:cat.
+        ^ self.
+    ].
+
+    change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat.
+
+    "/ 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
+    ] ifFalse:[
+        RefactoryChangeManager instance performChange:change.
+    ]
+
+    "Modified: / 21-08-2006 / 18:39:06 / cg"
+! !
 
 !CodeGeneratorTool methodsFor:'private'!
 
@@ -1910,5 +1947,5 @@
 !CodeGeneratorTool class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.43 2006-08-21 16:38:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.44 2006-08-21 16:38:59 cg Exp $'
 ! !