Explorar el Código

Use ifEmpty:ifNotEmpty: family.

Herbert Vojčík hace 8 años
padre
commit
4f436f9bbd
Se han modificado 2 ficheros con 85 adiciones y 67 borrados
  1. 80 59
      src/IDE.js
  2. 5 8
      src/IDE.st

+ 80 - 59
src/IDE.js

@@ -473,7 +473,7 @@ var li,cssClass;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$4,$5,$3,$6;
+var $1,$2,$4,$5,$3;
 cssClass="";
 li=$recv($recv(html)._li())._onClick_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -506,11 +506,16 @@ $ctx1.sendIdx[","]=1;
 //>>excludeEnd("ctx");
 cssClass;
 };
-$6=$recv($recv(self._theClass())._comment())._isEmpty();
-if(!$core.assert($6)){
+$recv($recv(self._theClass())._comment())._ifNotEmpty_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
 cssClass=$recv(cssClass).__comma(" commented");
-cssClass;
-};
+return cssClass;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
+//>>excludeEnd("ctx");
+}));
 $recv(li)._class_(cssClass);
 $recv(self._nodes())._do_((function(each){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -528,10 +533,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["html"],
-source: "renderOn: html\x0a\x09| li cssClass |\x0a\x09cssClass := ''.\x0a\x09li := html li\x0a\x09\x09onClick: [ self browser selectClass: self theClass ].\x0a\x09li asJQuery html: self label.\x0a\x0a\x09self browser selectedClass = self theClass ifTrue: [\x0a\x09\x09cssClass := cssClass, ' selected' ].\x0a\x0a\x09self theClass comment isEmpty ifFalse: [\x0a\x09\x09cssClass := cssClass, ' commented' ].\x0a\x0a\x09li class: cssClass.\x0a\x0a\x09self nodes do: [ :each |\x0a\x09\x09each renderOn: html ]",
+source: "renderOn: html\x0a\x09| li cssClass |\x0a\x09cssClass := ''.\x0a\x09li := html li\x0a\x09\x09onClick: [ self browser selectClass: self theClass ].\x0a\x09li asJQuery html: self label.\x0a\x0a\x09self browser selectedClass = self theClass ifTrue: [\x0a\x09\x09cssClass := cssClass, ' selected' ].\x0a\x0a\x09self theClass comment ifNotEmpty: [\x0a\x09\x09cssClass := cssClass, ' commented' ].\x0a\x0a\x09li class: cssClass.\x0a\x0a\x09self nodes do: [ :each |\x0a\x09\x09each renderOn: html ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["onClick:", "li", "selectClass:", "browser", "theClass", "html:", "asJQuery", "label", "ifTrue:", "=", "selectedClass", ",", "ifFalse:", "isEmpty", "comment", "class:", "do:", "nodes", "renderOn:"]
+messageSends: ["onClick:", "li", "selectClass:", "browser", "theClass", "html:", "asJQuery", "label", "ifTrue:", "=", "selectedClass", ",", "ifNotEmpty:", "comment", "class:", "do:", "nodes", "renderOn:"]
 }),
 $globals.ClassesListNode);
 
@@ -3917,7 +3922,9 @@ var klass;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$3,$4,$receiver;
+var $1,$2,$3,$receiver;
+var $early={};
+try {
 $1=self["@selectedClass"];
 if(($receiver = $1) == null || $receiver.isNil){
 $1;
@@ -3936,23 +3943,30 @@ klass=self["@selectedClass"];
 klass=$recv(self["@selectedClass"])._class();
 };
 klass;
-$4=$recv($recv(klass)._methodDictionary())._isEmpty();
-if($core.assert($4)){
-return $recv($globals.Array)._with_("not yet classified");
-};
+$recv($recv(klass)._methodDictionary())._ifEmpty_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+throw $early=[$recv($globals.Array)._with_("not yet classified")];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)});
+//>>excludeEnd("ctx");
+}));
 return $recv(klass)._protocols();
 };
 return $recv($globals.Array)._new();
