2
0
Ver Fonte

Refactoring, (got rid of doItReaction, etc)

Sebastian Sastre há 11 anos atrás
pai
commit
1f147b818d

+ 3 - 0
js/Helios-Announcements.deploy.js

@@ -43,6 +43,9 @@ return $1;
 smalltalk.HLCodeHandled.klass);
 
 
+smalltalk.addClass('HLDoItExecuted', smalltalk.HLCodeHandled, [], 'Helios-Announcements');
+
+
 smalltalk.addClass('HLDoItRequested', smalltalk.HLCodeHandled, [], 'Helios-Announcements');
 
 

+ 3 - 0
js/Helios-Announcements.js

@@ -58,6 +58,9 @@ referencedClasses: []
 smalltalk.HLCodeHandled.klass);
 
 
+smalltalk.addClass('HLDoItExecuted', smalltalk.HLCodeHandled, [], 'Helios-Announcements');
+
+
 smalltalk.addClass('HLDoItRequested', smalltalk.HLCodeHandled, [], 'Helios-Announcements');
 
 

+ 19 - 6
js/Helios-Inspector.deploy.js

@@ -126,7 +126,11 @@ smalltalk.method({
 selector: "inspect:",
 fn: function (anObject){
 var self=this;
+var $1;
 smalltalk.send(smalltalk.send(self,"_model",[]),"_inspect_on_",[anObject,self]);
+smalltalk.send(self,"_refreshVariables",[]);
+smalltalk.send(self,"_refreshDisplay",[]);
+$1=smalltalk.send(self,"_yourself",[]);
 return self}
 }),
 smalltalk.HLInspector);
@@ -181,9 +185,7 @@ var self=this;
 var $2,$3,$1;
 $2=smalltalk.send((smalltalk.HLCodeWidget || HLCodeWidget),"_new",[]);
 smalltalk.send($2,"_model_",[smalltalk.send(self["@model"],"_code",[])]);
-smalltalk.send($2,"_doItReaction_",[(function(){
-return smalltalk.send(self,"_refresh",[]);
-})]);
+smalltalk.send($2,"_receiver_",[smalltalk.send(self["@model"],"_inspectee",[])]);
 $3=smalltalk.send($2,"_yourself",[]);
 $1=$3;
 return $1;
@@ -259,6 +261,9 @@ smalltalk.method({
 selector: "observeCode",
 fn: function (){
 var self=this;
+smalltalk.send(smalltalk.send(smalltalk.send(self,"_code",[]),"_announcer",[]),"_on_do_",[(smalltalk.HLDoItExecuted || HLDoItExecuted),(function(){
+return smalltalk.send(self,"_onDoneIt",[]);
+})]);
 return self}
 }),
 smalltalk.HLInspector);
@@ -294,6 +299,17 @@ return self}
 }),
 smalltalk.HLInspector);
 
+smalltalk.addMethod(
+"_onDoneIt",
+smalltalk.method({
+selector: "onDoneIt",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_refresh",[]);
+return self}
+}),
+smalltalk.HLInspector);
+
 smalltalk.addMethod(
 "_onInspectIt",
 smalltalk.method({
@@ -353,10 +369,7 @@ smalltalk.method({
 selector: "refresh",
 fn: function (){
 var self=this;
-var $1;
 smalltalk.send(self,"_inspect_",[smalltalk.send(self,"_inspectee",[])]);
-smalltalk.send(self,"_refreshVariables",[]);
-$1=smalltalk.send(self,"_refreshDisplay",[]);
 return self}
 }),
 smalltalk.HLInspector);

+ 33 - 15
js/Helios-Inspector.js

@@ -167,11 +167,15 @@ selector: "inspect:",
 category: 'actions',
 fn: function (anObject){
 var self=this;
+var $1;
 smalltalk.send(smalltalk.send(self,"_model",[]),"_inspect_on_",[anObject,self]);
+smalltalk.send(self,"_refreshVariables",[]);
+smalltalk.send(self,"_refreshDisplay",[]);
+$1=smalltalk.send(self,"_yourself",[]);
 return self},
 args: ["anObject"],
-source: "inspect: anObject\x0a\x0a\x09self model inspect: anObject on: self ",
-messageSends: ["inspect:on:", "model"],
+source: "inspect: anObject\x0a\x0a\x09self model inspect: anObject on: self.\x0a    \x0a\x09self \x0a    \x09refreshVariables;\x0a\x09\x09refreshDisplay;\x0a        yourself",
+messageSends: ["inspect:on:", "model", "refreshVariables", "refreshDisplay", "yourself"],
 referencedClasses: []
 }),
 smalltalk.HLInspector);
