瀏覽代碼

Helios references browser changes:

- adds Find Class command
- adds Browse method command
Nicolas Petton 10 年之前
父節點
當前提交
d3964723a1
共有 8 個文件被更改,包括 262 次插入13 次删除
  1. 42 0
      js/Helios-Browser.js
  2. 86 7
      js/Helios-Commands-Tools.js
  3. 9 4
      js/Helios-Core.js
  4. 54 0
      js/Helios-References.js
  5. 13 0
      st/Helios-Browser.st
  6. 33 1
      st/Helios-Commands-Tools.st
  7. 7 1
      st/Helios-Core.st
  8. 18 0
      st/Helios-References.st

+ 42 - 0
js/Helios-Browser.js

@@ -147,6 +147,48 @@ referencedClasses: []
 }),
 globals.HLBrowser);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "openClassNamed:",
+protocol: 'actions',
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(self._model())._openClassNamed_(aString);
+return self}, function($ctx1) {$ctx1.fill(self,"openClassNamed:",{aString:aString},globals.HLBrowser)})},
+args: ["aString"],
+source: "openClassNamed: aString\x0a\x09self model openClassNamed: aString",
+messageSends: ["openClassNamed:", "model"],
+referencedClasses: []
+}),
+globals.HLBrowser);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "openMethod:",
+protocol: 'actions',
+fn: function (aCompiledMethod){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2,$4,$3,$5;
+$1=self._model();
+$2=$1;
+$4=_st(aCompiledMethod)._methodClass();
+$ctx1.sendIdx["methodClass"]=1;
+$3=_st($4)._package();
+_st($2)._selectedPackage_($3);
+_st($1)._selectedClass_(_st(aCompiledMethod)._methodClass());
+_st($1)._selectedProtocol_(_st(aCompiledMethod)._protocol());
+_st($1)._selectedMethod_(aCompiledMethod);
+$5=_st($1)._focusOnSourceCode();
+return self}, function($ctx1) {$ctx1.fill(self,"openMethod:",{aCompiledMethod:aCompiledMethod},globals.HLBrowser)})},
+args: ["aCompiledMethod"],
+source: "openMethod: aCompiledMethod\x0a\x09self model \x0a\x09\x09\x09selectedPackage: aCompiledMethod methodClass package;\x0a\x09\x09\x09selectedClass: aCompiledMethod methodClass;\x0a\x09\x09\x09selectedProtocol: aCompiledMethod protocol;\x0a\x09\x09\x09selectedMethod: aCompiledMethod;\x0a\x09\x09\x09focusOnSourceCode",
+messageSends: ["selectedPackage:", "model", "package", "methodClass", "selectedClass:", "selectedProtocol:", "protocol", "selectedMethod:", "focusOnSourceCode"],
+referencedClasses: []
+}),
+globals.HLBrowser);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "packagesListWidget",

+ 86 - 7
js/Helios-Commands-Tools.js

@@ -59,6 +59,88 @@ referencedClasses: []
 globals.HLToolCommand.klass);
 
 
+smalltalk.addClass('HLBrowseMethodCommand', globals.HLToolCommand, [], 'Helios-Commands-Tools');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "displayLabel",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "browse method";
+},
+args: [],
+source: "displayLabel\x0a\x09^ 'browse method'",
+messageSends: [],
+referencedClasses: []
+}),
+globals.HLBrowseMethodCommand);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "execute",
+protocol: 'executing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(self._model())._openMethod();
+return self}, function($ctx1) {$ctx1.fill(self,"execute",{},globals.HLBrowseMethodCommand)})},
+args: [],
+source: "execute\x0a\x09self model openMethod",
+messageSends: ["openMethod", "model"],
+referencedClasses: []
+}),
+globals.HLBrowseMethodCommand);
+
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "isValidFor:",
+protocol: 'testing',
+fn: function (aModel){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(aModel)._isReferencesModel();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"isValidFor:",{aModel:aModel},globals.HLBrowseMethodCommand.klass)})},
+args: ["aModel"],
+source: "isValidFor: aModel\x0a\x09^ aModel isReferencesModel",
+messageSends: ["isReferencesModel"],
+referencedClasses: []
+}),
+globals.HLBrowseMethodCommand.klass);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "key",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "b";
+},
+args: [],
+source: "key\x0a\x09^ 'b'",
+messageSends: [],
+referencedClasses: []
+}),
+globals.HLBrowseMethodCommand.klass);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "label",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "browse method";
+},
+args: [],
+source: "label\x0a\x09^ 'browse method'",
+messageSends: [],
+referencedClasses: []
+}),
+globals.HLBrowseMethodCommand.klass);
+
+
 smalltalk.addClass('HLCommitPackageCommand', globals.HLToolCommand, [], 'Helios-Commands-Tools');
 smalltalk.addMethod(
 smalltalk.method({
@@ -436,14 +518,11 @@ selector: "isValidFor:",
 protocol: 'testing',
 fn: function (aModel){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(aModel)._isBrowserModel();
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"isValidFor:",{aModel:aModel},globals.HLFindClassCommand.klass)})},
+return true;
+},
 args: ["aModel"],