+}
+catch(e) {if(e===$early)return e[0]; throw e}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"protocols",{klass:klass},$globals.Browser)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "protocols\x0a\x09| klass |\x0a\x09selectedClass ifNotNil: [\x0a\x09selectedTab = #comment ifTrue: [ ^ #() ].\x0a\x09klass := selectedTab = #instance\x0a\x09\x09ifTrue: [ selectedClass ]\x0a\x09\x09ifFalse: [ selectedClass class ].\x0a\x09klass methodDictionary isEmpty ifTrue: [\x0a\x09\x09^ Array with: 'not yet classified' ].\x0a\x09^ klass protocols ].\x0a\x09^ Array new",
+source: "protocols\x0a\x09| klass |\x0a\x09selectedClass ifNotNil: [\x0a\x09selectedTab = #comment ifTrue: [ ^ #() ].\x0a\x09klass := selectedTab = #instance\x0a\x09\x09ifTrue: [ selectedClass ]\x0a\x09\x09ifFalse: [ selectedClass class ].\x0a\x09klass methodDictionary ifEmpty: [\x0a\x09\x09^ Array with: 'not yet classified' ].\x0a\x09^ klass protocols ].\x0a\x09^ Array new",
 referencedClasses: ["Array"],
 //>>excludeEnd("ide");
-messageSends: ["ifNotNil:", "ifTrue:", "=", "ifTrue:ifFalse:", "class", "isEmpty", "methodDictionary", "with:", "protocols", "new"]
+messageSends: ["ifNotNil:", "ifTrue:", "=", "ifTrue:ifFalse:", "class", "ifEmpty:", "methodDictionary", "with:", "protocols", "new"]
 }),
 $globals.Browser);
 
@@ -4117,17 +4131,22 @@ var newName;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$receiver;
+var $1,$receiver;
 newName=$recv($globals.Terminal)._prompt_("Rename package ".__comma(self["@selectedPackage"]));
 $1=newName;
 if(($receiver = $1) == null || $receiver.isNil){
 $1;
 } else {
-$2=$recv(newName)._notEmpty();
-if($core.assert($2)){
+$recv(newName)._ifNotEmpty_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
 $recv($globals.Smalltalk)._renamePackage_to_(self["@selectedPackage"],newName);
-self._updateCategoriesList();
-};
+return self._updateCategoriesList();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
+//>>excludeEnd("ctx");
+}));
 };
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -4136,10 +4155,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "renamePackage\x0a\x0a\x09| newName |\x0a\x09newName := Terminal prompt: 'Rename package ', selectedPackage.\x0a\x09newName ifNotNil: [\x0a\x09newName notEmpty ifTrue: [\x0a\x09Smalltalk renamePackage: selectedPackage to: newName.\x0a\x09self updateCategoriesList ]]",
+source: "renamePackage\x0a\x0a\x09| newName |\x0a\x09newName := Terminal prompt: 'Rename package ', selectedPackage.\x0a\x09newName ifNotNil: [ newName ifNotEmpty: [\x0a\x09Smalltalk renamePackage: selectedPackage to: newName.\x0a\x09self updateCategoriesList ]]",
 referencedClasses: ["Terminal", "Smalltalk"],
 //>>excludeEnd("ide");
-messageSends: ["prompt:", ",", "ifNotNil:", "ifTrue:", "notEmpty", "renamePackage:to:", "updateCategoriesList"]
+messageSends: ["prompt:", ",", "ifNotNil:", "ifNotEmpty:", "renamePackage:to:", "updateCategoriesList"]
 }),
 $globals.Browser);
 