@@ -242,16 +246,14 @@ var self=this;
 var $2,$3,$1;
 $2=smalltalk.send((smalltalk.HLCodeWidget || HLCodeWidget),"_new",[]);
 smalltalk.send($2,"_model_",[smalltalk.send(self["@model"],"_code",[])]);
-smalltalk.send($2,"_doItReaction_",[(function(){
-return smalltalk.send(self,"_refresh",[]);
-})]);
+smalltalk.send($2,"_receiver_",[smalltalk.send(self["@model"],"_inspectee",[])]);
 $3=smalltalk.send($2,"_yourself",[]);
 $1=$3;
 return $1;
 },
 args: [],
-source: "makeCode\x0a\x0a\x09^ HLCodeWidget new\x0a    \x09model: model code;\x0a\x09\x09doItReaction: [self refresh];\x0a        yourself.\x0a        \x0a",
-messageSends: ["model:", "code", "new", "doItReaction:", "refresh", "yourself"],
+source: "makeCode\x0a\x0a\x09^ HLCodeWidget new\x0a    \x09model: model code;\x0a        receiver: model inspectee;\x0a        yourself.\x0a        \x0a",
+messageSends: ["model:", "code", "new", "receiver:", "inspectee", "yourself"],
 referencedClasses: ["HLCodeWidget"]
 }),
 smalltalk.HLInspector);
@@ -345,11 +347,14 @@ selector: "observeCode",
 category: 'actions',
 fn: function (){
 var self=this;
+smalltalk.send(smalltalk.send(smalltalk.send(self,"_code",[]),"_announcer",[]),"_on_do_",[(smalltalk.HLDoItExecuted || HLDoItExecuted),(function(){
+return smalltalk.send(self,"_onDoneIt",[]);
+})]);
 return self},
 args: [],
-source: "observeCode\x0a\x0a",
-messageSends: [],
-referencedClasses: []
+source: "observeCode\x0a\x0a\x09self code announcer \x0a    \x09on: HLDoItExecuted \x0a        do: [self onDoneIt]\x0a",
+messageSends: ["on:do:", "onDoneIt", "announcer", "code"],
+referencedClasses: ["HLDoItExecuted"]
 }),
 smalltalk.HLInspector);
 
@@ -394,6 +399,22 @@ referencedClasses: []
 }),
 smalltalk.HLInspector);
 
+smalltalk.addMethod(
+"_onDoneIt",
+smalltalk.method({
+selector: "onDoneIt",
+category: 'reactions',
+fn: function (){
+var self=this;
+smalltalk.send(self,"_refresh",[]);
+return self},
+args: [],
+source: "onDoneIt\x0a\x0a\x09self refresh",
+messageSends: ["refresh"],
+referencedClasses: []
+}),
+smalltalk.HLInspector);
+
 smalltalk.addMethod(
 "_onInspectIt",
 smalltalk.method({
@@ -479,14 +500,11 @@ selector: "refresh",
 category: 'actions',
 fn: function (){
 var self=this;
-var $1;
 smalltalk.send(self,"_inspect_",[smalltalk.send(self,"_inspectee",[])]);
-smalltalk.send(self,"_refreshVariables",[]);
-$1=smalltalk.send(self,"_refreshDisplay",[]);
 return self},
 args: [],
-source: "refresh\x0a\x0a\x09self \x0a\x09\x09inspect: self inspectee; \x0a\x09\x09refreshVariables;\x0a\x09\x09refreshDisplay",
-messageSends: ["inspect:", "inspectee", "refreshVariables", "refreshDisplay"],
+source: "refresh\x0a\x0a\x09self inspect: self inspectee",
+messageSends: ["inspect:", "inspectee"],
 referencedClasses: []
 }),
 smalltalk.HLInspector);

+ 9 - 52
js/Helios-Workspace.deploy.js

