Browse Source

Use Behavior >> definition, extract selClsOrMetaCls.

Herbert Vojčík 7 years ago
parent
commit
6b0093d669
2 changed files with 92 additions and 301 deletions
  1. 76 249
      src/IDE.js
  2. 16 52
      src/IDE.st

+ 76 - 249
src/IDE.js

@@ -3004,112 +3004,6 @@ messageSends: ["comment"]
 }),
 $globals.Browser);
 
-$core.addMethod(
-$core.method({
-selector: "classDeclarationSource",
-protocol: 'accessing',
-fn: function (){
-var self=this;
-var stream;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1,$2,$4,$5,$3,$6,$7,$8,$receiver;
-stream=""._writeStream();
-$1=self["@selectedClass"];
-if(($receiver = $1) == null || $receiver.isNil){
-return self._classDeclarationTemplate();
-} else {
-$1;
-}
-$2=stream;
-$recv($2)._nextPutAll_($recv($recv(self["@selectedClass"])._superclass())._asString());
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=1;
-//>>excludeEnd("ctx");
-$recv($2)._nextPutAll_(" subclass: #");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=2;
-//>>excludeEnd("ctx");
-$recv($2)._nextPutAll_($recv(self["@selectedClass"])._name());
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=3;
-//>>excludeEnd("ctx");
-$4=$recv($globals.String)._lf();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["lf"]=1;
-//>>excludeEnd("ctx");
-$5=$recv($globals.String)._tab();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["tab"]=1;
-//>>excludeEnd("ctx");
-$3=$recv($4).__comma($5);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx[","]=1;
-//>>excludeEnd("ctx");
-$recv($2)._nextPutAll_($3);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=4;
-//>>excludeEnd("ctx");
-$6=$recv($2)._nextPutAll_("instanceVariableNames: '");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=5;
-//>>excludeEnd("ctx");
-$recv($recv(self["@selectedClass"])._instanceVariableNames())._do_separatedBy_((function(each){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-return $recv(stream)._nextPutAll_(each);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["nextPutAll:"]=6;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
-//>>excludeEnd("ctx");
-}),(function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-return $recv(stream)._nextPutAll_(" ");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["nextPutAll:"]=7;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
-//>>excludeEnd("ctx");
-}));
-$7=stream;
-$8=$recv("'".__comma($recv($globals.String)._lf())).__comma($recv($globals.String)._tab());
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx[","]=2;
-//>>excludeEnd("ctx");
-$recv($7)._nextPutAll_($8);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=8;
-//>>excludeEnd("ctx");
-$recv($7)._nextPutAll_("package: '");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=9;
-//>>excludeEnd("ctx");
-$recv($7)._nextPutAll_($recv(self["@selectedClass"])._category());
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=10;
-//>>excludeEnd("ctx");
-$recv($7)._nextPutAll_("'");
-return $recv(stream)._contents();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"classDeclarationSource",{stream:stream},$globals.Browser)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "classDeclarationSource\x0a\x09| stream |\x0a\x09stream := '' writeStream.\x0a\x09selectedClass ifNil: [ ^ self classDeclarationTemplate ].\x0a\x09stream\x0a\x09\x09nextPutAll: selectedClass superclass asString;\x0a\x09\x09nextPutAll: ' subclass: #';\x0a\x09\x09nextPutAll: selectedClass name;\x0a\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09nextPutAll: 'instanceVariableNames: '''.\x0a\x09selectedClass instanceVariableNames\x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ' ' ].\x0a\x09stream\x0a\x09\x09nextPutAll: '''', String lf, String tab;\x0a\x09\x09nextPutAll: 'package: ''';\x0a\x09\x09nextPutAll: selectedClass category;\x0a\x09\x09nextPutAll: ''''.\x0a\x09^ stream contents",
-referencedClasses: ["String"],
-//>>excludeEnd("ide");
-messageSends: ["writeStream", "ifNil:", "classDeclarationTemplate", "nextPutAll:", "asString", "superclass", "name", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "contents"]
-}),
-$globals.Browser);
-
 $core.addMethod(
 $core.method({
 selector: "classDeclarationTemplate",
@@ -3334,16 +3228,7 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1;
-$1=$recv(self["@selectedTab"]).__eq("instance");
-if($core.assert($1)){
-self._compileMethodDefinitionFor_(self["@selectedClass"]);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["compileMethodDefinitionFor:"]=1;
-//>>excludeEnd("ctx");
-} else {
-self._compileMethodDefinitionFor_($recv(self["@selectedClass"])._class());
-}
+self._compileMethodDefinitionFor_(self._selectedClassOrMetaClass());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"compileMethodDefinition",{},$globals.Browser)});
@@ -3351,10 +3236,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "compileMethodDefinition\x0a\x09selectedTab = #instance\x0a\x09ifTrue: [ self compileMethodDefinitionFor: selectedClass ]\x0a\x09ifFalse: [ self compileMethodDefinitionFor: selectedClass class ]",
+source: "compileMethodDefinition\x0a\x09self compileMethodDefinitionFor: self selectedClassOrMetaClass",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "=", "compileMethodDefinitionFor:", "class"]
+messageSends: ["compileMethodDefinitionFor:", "selectedClassOrMetaClass"]
 }),
 $globals.Browser);
 