@@ -4997,7 +5016,7 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$3;
+var $1,$2;
 $recv(self["@packagesList"])._contents_((function(html){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
@@ -5007,29 +5026,26 @@ var li,label;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
-$1=$recv(each)._isEmpty();
-if($core.assert($1)){
-label="Unclassified";
-label;
-} else {
-label=each;
+label=$recv(each)._ifEmpty_((function(){
+return "Unclassified";
+
+}));
 label;
-};
 li=$recv(html)._li();
 li;
-$2=$recv(self["@selectedPackage"]).__eq(each);
-if($core.assert($2)){
+$1=$recv(self["@selectedPackage"]).__eq(each);
+if($core.assert($1)){
 $recv(li)._class_("selected");
 };
-$3=li;
-$recv($3)._with_(label);
-return $recv($3)._onClick_((function(){
+$2=li;
+$recv($2)._with_(label);
+return $recv($2)._onClick_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx4) {
 //>>excludeEnd("ctx");
 return self._selectCategory_(each);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)});
+}, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)});
 //>>excludeEnd("ctx");
 }));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -5047,10 +5063,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "updateCategoriesList\x0a\x09packagesList contents: [ :html |\x0a\x09self packages do: [ :each || li label |\x0a\x09\x09each isEmpty\x0a\x09\x09ifTrue: [ label := 'Unclassified' ]\x0a\x09\x09ifFalse: [ label := each ].\x0a\x09\x09li := html li.\x0a\x09\x09selectedPackage = each ifTrue: [\x0a\x09\x09li class: 'selected' ].\x0a\x09\x09li\x0a\x09\x09with: label;\x0a\x09\x09onClick: [ self selectCategory: each ]] ]",
+source: "updateCategoriesList\x0a\x09packagesList contents: [ :html |\x0a\x09self packages do: [ :each || li label |\x0a\x09\x09label := each ifEmpty: [ 'Unclassified' ].\x0a\x09\x09li := html li.\x0a\x09\x09selectedPackage = each ifTrue: [\x0a\x09\x09li class: 'selected' ].\x0a\x09\x09li\x0a\x09\x09with: label;\x0a\x09\x09onClick: [ self selectCategory: each ]] ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["contents:", "do:", "packages", "ifTrue:ifFalse:", "isEmpty", "li", "ifTrue:", "=", "class:", "with:", "onClick:", "selectCategory:"]
+messageSends: ["contents:", "do:", "packages", "ifEmpty:", "li", "ifTrue:", "=", "class:", "with:", "onClick:", "selectCategory:"]
 }),
 $globals.Browser);
 