-source: "isValidFor: aModel\x0a\x09^ aModel isBrowserModel",
-messageSends: ["isBrowserModel"],
+source: "isValidFor: aModel\x0a\x09^ true",
+messageSends: [],
 referencedClasses: []
 }),
 globals.HLFindClassCommand.klass);

+ 9 - 4
js/Helios-Core.js

@@ -1881,14 +1881,19 @@ selector: "openAsTab",
 protocol: 'accessing',
 fn: function (){
 var self=this;
+var instance;
 function $HLManager(){return globals.HLManager||(typeof HLManager=="undefined"?nil:HLManager)}
 function $HLTabWidget(){return globals.HLTabWidget||(typeof HLTabWidget=="undefined"?nil:HLTabWidget)}
 return smalltalk.withContext(function($ctx1) { 
-_st(_st($HLManager())._current())._addTab_(_st($HLTabWidget())._on_labelled_(self._new(),self._tabLabel()));
-return self}, function($ctx1) {$ctx1.fill(self,"openAsTab",{},globals.HLWidget.klass)})},
+var $1;
+instance=self._new();
+_st(_st($HLManager())._current())._addTab_(_st($HLTabWidget())._on_labelled_(instance,self._tabLabel()));
+$1=instance;
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"openAsTab",{instance:instance},globals.HLWidget.klass)})},
 args: [],
-source: "openAsTab\x0a\x09HLManager current addTab: (HLTabWidget on: self new labelled: self tabLabel)",
-messageSends: ["addTab:", "current", "on:labelled:", "new", "tabLabel"],
+source: "openAsTab\x0a\x09| instance |\x0a\x09\x0a\x09instance := self new.\x0a\x09HLManager current addTab: (HLTabWidget \x0a\x09\x09on: instance \x0a\x09\x09labelled: self tabLabel).\x0a\x09^ instance",
+messageSends: ["new", "addTab:", "current", "on:labelled:", "tabLabel"],
 referencedClasses: ["HLManager", "HLTabWidget"]
 }),
 globals.HLWidget.klass);

+ 54 - 0
js/Helios-References.js

@@ -944,6 +944,60 @@ referencedClasses: []
 }),
 globals.HLReferencesModel);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "openClassNamed:",