@@ -3490,26 +3375,33 @@ selector: "declarationSource",
 protocol: 'accessing',
 fn: function (){
 var self=this;
+var klass;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1;
-$1=$recv(self["@selectedTab"]).__eq("instance");
-if($core.assert($1)){
-return self._classDeclarationSource();
+var $1,$2,$receiver;
+klass=self._selectedClassOrMetaClass();
+$1=klass;
+if(($receiver = $1) == null || $receiver.isNil){
+$2=$recv(self["@selectedTab"]).__eq("instance");
+if($core.assert($2)){
+return self._classDeclarationTemplate();
 } else {
-return self._metaclassDeclarationSource();
+return "";
+}
+} else {
+return $recv(klass)._definition();
 }
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"declarationSource",{},$globals.Browser)});
+}, function($ctx1) {$ctx1.fill(self,"declarationSource",{klass:klass},$globals.Browser)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "declarationSource\x0a\x09^ selectedTab = #instance\x0a\x09ifTrue: [ self classDeclarationSource ]\x0a\x09ifFalse: [ self metaclassDeclarationSource ]",
+source: "declarationSource\x0a\x09| klass |\x0a\x09klass := self selectedClassOrMetaClass.\x0a\x09^ klass ifNotNil: [ klass definition ] ifNil: [\x0a\x09\x09selectedTab = #instance ifTrue: [ self classDeclarationTemplate ] ifFalse: [ '' ] \x0a\x09]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "=", "classDeclarationSource", "metaclassDeclarationSource"]
+messageSends: ["selectedClassOrMetaClass", "ifNotNil:ifNil:", "definition", "ifTrue:ifFalse:", "=", "classDeclarationTemplate"]
 }),
 $globals.Browser);
 
@@ -3704,75 +3596,6 @@ messageSends: ["ifNil:ifNotNil:", ",", "name"]
 }),
 $globals.Browser);
 