@@ -10202,39 +10218,44 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$3,$4,$5;
+var $1,$2,$3,$4;
 $recv(self["@classesList"])._contents_((function(html){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-$1=$recv(self._selectedCategories())._isEmpty();
-if(!$core.assert($1)){
-$2=$recv(html)._li();
+$recv(self._selectedCategories())._ifNotEmpty_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["li"]=1;
+return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
-$recv($2)._class_("all");
+$1=$recv(html)._li();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["class:"]=1;
+$ctx3.sendIdx["li"]=1;
 //>>excludeEnd("ctx");
-$recv($2)._with_("All");
+$recv($1)._class_("all");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["with:"]=1;
+$ctx3.sendIdx["class:"]=1;
+//>>excludeEnd("ctx");
+$recv($1)._with_("All");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["with:"]=1;
 //>>excludeEnd("ctx");
-$3=$recv($2)._onClick_((function(){
+$2=$recv($1)._onClick_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx3) {
+return $core.withContext(function($ctx4) {
 //>>excludeEnd("ctx");
 return self._selectAllClasses();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
+}, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
 //>>excludeEnd("ctx");
 }));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["onClick:"]=1;
+$ctx3.sendIdx["onClick:"]=1;
 //>>excludeEnd("ctx");
-$3;
-};
+return $2;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
+//>>excludeEnd("ctx");
+}));
 return $recv(self._classes())._do_((function(each){
 var li;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -10242,13 +10263,13 @@ return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
 li=$recv(html)._li();
 li;
-$4=$recv(self._selectedClasses())._includes_(each);
-if($core.assert($4)){
+$3=$recv(self._selectedClasses())._includes_(each);
+if($core.assert($3)){
 $recv(li)._class_("selected");
 };
-$5=li;
-$recv($5)._with_($recv(each)._name());
-return $recv($5)._onClick_((function(){
+$4=li;
+$recv($4)._with_($recv(each)._name());
+return $recv($4)._onClick_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx4) {
 //>>excludeEnd("ctx");
@@ -10272,10 +10293,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "updateClassesList\x0a\x09classesList contents: [ :html |\x0a\x09(self selectedCategories isEmpty) ifFalse: [\x0a\x09\x09html li\x0a\x09\x09\x09class: 'all';\x0a\x09\x09\x09with: 'All';\x0a\x09\x09\x09onClick: [ self selectAllClasses ]].\x0a\x09self classes do: [ :each || li |\x0a\x09\x09li := html li.\x0a\x09\x09(self selectedClasses includes: each) ifTrue: [\x0a\x09\x09\x09li class: 'selected' ].\x0a\x09\x09li\x0a\x09\x09\x09with: each name;\x0a\x09\x09\x09onClick: [ self toggleClass: each ]] ]",
+source: "updateClassesList\x0a\x09classesList contents: [ :html |\x0a\x09self selectedCategories ifNotEmpty: [\x0a\x09\x09html li\x0a\x09\x09\x09class: 'all';\x0a\x09\x09\x09with: 'All';\x0a\x09\x09\x09onClick: [ self selectAllClasses ]].\x0a\x09self classes do: [ :each || li |\x0a\x09\x09li := html li.\x0a\x09\x09(self selectedClasses includes: each) ifTrue: [\x0a\x09\x09\x09li class: 'selected' ].\x0a\x09\x09li\x0a\x09\x09\x09with: each name;\x0a\x09\x09\x09onClick: [ self toggleClass: each ]] ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["contents:", "ifFalse:", "isEmpty", "selectedCategories", "class:", "li", "with:", "onClick:", "selectAllClasses", "do:", "classes", "ifTrue:", "includes:", "selectedClasses", "name", "toggleClass:"]
+messageSends: ["contents:", "ifNotEmpty:", "selectedCategories", "class:", "li", "with:", "onClick:", "selectAllClasses", "do:", "classes", "ifTrue:", "includes:", "selectedClasses", "name", "toggleClass:"]
 }),
 $globals.TestRunner);
 

+ 5 - 8
src/IDE.st

@@ -130,7 +130,7 @@ renderOn: html
 	self browser selectedClass = self theClass ifTrue: [
 		cssClass := cssClass, ' selected' ].
 
-	self theClass comment isEmpty ifFalse: [
+	self theClass comment ifNotEmpty: [
 		cssClass := cssClass, ' commented' ].
 
 	li class: cssClass.
@@ -755,7 +755,7 @@ protocols
 	klass := selectedTab = #instance
 		ifTrue: [ selectedClass ]
 		ifFalse: [ selectedClass class ].
-	klass methodDictionary isEmpty ifTrue: [
+	klass methodDictionary ifEmpty: [
 		^ Array with: 'not yet classified' ].
 	^ klass protocols ].
 	^ Array new
@@ -955,8 +955,7 @@ renamePackage
 
 	| newName |
 	newName := Terminal prompt: 'Rename package ', selectedPackage.
-	newName ifNotNil: [
-	newName notEmpty ifTrue: [
+	newName ifNotNil: [ newName ifNotEmpty: [
 	Smalltalk renamePackage: selectedPackage to: newName.
 	self updateCategoriesList ]]
 !
@@ -1149,9 +1148,7 @@ resetClassesList
 updateCategoriesList
 	packagesList contents: [ :html |
 	self packages do: [ :each || li label |
-		each isEmpty
-		ifTrue: [ label := 'Unclassified' ]
-		ifFalse: [ label := each ].
+		label := each ifEmpty: [ 'Unclassified' ].
 		li := html li.
 		selectedPackage = each ifTrue: [
 		li class: 'selected' ].
@@ -2217,7 +2214,7 @@ updateCategoriesList
 
 updateClassesList
 	classesList contents: [ :html |
-	(self selectedCategories isEmpty) ifFalse: [
+	self selectedCategories ifNotEmpty: [
 		html li
 			class: 'all';
 			with: 'All';