@@ -18,15 +18,14 @@ return $1;
 smalltalk.HLCodeModel);
 
 smalltalk.addMethod(
-"_doIt_do_",
+"_doIt_",
 smalltalk.method({
-selector: "doIt:do:",
-fn: function (someCode,aReaction){
+selector: "doIt:",
+fn: function (someCode){
 var self=this;
-var result;
-result=smalltalk.send(smalltalk.send(self,"_environment",[]),"_eval_on_",[someCode,smalltalk.send(self,"_receiver",[])]);
-smalltalk.send(aReaction,"_value_",[result]);
-return result;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_environment",[]),"_eval_on_",[someCode,smalltalk.send(self,"_receiver",[])]);
+return $1;
 }
 }),
 smalltalk.HLCodeModel);
@@ -152,7 +151,7 @@ return $1;
 smalltalk.HLCodeModel.klass);
 
 
-smalltalk.addClass('HLCodeWidget', smalltalk.HLWidget, ['model', 'wrapper', 'code', 'editor', 'doItReaction'], 'Helios-Workspace');
+smalltalk.addClass('HLCodeWidget', smalltalk.HLWidget, ['model', 'wrapper', 'code', 'editor'], 'Helios-Workspace');
 smalltalk.addMethod(
 "_announcer",
 smalltalk.method({
@@ -215,41 +214,14 @@ selector: "doIt",
 fn: function (){
 var self=this;
 var result;
-result=smalltalk.send(self["@model"],"_doIt_do_",[smalltalk.send(self,"_currentLineOrSelection",[]),smalltalk.send(self,"_doItReaction",[])]);
 smalltalk.send(smalltalk.send(self,"_announcer",[]),"_announce_",[smalltalk.send((smalltalk.HLDoItRequested || HLDoItRequested),"_on_",[self["@model"]])]);
+result=smalltalk.send(self["@model"],"_doIt_",[smalltalk.send(self,"_currentLineOrSelection",[])]);
+smalltalk.send(smalltalk.send(self,"_announcer",[]),"_announce_",[smalltalk.send((smalltalk.HLDoItExecuted || HLDoItExecuted),"_on_",[self["@model"]])]);
 return result;
 }
 }),
 smalltalk.HLCodeWidget);
 
-smalltalk.addMethod(
-"_doItReaction",
-smalltalk.method({
-selector: "doItReaction",
-fn: function (){
-var self=this;
-var $1;
-if(($receiver = self["@doItReaction"]) == nil || $receiver == undefined){
-$1=smalltalk.send(self,"_initializeDoItReaction",[]);
-} else {
-$1=self["@doItReaction"];
-};
-return $1;
-}
-}),
-smalltalk.HLCodeWidget);
-
-smalltalk.addMethod(
-"_doItReaction_",
-smalltalk.method({
-selector: "doItReaction:",
-fn: function (aBlock){
-var self=this;
-self["@doItReaction"]=aBlock;
-return self}
-}),
-smalltalk.HLCodeWidget);
-
 smalltalk.addMethod(
 "_editor",
 smalltalk.method({
@@ -272,21 +244,6 @@ return self}
 }),
 smalltalk.HLCodeWidget);
 