-$core.addMethod(
-$core.method({
-selector: "metaclassDeclarationSource",
-protocol: 'accessing',
-fn: function (){
-var self=this;
-var stream;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1,$2,$3,$receiver;
-stream=""._writeStream();
-$1=self["@selectedClass"];
-if(($receiver = $1) == null || $receiver.isNil){
-$1;
-} else {
-$2=stream;
-$recv($2)._nextPutAll_($recv(self["@selectedClass"])._asString());
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=1;
-//>>excludeEnd("ctx");
-$recv($2)._nextPutAll_(" class ");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=2;
-//>>excludeEnd("ctx");
-$3=$recv($2)._nextPutAll_("instanceVariableNames: '");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["nextPutAll:"]=3;
-//>>excludeEnd("ctx");
-$3;
-$recv($recv($recv(self["@selectedClass"])._class())._instanceVariableNames())._do_separatedBy_((function(each){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-return $recv(stream)._nextPutAll_(each);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["nextPutAll:"]=4;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
-//>>excludeEnd("ctx");
-}),(function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-return $recv(stream)._nextPutAll_(" ");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["nextPutAll:"]=5;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
-//>>excludeEnd("ctx");
-}));
-$recv(stream)._nextPutAll_("'");
-}
-return $recv(stream)._contents();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"metaclassDeclarationSource",{stream:stream},$globals.Browser)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "metaclassDeclarationSource\x0a\x09| stream |\x0a\x09stream := '' writeStream.\x0a\x09selectedClass ifNotNil: [\x0a\x09stream\x0a\x09\x09nextPutAll: selectedClass asString;\x0a\x09\x09nextPutAll: ' class ';\x0a\x09\x09nextPutAll: 'instanceVariableNames: '''.\x0a\x09selectedClass class instanceVariableNames\x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ' ' ].\x0a\x09stream nextPutAll: '''' ].\x0a\x09^ stream contents",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["writeStream", "ifNotNil:", "nextPutAll:", "asString", "do:separatedBy:", "instanceVariableNames", "class", "contents"]
-}),
-$globals.Browser);
-
 $core.addMethod(
 $core.method({
 selector: "methodSource",
@@ -3812,48 +3635,34 @@ var klass;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$3,$5,$6,$4,$7,$receiver;
+var $1,$3,$4,$2,$5,$receiver;
 $1=$recv(self["@selectedTab"]).__eq("comment");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["="]=1;
-//>>excludeEnd("ctx");
 if($core.assert($1)){
 return [];
 }
-$2=self["@selectedClass"];
-if(($receiver = $2) == null || $receiver.isNil){
-$2;
-} else {
-$3=$recv(self["@selectedTab"]).__eq("instance");
-if($core.assert($3)){
-klass=self["@selectedClass"];
-} else {
-klass=$recv(self["@selectedClass"])._class();
-}
-klass;
-}
-$5=self["@selectedProtocol"];
-if(($receiver = $5) == null || $receiver.isNil){
-$6=klass;
-if(($receiver = $6) == null || $receiver.isNil){
-$4=[];
+klass=self._selectedClassOrMetaClass();
+$3=self["@selectedProtocol"];
+if(($receiver = $3) == null || $receiver.isNil){
+$4=klass;
+if(($receiver = $4) == null || $receiver.isNil){
+$2=[];
 } else {
-$4=$recv($recv(klass)._methodDictionary())._values();
+$2=$recv($recv(klass)._methodDictionary())._values();
 }
 } else {
-$4=$recv(klass)._methodsInProtocol_(self["@selectedProtocol"]);
+$2=$recv(klass)._methodsInProtocol_(self["@selectedProtocol"]);
 }
-return $recv($4)._sort_((function(a,b){
+return $recv($2)._sort_((function(a,b){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-$7=$recv(a)._selector();
+$5=$recv(a)._selector();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx2.sendIdx["selector"]=1;
 //>>excludeEnd("ctx");
-return $recv($7).__lt($recv(b)._selector());
+return $recv($5).__lt($recv(b)._selector());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,9)});
+}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,6)});
 //>>excludeEnd("ctx");
 }));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -3862,10 +3671,10 @@ return $recv($7).__lt($recv(b)._selector());
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "methods\x0a\x09| klass |\x0a\x09selectedTab = #comment ifTrue: [ ^ #() ].\x0a\x09selectedClass ifNotNil: [\x0a\x09klass := selectedTab = #instance\x0a\x09\x09ifTrue: [ selectedClass ]\x0a\x09\x09ifFalse: [ selectedClass class ]].\x0a\x09^ (selectedProtocol\x0a\x09ifNil: [\x0a\x09\x09klass\x0a\x09\x09ifNil: [ #() ]\x0a\x09\x09ifNotNil: [ klass methodDictionary values ]]\x0a\x09ifNotNil: [\x0a\x09\x09klass methodsInProtocol: selectedProtocol ]) \x0a\x09\x09\x09\x09sort: [ :a :b | a selector < b selector ]",
+source: "methods\x0a\x09| klass |\x0a\x09selectedTab = #comment ifTrue: [ ^ #() ].\x0a\x09klass := self selectedClassOrMetaClass.\x0a\x09^ (selectedProtocol\x0a\x09ifNil: [\x0a\x09\x09klass\x0a\x09\x09ifNil: [ #() ]\x0a\x09\x09ifNotNil: [ klass methodDictionary values ]]\x0a\x09ifNotNil: [\x0a\x09\x09klass methodsInProtocol: selectedProtocol ]) \x0a\x09\x09\x09\x09sort: [ :a :b | a selector < b selector ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:", "=", "ifNotNil:", "ifTrue:ifFalse:", "class", "sort:", "ifNil:ifNotNil:", "values", "methodDictionary", "methodsInProtocol:", "<", "selector"]
+messageSends: ["ifTrue:", "=", "selectedClassOrMetaClass", "sort:", "ifNil:ifNotNil:", "values", "methodDictionary", "methodsInProtocol:", "<", "selector"]
 }),
 $globals.Browser);
 
@@ -3922,7 +3731,7 @@ var klass;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$3,$receiver;
+var $1,$2,$receiver;
 var $early={};
 try {
 $1=self["@selectedClass"];
@@ -3930,18 +3739,10 @@ if(($receiver = $1) == null || $receiver.isNil){
 $1;
 } else {
 $2=$recv(self["@selectedTab"]).__eq("comment");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["="]=1;
-//>>excludeEnd("ctx");
 if($core.assert($2)){
 return [];
 }
-$3=$recv(self["@selectedTab"]).__eq("instance");
-if($core.assert($3)){
-klass=self["@selectedClass"];
-} else {
-klass=$recv(self["@selectedClass"])._class();
-}
+klass=self._selectedClassOrMetaClass();
 klass;
 $recv($recv(klass)._methodDictionary())._ifEmpty_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -3949,7 +3750,7 @@ 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)});
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
 //>>excludeEnd("ctx");
 }));
 return $recv(klass)._protocols();