+protocol: 'actions',
+fn: function (aString){
+var self=this;
+var browser;
+function $HLBrowser(){return globals.HLBrowser||(typeof HLBrowser=="undefined"?nil:HLBrowser)}
+return smalltalk.withContext(function($ctx1) { 
+self._withChangesDo_((function(){
+return smalltalk.withContext(function($ctx2) {
+browser=_st($HLBrowser())._openAsTab();
+browser;
+return _st(browser)._openClassNamed_(aString);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"openClassNamed:",{aString:aString,browser:browser},globals.HLReferencesModel)})},
+args: ["aString"],
+source: "openClassNamed: aString\x0a\x09| browser |\x0a\x09\x0a\x09self withChangesDo: [\x0a\x09\x09browser := HLBrowser openAsTab.\x0a\x09\x09browser openClassNamed: aString ]",
+messageSends: ["withChangesDo:", "openAsTab", "openClassNamed:"],
+referencedClasses: ["HLBrowser"]
+}),
+globals.HLReferencesModel);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "openMethod",
+protocol: 'actions',
+fn: function (){
+var self=this;
+var browser;
+function $HLBrowser(){return globals.HLBrowser||(typeof HLBrowser=="undefined"?nil:HLBrowser)}
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self._selectedMethod();
+$ctx1.sendIdx["selectedMethod"]=1;
+if(($receiver = $1) == nil || $receiver == null){
+return self;
+} else {
+$1;
+};
+self._withChangesDo_((function(){
+return smalltalk.withContext(function($ctx2) {
+browser=_st($HLBrowser())._openAsTab();
+browser;
+return _st(browser)._openMethod_(self._selectedMethod());
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"openMethod",{browser:browser},globals.HLReferencesModel)})},
+args: [],
+source: "openMethod\x0a\x09| browser |\x0a\x09\x0a\x09self selectedMethod ifNil: [ ^ self ].\x0a\x09\x0a\x09self withChangesDo: [\x0a\x09\x09browser := HLBrowser openAsTab.\x0a\x09\x09browser openMethod: self selectedMethod ]",
+messageSends: ["ifNil:", "selectedMethod", "withChangesDo:", "openAsTab", "openMethod:"],
+referencedClasses: ["HLBrowser"]
+}),
+globals.HLReferencesModel);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "regexpReferencesOf:",

+ 13 - 0
st/Helios-Browser.st

@@ -25,6 +25,19 @@ focus
 	^ self packagesListWidget focus
 !
 
+openClassNamed: aString
+	self model openClassNamed: aString
+!
+
+openMethod: aCompiledMethod
+	self model 
+			selectedPackage: aCompiledMethod methodClass package;
+			selectedClass: aCompiledMethod methodClass;
+			selectedProtocol: aCompiledMethod protocol;
+			selectedMethod: aCompiledMethod;
+			focusOnSourceCode
+!
+
 unregister
 	super unregister.
 

+ 33 - 1
st/Helios-Commands-Tools.st

@@ -23,6 +23,38 @@ isValidFor: aModel
 	^ aModel isToolModel
 ! !
 
+HLToolCommand subclass: #HLBrowseMethodCommand
+	instanceVariableNames: ''
+	package: 'Helios-Commands-Tools'!
+
+!HLBrowseMethodCommand methodsFor: 'accessing'!
+
+displayLabel
+	^ 'browse method'
+! !
+
+!HLBrowseMethodCommand methodsFor: 'executing'!
+
+execute
+	self model openMethod
+! !
+
+!HLBrowseMethodCommand class methodsFor: 'accessing'!
+
+key
+	^ 'b'
+!
+
+label
+	^ 'browse method'
+! !
+
+!HLBrowseMethodCommand class methodsFor: 'testing'!
+
+isValidFor: aModel
+	^ aModel isReferencesModel
+! !
+
 HLToolCommand subclass: #HLCommitPackageCommand
 	instanceVariableNames: ''
 	package: 'Helios-Commands-Tools'!
@@ -177,7 +209,7 @@ label
 !HLFindClassCommand class methodsFor: 'testing'!
 
 isValidFor: aModel
-	^ aModel isBrowserModel
+	^ true
 ! !
 
 HLFindCommand subclass: #HLFindReferencesCommand

+ 7 - 1
st/Helios-Core.st

@@ -657,7 +657,13 @@ refresh
 !HLWidget class methodsFor: 'accessing'!
 
 openAsTab
-	HLManager current addTab: (HLTabWidget on: self new labelled: self tabLabel)
+	| instance |
+	
+	instance := self new.
+	HLManager current addTab: (HLTabWidget 
+		on: instance 
+		labelled: self tabLabel).
+	^ instance
 !
 
 tabClass

+ 18 - 0
st/Helios-References.st

@@ -319,6 +319,24 @@ sendersOf: aString
 
 !HLReferencesModel methodsFor: 'actions'!
 
+openClassNamed: aString
+	| browser |
+	
+	self withChangesDo: [
+		browser := HLBrowser openAsTab.
+		browser openClassNamed: aString ]
+!
+
+openMethod
+	| browser |
+	
+	self selectedMethod ifNil: [ ^ self ].
+	
+	self withChangesDo: [
+		browser := HLBrowser openAsTab.
+		browser openMethod: self selectedMethod ]
+!
+
 search: aString
 	self updateCaches.