-smalltalk.addMethod(
-"_initializeDoItReaction",
-smalltalk.method({
-selector: "initializeDoItReaction",
-fn: function (){
-var self=this;
-var $1;
-self["@doItReaction"]=(function(){
-});
-$1=self["@doItReaction"];
-return $1;
-}
-}),
-smalltalk.HLCodeWidget);
-
 smalltalk.addMethod(
 "_inspectIt",
 smalltalk.method({

+ 15 - 73
js/Helios-Workspace.js

@@ -23,20 +23,19 @@ referencedClasses: []
 smalltalk.HLCodeModel);
 
 smalltalk.addMethod(
-"_doIt_do_",
+"_doIt_",
 smalltalk.method({
-selector: "doIt:do:",
+selector: "doIt:",
 category: 'actions',
-fn: function (someCode,aReaction){
+fn: function (someCode){
 var self=this;
-var result;
-result=smalltalk.send(smalltalk.send(self,"_environment",[]),"_eval_on_",[someCode,smalltalk.send(self,"_receiver",[])]);
-smalltalk.send(aReaction,"_value_",[result]);
-return result;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_environment",[]),"_eval_on_",[someCode,smalltalk.send(self,"_receiver",[])]);
+return $1;
 },
-args: ["someCode", "aReaction"],
-source: "doIt: someCode do: aReaction\x0a\x0a\x09| result |\x0a    result := self environment eval: someCode on: self receiver.\x0a\x09aReaction value: result.\x0a    ^result",
-messageSends: ["eval:on:", "receiver", "environment", "value:"],
+args: ["someCode"],
+source: "doIt: someCode\x0a\x0a\x09^ self environment eval: someCode on: self receiver",
+messageSends: ["eval:on:", "receiver", "environment"],
 referencedClasses: []
 }),
 smalltalk.HLCodeModel);
@@ -207,7 +206,7 @@ referencedClasses: []
 smalltalk.HLCodeModel.klass);
 
 
-smalltalk.addClass('HLCodeWidget', smalltalk.HLWidget, ['model', 'wrapper', 'code', 'editor', 'doItReaction'], 'Helios-Workspace');
+smalltalk.addClass('HLCodeWidget', smalltalk.HLWidget, ['model', 'wrapper', 'code', 'editor'], 'Helios-Workspace');
 smalltalk.addMethod(
 "_announcer",
 smalltalk.method({
@@ -291,52 +290,15 @@ category: 'actions',
 fn: function (){
 var self=this;
 var result;
-result=smalltalk.send(self["@model"],"_doIt_do_",[smalltalk.send(self,"_currentLineOrSelection",[]),smalltalk.send(self,"_doItReaction",[])]);
 smalltalk.send(smalltalk.send(self,"_announcer",[]),"_announce_",[smalltalk.send((smalltalk.HLDoItRequested || HLDoItRequested),"_on_",[self["@model"]])]);
+result=smalltalk.send(self["@model"],"_doIt_",[smalltalk.send(self,"_currentLineOrSelection",[])]);
+smalltalk.send(smalltalk.send(self,"_announcer",[]),"_announce_",[smalltalk.send((smalltalk.HLDoItExecuted || HLDoItExecuted),"_on_",[self["@model"]])]);
 return result;
 },
 args: [],
-source: "doIt\x0a\x09| result |\x0a\x0a\x09result:=  model \x0a    \x09\x09\x09\x09doIt: self currentLineOrSelection \x0a        \x09\x09\x09do: self doItReaction.\x0a        \x0a\x09self announcer announce: (HLDoItRequested on: model).\x0a\x09^ result        ",
-messageSends: ["doIt:do:", "currentLineOrSelection", "doItReaction", "announce:", "on:", "announcer"],
-referencedClasses: ["HLDoItRequested"]
-}),
-smalltalk.HLCodeWidget);
-
-smalltalk.addMethod(
-"_doItReaction",
-smalltalk.method({
-selector: "doItReaction",
-category: 'accessing',
-fn: function (){
-var self=this;
-var $1;
-if(($receiver = self["@doItReaction"]) == nil || $receiver == undefined){
-$1=smalltalk.send(self,"_initializeDoItReaction",[]);
-} else {
-$1=self["@doItReaction"];
-};
-return $1;
-},
-args: [],
-source: "doItReaction\x0a\x0a\x09^ doItReaction ifNil:[self initializeDoItReaction]",
-messageSends: ["ifNil:", "initializeDoItReaction"],
-referencedClasses: []
-}),
-smalltalk.HLCodeWidget);
-
-smalltalk.addMethod(
-"_doItReaction_",
-smalltalk.method({
-selector: "doItReaction:",
-category: 'accessing',
-fn: function (aBlock){
-var self=this;
-self["@doItReaction"]=aBlock;
-return self},
-args: ["aBlock"],
-source: "doItReaction: aBlock\x0a\x0a\x09doItReaction := aBlock",
-messageSends: [],
-referencedClasses: []
+source: "doIt\x0a\x09| result |\x0a\x0a\x09self announcer announce: (HLDoItRequested on: model).\x0a\x0a\x09result:=  model doIt: self currentLineOrSelection.\x0a\x0a\x09self announcer announce: (HLDoItExecuted on: model).\x0a\x0a\x09^ result        ",
+messageSends: ["announce:", "on:", "announcer", "doIt:", "currentLineOrSelection"],
+referencedClasses: ["HLDoItRequested", "HLDoItExecuted"]
 }),
 smalltalk.HLCodeWidget);
 
@@ -372,26 +334,6 @@ referencedClasses: []
 }),
 smalltalk.HLCodeWidget);
 