@@ -3963,10 +3764,10 @@ catch(e) {if(e===$early)return e[0]; throw e}
 },
 //>>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 ifEmpty: [\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 := self selectedClassOrMetaClass.\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", "ifEmpty:", "methodDictionary", "with:", "protocols", "new"]
+messageSends: ["ifNotNil:", "ifTrue:", "=", "selectedClassOrMetaClass", "ifEmpty:", "methodDictionary", "with:", "protocols", "new"]
 }),
 $globals.Browser);
 
@@ -4013,7 +3814,7 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$3,$2,$4;
+var $1,$3,$2;
 $1=self._cancelChanges();
 if($core.assert($1)){
 $3=$recv("Do you really want to remove #".__comma($recv(self["@selectedMethod"])._selector())).__comma("?");
@@ -4022,15 +3823,7 @@ $ctx1.sendIdx[","]=1;
 //>>excludeEnd("ctx");
 $2=$recv($globals.Terminal)._confirm_($3);
 if($core.assert($2)){
-$4=$recv(self["@selectedTab"]).__eq("instance");
-if($core.assert($4)){
-$recv(self["@selectedClass"])._removeCompiledMethod_(self["@selectedMethod"]);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["removeCompiledMethod:"]=1;
-//>>excludeEnd("ctx");
-} else {
-$recv($recv(self["@selectedClass"])._class())._removeCompiledMethod_(self["@selectedMethod"]);
-}
+$recv(self._selectedClassOrMetaClass())._removeCompiledMethod_(self["@selectedMethod"]);
 self._selectMethod_(nil);
 }
 }
@@ -4041,10 +3834,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "removeMethod\x0a\x09self cancelChanges ifTrue: [\x0a\x09(Terminal confirm: 'Do you really want to remove #', selectedMethod selector, '?')\x0a\x09\x09ifTrue: [\x0a\x09\x09selectedTab = #instance\x0a\x09\x09\x09ifTrue: [ selectedClass removeCompiledMethod: selectedMethod ]\x0a\x09\x09\x09ifFalse: [ selectedClass class removeCompiledMethod: selectedMethod ].\x0a\x09\x09self selectMethod: nil ]]",
+source: "removeMethod\x0a\x09self cancelChanges ifTrue: [\x0a\x09(Terminal confirm: 'Do you really want to remove #', selectedMethod selector, '?')\x0a\x09\x09ifTrue: [\x0a\x09\x09self selectedClassOrMetaClass removeCompiledMethod: selectedMethod.\x0a\x09\x09self selectMethod: nil ]]",
 referencedClasses: ["Terminal"],
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:", "cancelChanges", "confirm:", ",", "selector", "ifTrue:ifFalse:", "=", "removeCompiledMethod:", "class", "selectMethod:"]
+messageSends: ["ifTrue:", "cancelChanges", "confirm:", ",", "selector", "removeCompiledMethod:", "selectedClassOrMetaClass", "selectMethod:"]
 }),
 $globals.Browser);
 
@@ -4839,6 +4632,40 @@ messageSends: []
 }),
 $globals.Browser);
 
