Improvement in QuickFixer - if the fix is local to the method, only update codeview's contents.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 18 Sep 2013 01:30:51 +0100
changeset 92 67592095147e
parent 91 920e30d788dc
child 93 f50bd9fded52
Improvement in QuickFixer - if the fix is local to the method, only update codeview's contents.
SmallSense__SmalltalkQuickFixer.st
--- a/SmallSense__SmalltalkQuickFixer.st	Wed Sep 18 01:29:45 2013 +0100
+++ b/SmallSense__SmalltalkQuickFixer.st	Wed Sep 18 01:30:51 2013 +0100
@@ -99,20 +99,34 @@
 !SmalltalkQuickFixer methodsFor:'utilities'!
 
 apply: allChanges
-    | changes |
+
+    allChanges isEmptyOrNil ifTrue:[ ^ self ].
+    (allChanges size == 1 and:[allChanges anElement isMethodCodeChange]) ifTrue:[
+        | oldSource newSource |
 
-    changes := Tools::ChangeSetBrowser2 confirmChanges: allChanges.
-    changes isEmptyOrNil ifTrue:[ ^ self ].
-    (changes size == 1 and:[view reallyModified]) ifTrue:[
-        view contents: changes anElement source clear: false.
+        oldSource := view contents asString string.
+        newSource := allChanges anElement source asString.
+        oldSource ~= newSource ifTrue:[
+            view list: newSource asStringCollection.
+            view modified: true.
+            view isCodeView2 ifTrue:[
+                view reallyModifiedChannel value: true.
+            ]
+        ].
     ] ifFalse:[
         | browser |
 
-
-        self halt.
+       browser := view application topApplication.
+       (browser respondsTo: #performRefactoring:) ifTrue:[
+           browser performRefactoring: allChanges.
+       ] ifFalse:[
+           self breakPoint: #jv.
+           Dialog warn: 'Sorry, this application does not support quick fixes'
+       ]
     ]
 
     "Created: / 16-02-2012 / 14:46:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-09-2013 / 00:36:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkQuickFixer::QuickFix methodsFor:'accessing'!