-smalltalk.addMethod(
-"_initializeDoItReaction",
-smalltalk.method({
-selector: "initializeDoItReaction",
-category: 'initialization',
-fn: function (){
-var self=this;
-var $1;
-self["@doItReaction"]=(function(){
-});
-$1=self["@doItReaction"];
-return $1;
-},
-args: [],
-source: "initializeDoItReaction\x0a\x0a\x09^ doItReaction := [\x22no-op\x22]",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.HLCodeWidget);
-
 smalltalk.addMethod(
 "_inspectIt",
 smalltalk.method({

+ 4 - 0
st/Helios-Announcements.st

@@ -28,6 +28,10 @@ on: aCodeModel
         yourself
 ! !
 
+HLCodeHandled subclass: #HLDoItExecuted
+	instanceVariableNames: ''
+	package: 'Helios-Announcements'!
+
 HLCodeHandled subclass: #HLDoItRequested
 	instanceVariableNames: ''
 	package: 'Helios-Announcements'!

+ 17 - 6
st/Helios-Inspector.st

@@ -66,14 +66,19 @@ ensureModel
 
 inspect: anObject
 
-	self model inspect: anObject on: self
+	self model inspect: anObject on: self.
+    
+	self 
+    	refreshVariables;
+		refreshDisplay;
+        yourself
 !
 
 makeCode
 
 	^ HLCodeWidget new
     	model: model code;
-		doItReaction: [self refresh];
+        receiver: model inspectee;
         yourself.
 !
 
@@ -92,6 +97,10 @@ makeVariables
 !
 
 observeCode
+
+	self code announcer 
+    	on: HLDoItExecuted 
+        do: [self onDoneIt]
 !
 
 observeVariables
@@ -112,10 +121,7 @@ open
 
 refresh
 
-	self 
-		inspect: self inspectee; 
-		refreshVariables;
-		refreshDisplay
+	self inspect: self inspectee
 !
 
 refreshDisplay
@@ -166,6 +172,11 @@ initializeVariables
 onDoIt
 !
 
+onDoneIt
+
+	self refresh
+!
+
 onInspectIt
 !
 

+ 8 - 27
st/Helios-Workspace.st

@@ -27,12 +27,9 @@ receiver: anObject
 
 !HLCodeModel methodsFor: 'actions'!
 
-doIt: someCode do: aReaction
+doIt: someCode
 
-	| result |
-    result := self environment eval: someCode on: self receiver.
-	aReaction value: result.
-    ^result
+	^ self environment eval: someCode on: self receiver
 !
 
 subscribe: aWidget
@@ -63,7 +60,7 @@ on: anEnvironment
 ! !
 
 HLWidget subclass: #HLCodeWidget
-	instanceVariableNames: 'model wrapper code editor doItReaction'
+	instanceVariableNames: 'model wrapper code editor'
 	package: 'Helios-Workspace'!
 
 !HLCodeWidget methodsFor: 'accessing'!
@@ -82,16 +79,6 @@ currentLineOrSelection
 		ifTrue: [self selection]
 !
 
-doItReaction
-
-	^ doItReaction ifNil:[self initializeDoItReaction]
-!
-
-doItReaction: aBlock
-
-	doItReaction := aBlock
-!
-
 model
 
 	^ model
@@ -152,11 +139,12 @@ clear
 doIt
 	| result |
 
-	result:=  model 
-    				doIt: self currentLineOrSelection 
-        			do: self doItReaction.
-        
 	self announcer announce: (HLDoItRequested on: model).
+
+	result:=  model doIt: self currentLineOrSelection.
+
+	self announcer announce: (HLDoItExecuted on: model).
+
 	^ result
 !
 
@@ -226,13 +214,6 @@ setEditorOn: aTextarea
 	})>
 ! !
 
-!HLCodeWidget methodsFor: 'initialization'!
-
-initializeDoItReaction
-
-	^ doItReaction := ["no-op"]
-! !
-
 !HLCodeWidget methodsFor: 'reactions'!
 
 onDoIt