+$core.addMethod(
+$core.method({
+selector: "selectedClassOrMetaClass",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2,$receiver;
+$1=self["@selectedClass"];
+if(($receiver = $1) == null || $receiver.isNil){
+return $1;
+} else {
+$2=$recv(self["@selectedTab"]).__eq("instance");
+if($core.assert($2)){
+return self["@selectedClass"];
+} else {
+return $recv(self["@selectedClass"])._theMetaClass();
+}
+}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"selectedClassOrMetaClass",{},$globals.Browser)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "selectedClassOrMetaClass\x0a\x09^ selectedClass ifNotNil: [\x0a\x09\x09selectedTab = #instance\x0a\x09\x09\x09ifTrue: [ selectedClass ]\x0a\x09\x09\x09ifFalse: [ selectedClass theMetaClass ] ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifNotNil:", "ifTrue:ifFalse:", "=", "theMetaClass"]
+}),
+$globals.Browser);
+
 $core.addMethod(
 $core.method({
 selector: "selectedPackage",

+ 16 - 52
src/IDE.st

@@ -648,27 +648,6 @@ classCommentSource
 	^ selectedClass comment
 !
 
-classDeclarationSource
-	| stream |
-	stream := '' writeStream.
-	selectedClass ifNil: [ ^ self classDeclarationTemplate ].
-	stream
-		nextPutAll: selectedClass superclass asString;
-		nextPutAll: ' subclass: #';
-		nextPutAll: selectedClass name;
-		nextPutAll: String lf, String tab;
-		nextPutAll: 'instanceVariableNames: '''.
-	selectedClass instanceVariableNames
-		do: [ :each | stream nextPutAll: each ]
-		separatedBy: [ stream nextPutAll: ' ' ].
-	stream
-		nextPutAll: '''', String lf, String tab;
-		nextPutAll: 'package: ''';
-		nextPutAll: selectedClass category;
-		nextPutAll: ''''.
-	^ stream contents
-!
-
 classDeclarationTemplate
 	^ 'Object subclass: #NameOfSubclass
 	instanceVariableNames: ''''
@@ -682,9 +661,11 @@ classes
 !
 
 declarationSource
-	^ selectedTab = #instance
-	ifTrue: [ self classDeclarationSource ]
-	ifFalse: [ self metaclassDeclarationSource ]
+	| klass |
+	klass := self selectedClassOrMetaClass.
+	^ klass ifNotNil: [ klass definition ] ifNil: [
+		selectedTab = #instance ifTrue: [ self classDeclarationTemplate ] ifFalse: [ '' ] 
+	]
 !
 
 dummyMethodSource
@@ -701,21 +682,6 @@ label
 	ifNotNil: [ 'Browser: ', selectedClass name ]
 !
 
-metaclassDeclarationSource
-	| stream |
-	stream := '' writeStream.
-	selectedClass ifNotNil: [
-	stream
-		nextPutAll: selectedClass asString;
-		nextPutAll: ' class ';
-		nextPutAll: 'instanceVariableNames: '''.
-	selectedClass class instanceVariableNames
-		do: [ :each | stream nextPutAll: each ]
-		separatedBy: [ stream nextPutAll: ' ' ].
-	stream nextPutAll: '''' ].
-	^ stream contents
-!
-
 methodSource
 	^ selectedMethod
 	ifNil: [ self dummyMethodSource ]
@@ -725,10 +691,7 @@ methodSource
 methods
 	| klass |
 	selectedTab = #comment ifTrue: [ ^ #() ].
-	selectedClass ifNotNil: [
-	klass := selectedTab = #instance
-		ifTrue: [ selectedClass ]
-		ifFalse: [ selectedClass class ]].
+	klass := self selectedClassOrMetaClass.
 	^ (selectedProtocol
 	ifNil: [
 		klass
@@ -752,9 +715,7 @@ protocols
 	| klass |
 	selectedClass ifNotNil: [
 	selectedTab = #comment ifTrue: [ ^ #() ].
-	klass := selectedTab = #instance
-		ifTrue: [ selectedClass ]
-		ifFalse: [ selectedClass class ].
+	klass := self selectedClassOrMetaClass.
 	klass methodDictionary ifEmpty: [
 		^ Array with: 'not yet classified' ].
 	^ klass protocols ].
@@ -765,6 +726,13 @@ selectedClass
 	^ selectedClass
 !
 
+selectedClassOrMetaClass
+	^ selectedClass ifNotNil: [
+		selectedTab = #instance
+			ifTrue: [ selectedClass ]
+			ifFalse: [ selectedClass theMetaClass ] ]
+!
+
 selectedPackage
 	^ selectedPackage
 !
@@ -851,9 +819,7 @@ compileDefinition
 !
 
 compileMethodDefinition
-	selectedTab = #instance
-	ifTrue: [ self compileMethodDefinitionFor: selectedClass ]
-	ifFalse: [ self compileMethodDefinitionFor: selectedClass class ]
+	self compileMethodDefinitionFor: self selectedClassOrMetaClass
 !
 
 compileMethodDefinitionFor: aClass
@@ -927,9 +893,7 @@ removeMethod
 	self cancelChanges ifTrue: [
 	(Terminal confirm: 'Do you really want to remove #', selectedMethod selector, '?')
 		ifTrue: [
-		selectedTab = #instance
-			ifTrue: [ selectedClass removeCompiledMethod: selectedMethod ]
-			ifFalse: [ selectedClass class removeCompiledMethod: selectedMethod ].
+		self selectedClassOrMetaClass removeCompiledMethod: selectedMethod.
 		self selectMethod: nil ]]
 !