121
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCTool subclass:#MCCodeTool
|
|
4 |
instanceVariableNames:'items'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
615
|
7 |
category:'SCM-Monticello-UI'
|
121
|
8 |
!
|
|
9 |
|
|
10 |
MCCodeTool comment:'MCCodeTool is an abstract superclass for those Monticello browsers that display code.
|
|
11 |
It contains copies of the various CodeHolder methods that perform the various menu operations in the method list.
|
|
12 |
'
|
|
13 |
!
|
|
14 |
|
|
15 |
|
|
16 |
!MCCodeTool methodsFor:'menus'!
|
|
17 |
|
|
18 |
adoptMessageInCurrentChangeset
|
|
19 |
"Add the receiver's method to the current change set if not already there"
|
|
20 |
|
|
21 |
self selectedClassOrMetaClass ifNotNilDo: [ :cl |
|
|
22 |
self selectedMessageName ifNotNilDo: [ :sel |
|
|
23 |
ChangeSet current adoptSelector: sel forClass: cl.
|
|
24 |
self changed: #annotations ]]
|
|
25 |
!
|
|
26 |
|
|
27 |
browseFullProtocol
|
|
28 |
"Open up a protocol-category browser on the value of the receiver's current selection. If in mvc, an old-style protocol browser is opened instead. Someone who still uses mvc might wish to make the protocol-category-browser work there too, thanks."
|
|
29 |
|
|
30 |
| aClass |
|
|
31 |
|
|
32 |
(Smalltalk isMorphic and: [Smalltalk includesKey: #Lexicon]) ifFalse: [^ self spawnFullProtocol].
|
|
33 |
(aClass _ self selectedClassOrMetaClass) ifNotNil:
|
|
34 |
[(Smalltalk at: #Lexicon) new openOnClass: aClass inWorld: ActiveWorld showingSelector: self selectedMessageName]
|
|
35 |
!
|
|
36 |
|
|
37 |
browseMessages
|
|
38 |
"Present a menu of the currently selected message, as well as all messages sent by it. Open a message set browser of all implementors of the selector chosen."
|
|
39 |
|
|
40 |
self systemNavigation browseAllImplementorsOf: (self selectedMessageName ifNil: [ ^nil ])
|
|
41 |
!
|
|
42 |
|
|
43 |
browseMethodFull
|
|
44 |
"Create and schedule a full Browser and then select the current class and message."
|
|
45 |
|
|
46 |
| myClass |
|
|
47 |
(myClass _ self selectedClassOrMetaClass) ifNotNil:
|
|
48 |
[Browser fullOnClass: myClass selector: self selectedMessageName]
|
|
49 |
!
|
|
50 |
|
|
51 |
browseSendersOfMessages
|
|
52 |
"Present a menu of the currently selected message, as well as all messages sent by it. Open a message set browser of all senders of the selector chosen."
|
|
53 |
|
|
54 |
self systemNavigation browseAllCallsOn: (self selectedMessageName ifNil: [ ^nil ])
|
|
55 |
!
|
|
56 |
|
|
57 |
browseVersions
|
|
58 |
"Create and schedule a message set browser on all versions of the
|
|
59 |
currently selected message selector."
|
|
60 |
|
|
61 |
| class selector compiledMethod |
|
|
62 |
class _ self selectedClassOrMetaClass.
|
|
63 |
selector _ self selectedMessageName.
|
|
64 |
compiledMethod _ class compiledMethodAt: selector ifAbsent: [ ^self ].
|
|
65 |
VersionsBrowser
|
|
66 |
browseVersionsOf: compiledMethod
|
|
67 |
class: class theNonMetaClass
|
|
68 |
meta: class isMeta
|
|
69 |
category: self selectedMessageCategoryName
|
|
70 |
selector: selector
|
|
71 |
!
|
|
72 |
|
|
73 |
classHierarchy
|
|
74 |
"Create and schedule a class list browser on the receiver's hierarchy."
|
|
75 |
|
|
76 |
self systemNavigation spawnHierarchyForClass: self selectedClassOrMetaClass
|
|
77 |
selector: self selectedMessageName "OK if nil"
|
|
78 |
!
|
|
79 |
|
|
80 |
classListMenu: aMenu
|
|
81 |
|
|
82 |
aMenu addList: #(
|
|
83 |
-
|
|
84 |
('browse full (b)' browseMethodFull)
|
|
85 |
('browse hierarchy (h)' classHierarchy)
|
|
86 |
('browse protocol (p)' browseFullProtocol)
|
|
87 |
" -
|
|
88 |
('printOut' printOutClass)
|
|
89 |
('fileOut' fileOutClass)
|
|
90 |
" -
|
|
91 |
('show hierarchy' methodHierarchy)
|
|
92 |
" ('show definition' editClass)
|
|
93 |
('show comment' editComment)
|
|
94 |
"
|
|
95 |
" -
|
|
96 |
('inst var refs...' browseInstVarRefs)
|
|
97 |
('inst var defs...' browseInstVarDefs)
|
|
98 |
-
|
|
99 |
('class var refs...' browseClassVarRefs)
|
|
100 |
('class vars' browseClassVariables)
|
|
101 |
('class refs (N)' browseClassRefs)
|
|
102 |
-
|
|
103 |
('rename class ...' renameClass)
|
|
104 |
('copy class' copyClass)
|
|
105 |
('remove class (x)' removeClass)
|
|
106 |
"
|
|
107 |
-
|
|
108 |
('find method...' findMethodInChangeSets)).
|
|
109 |
|
|
110 |
^aMenu
|
|
111 |
!
|
|
112 |
|
|
113 |
copySelector
|
|
114 |
"Copy the selected selector to the clipboard"
|
|
115 |
|
|
116 |
| selector |
|
|
117 |
(selector _ self selectedMessageName) ifNotNil:
|
|
118 |
[Clipboard clipboardText: selector asString]
|
|
119 |
!
|
|
120 |
|
|
121 |
fileOutMessage
|
|
122 |
"Put a description of the selected message on a file"
|
|
123 |
|
|
124 |
self selectedMessageName ifNotNil:
|
|
125 |
[Cursor write showWhile:
|
|
126 |
[self selectedClassOrMetaClass fileOutMethod: self selectedMessageName]]
|
|
127 |
!
|
|
128 |
|
|
129 |
findMethodInChangeSets
|
|
130 |
"Find and open a changeSet containing the current method."
|
|
131 |
|
|
132 |
| aName |
|
|
133 |
(aName _ self selectedMessageName) ifNotNil: [
|
|
134 |
ChangeSorter browseChangeSetsWithClass: self selectedClassOrMetaClass
|
|
135 |
selector: aName]
|
|
136 |
!
|
|
137 |
|
|
138 |
methodHierarchy
|
|
139 |
"Create and schedule a method browser on the hierarchy of implementors."
|
|
140 |
|
|
141 |
self systemNavigation methodHierarchyBrowserForClass: self selectedClassOrMetaClass
|
|
142 |
selector: self selectedMessageName
|
|
143 |
!
|
|
144 |
|
|
145 |
methodListKey: aKeystroke from: aListMorph
|
|
146 |
aKeystroke caseOf: {
|
|
147 |
[$b] -> [self browseMethodFull].
|
|
148 |
[$h] -> [self classHierarchy].
|
|
149 |
[$O] -> [self openSingleMessageBrowser].
|
|
150 |
[$p] -> [self browseFullProtocol].
|
|
151 |
[$o] -> [self fileOutMessage].
|
|
152 |
[$c] -> [self copySelector].
|
|
153 |
[$n] -> [self browseSendersOfMessages].
|
|
154 |
[$m] -> [self browseMessages].
|
|
155 |
[$i] -> [self methodHierarchy].
|
|
156 |
[$v] -> [self browseVersions]}
|
|
157 |
otherwise: []
|
|
158 |
!
|
|
159 |
|
|
160 |
methodListMenu: aMenu
|
|
161 |
"Build the menu for the selected method, if any."
|
|
162 |
|
|
163 |
self selectedMessageName ifNotNil: [
|
|
164 |
aMenu addList:#(
|
|
165 |
('browse full (b)' browseMethodFull)
|
|
166 |
('browse hierarchy (h)' classHierarchy)
|
|
167 |
('browse method (O)' openSingleMessageBrowser)
|
|
168 |
('browse protocol (p)' browseFullProtocol)
|
|
169 |
-
|
|
170 |
('fileOut (o)' fileOutMessage)
|
|
171 |
('printOut' printOutMessage)
|
|
172 |
('copy selector (c)' copySelector)).
|
|
173 |
aMenu addList: #(
|
|
174 |
-
|
|
175 |
('browse senders (n)' browseSendersOfMessages)
|
|
176 |
('browse implementors (m)' browseMessages)
|
|
177 |
('inheritance (i)' methodHierarchy)
|
|
178 |
('versions (v)' browseVersions)
|
|
179 |
('change sets with this method' findMethodInChangeSets)
|
|
180 |
" ('x revert to previous version' revertToPreviousVersion)"
|
|
181 |
('remove from current change set' removeFromCurrentChanges)
|
|
182 |
" ('x revert & remove from changes' revertAndForget)"
|
|
183 |
('add to current change set' adoptMessageInCurrentChangeset)
|
|
184 |
" ('x copy up or copy down...' copyUpOrCopyDown)"
|
|
185 |
" ('x remove method (x)' removeMessage)"
|
|
186 |
"-"
|
|
187 |
).
|
|
188 |
].
|
|
189 |
" aMenu addList: #(
|
|
190 |
('x inst var refs...' browseInstVarRefs)
|
|
191 |
('x inst var defs...' browseInstVarDefs)
|
|
192 |
('x class var refs...' browseClassVarRefs)
|
|
193 |
('x class variables' browseClassVariables)
|
|
194 |
('x class refs (N)' browseClassRefs)
|
|
195 |
).
|
|
196 |
"
|
|
197 |
^ aMenu
|
|
198 |
!
|
|
199 |
|
|
200 |
openSingleMessageBrowser
|
|
201 |
| msgName mr |
|
|
202 |
"Create and schedule a message list browser populated only by the currently selected message"
|
|
203 |
|
|
204 |
(msgName _ self selectedMessageName) ifNil: [^ self].
|
|
205 |
|
|
206 |
mr _ MethodReference new
|
|
207 |
setStandardClass: self selectedClassOrMetaClass
|
|
208 |
methodSymbol: msgName.
|
|
209 |
|
|
210 |
self systemNavigation
|
|
211 |
browseMessageList: (Array with: mr)
|
|
212 |
name: mr asStringOrText
|
|
213 |
autoSelect: nil
|
|
214 |
!
|
|
215 |
|
|
216 |
perform: selector orSendTo: otherTarget
|
|
217 |
|
|
218 |
"Selector was just chosen from a menu by a user. If can respond, then
|
|
219 |
perform it on myself. If not, send it to otherTarget, presumably the
|
|
220 |
editPane from which the menu was invoked."
|
|
221 |
|
|
222 |
(self respondsTo: selector)
|
|
223 |
ifTrue: [^ self perform: selector]
|
|
224 |
ifFalse: [^ super perform: selector orSendTo: otherTarget]
|
|
225 |
!
|
|
226 |
|
|
227 |
printOutMessage
|
|
228 |
"Write a file with the text of the selected message, for printing by a web browser"
|
|
229 |
|
|
230 |
self selectedMessageName ifNotNil: [
|
|
231 |
self selectedClassOrMetaClass fileOutMethod: self selectedMessageName
|
|
232 |
asHtml: true]
|
|
233 |
!
|
|
234 |
|
|
235 |
removeFromCurrentChanges
|
|
236 |
"Tell the changes mgr to forget that the current msg was changed."
|
|
237 |
|
|
238 |
ChangeSet current removeSelectorChanges: self selectedMessageName
|
|
239 |
class: self selectedClassOrMetaClass.
|
|
240 |
self changed: #annotations
|
|
241 |
! !
|
|
242 |
|
|
243 |
!MCCodeTool methodsFor:'subclassResponsibility'!
|
|
244 |
|
|
245 |
annotations
|
|
246 |
"Build an annotations string for the various browsers"
|
|
247 |
^''
|
|
248 |
!
|
|
249 |
|
|
250 |
selectedClass
|
|
251 |
"Answer the class that is selected, or nil"
|
|
252 |
self subclassResponsibility
|
|
253 |
!
|
|
254 |
|
|
255 |
selectedClassOrMetaClass
|
|
256 |
"Answer the class that is selected, or nil"
|
|
257 |
self subclassResponsibility
|
|
258 |
!
|
|
259 |
|
|
260 |
selectedMessageCategoryName
|
|
261 |
"Answer the method category of the method that is selected, or nil"
|
|
262 |
self subclassResponsibility
|
|
263 |
!
|
|
264 |
|
|
265 |
selectedMessageName
|
|
266 |
"Answer the name of the selected message"
|
|
267 |
self subclassResponsibility
|
|
268 |
! !
|
|
269 |
|
|
270 |
!MCCodeTool class methodsFor:'documentation'!
|
|
271 |
|
|
272 |
version
|
615
|
273 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCCodeTool.st,v 1.2 2012-09-11 21:20:58 cg Exp $'
|
121
|
274 |
! !
|