10023
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
8775
|
13 |
|
|
14 |
"{ NameSpace: Tools }"
|
|
15 |
|
|
16 |
CodeView subclass:#NewSystemBrowserCodeView
|
|
17 |
instanceVariableNames:'browser parseTree selectedNode parsingProcess
|
|
18 |
parsingProcessRunning highlightEmphasis seqNum'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Browsers-New'
|
|
22 |
!
|
|
23 |
|
10023
|
24 |
!NewSystemBrowserCodeView class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
! !
|
8775
|
39 |
|
|
40 |
!NewSystemBrowserCodeView class methodsFor:'initialization'!
|
|
41 |
|
|
42 |
initialize
|
|
43 |
"
|
|
44 |
self initialize
|
|
45 |
"
|
10024
|
46 |
"/ MUST be done in the keyboard.rc file
|
10023
|
47 |
"
|
|
48 |
Smalltalk addStartBlock:
|
|
49 |
[Display keyboardMap
|
|
50 |
bindValue:#ImplementorsOfIt to:#Cmdm;
|
|
51 |
bindValue:#SendersOfIt to:#Cmdn;
|
|
52 |
bindValue:#GoBack to:#CmdBackSpace]
|
|
53 |
"
|
8775
|
54 |
|
|
55 |
"Created: / 25-12-2007 / 19:58:53 / janfrog"
|
|
56 |
"Modified: / 27-02-2008 / 12:16:10 / janfrog"
|
10023
|
57 |
"Modified: / 15-04-2010 / 16:40:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10024
|
58 |
"Modified (comment): / 01-07-2011 / 16:21:38 / cg"
|
8775
|
59 |
! !
|
|
60 |
|
|
61 |
!NewSystemBrowserCodeView class methodsFor:'menu specs'!
|
|
62 |
|
|
63 |
editMenuSpec
|
|
64 |
"This resource specification was automatically generated
|
|
65 |
by the MenuEditor of ST/X."
|
|
66 |
|
|
67 |
"Do not manually edit this!! If it is corrupted,
|
|
68 |
the MenuEditor may not be able to read the specification."
|
|
69 |
|
|
70 |
"
|
|
71 |
MenuEditor new openOnClass:Tools::NewSystemBrowserCodeView andSelector:#editMenuSpec
|
|
72 |
(Menu new fromLiteralArrayEncoding:(Tools::NewSystemBrowserCodeView editMenuSpec)) startUp
|
|
73 |
"
|
|
74 |
|
|
75 |
<resource: #menu>
|
|
76 |
|
|
77 |
^
|
|
78 |
#(Menu
|
|
79 |
(
|
|
80 |
(MenuItem
|
|
81 |
label: 'Implementors'
|
|
82 |
itemValue: browseImplementorsOfIt
|
|
83 |
translateLabel: true
|
|
84 |
shortcutKey: ImplementorsOfIt
|
|
85 |
)
|
|
86 |
(MenuItem
|
|
87 |
label: 'Senders'
|
|
88 |
itemValue: browseSendersOfIt
|
|
89 |
translateLabel: true
|
|
90 |
shortcutKey: SendersOfIt
|
|
91 |
)
|
|
92 |
(MenuItem
|
|
93 |
label: 'Refactor'
|
|
94 |
translateLabel: true
|
|
95 |
isVisible: false
|
|
96 |
shortcutKey: Shift
|
|
97 |
)
|
|
98 |
(MenuItem
|
|
99 |
label: '-'
|
|
100 |
)
|
|
101 |
(MenuItem
|
|
102 |
label: 'Accept'
|
|
103 |
itemValue: accept
|
|
104 |
translateLabel: true
|
|
105 |
shortcutKey: Accept
|
|
106 |
)
|
|
107 |
(MenuItem
|
|
108 |
label: '-'
|
|
109 |
)
|
|
110 |
(MenuItem
|
|
111 |
label: 'Cut'
|
|
112 |
itemValue: cut
|
|
113 |
translateLabel: true
|
|
114 |
shortcutKey: Cut
|
|
115 |
)
|
|
116 |
(MenuItem
|
|
117 |
label: 'Copy'
|
|
118 |
itemValue: copySelection
|
|
119 |
translateLabel: true
|
|
120 |
shortcutKey: Copy
|
|
121 |
)
|
|
122 |
(MenuItem
|
|
123 |
label: 'Paste'
|
|
124 |
itemValue: pasteOrReplace
|
|
125 |
translateLabel: true
|
|
126 |
shortcutKey: Paste
|
|
127 |
)
|
|
128 |
(MenuItem
|
|
129 |
label: '-'
|
|
130 |
)
|
|
131 |
(MenuItem
|
|
132 |
label: 'Undo'
|
|
133 |
itemValue: undo
|
|
134 |
translateLabel: true
|
|
135 |
shortcutKey: Undo
|
|
136 |
)
|
|
137 |
(MenuItem
|
|
138 |
label: '-'
|
|
139 |
)
|
|
140 |
(MenuItem
|
|
141 |
label: 'Do it'
|
|
142 |
itemValue: doIt
|
|
143 |
translateLabel: true
|
|
144 |
shortcutKey: DoIt
|
|
145 |
)
|
|
146 |
(MenuItem
|
|
147 |
label: 'Print it'
|
|
148 |
itemValue: printIt
|
|
149 |
translateLabel: true
|
|
150 |
shortcutKey: PrintIt
|
|
151 |
)
|
|
152 |
(MenuItem
|
|
153 |
label: 'Inspect it'
|
|
154 |
itemValue: inspectIt
|
|
155 |
translateLabel: true
|
|
156 |
shortcutKey: InspectIt
|
|
157 |
)
|
|
158 |
(MenuItem
|
|
159 |
label: '-'
|
|
160 |
)
|
|
161 |
(MenuItem
|
|
162 |
label: 'Special'
|
|
163 |
translateLabel: true
|
|
164 |
submenu:
|
|
165 |
(Menu
|
|
166 |
(
|
|
167 |
(MenuItem
|
|
168 |
label: 'Inspect RB Parse Tree'
|
|
169 |
itemValue: inspectParseTree
|
|
170 |
translateLabel: true
|
|
171 |
)
|
|
172 |
(MenuItem
|
|
173 |
label: 'Inspect selected selector'
|
|
174 |
itemValue: inspectSelectedSelector
|
|
175 |
translateLabel: true
|
|
176 |
)
|
|
177 |
)
|
|
178 |
nil
|
|
179 |
nil
|
|
180 |
)
|
|
181 |
)
|
|
182 |
(MenuItem
|
|
183 |
label: 'More'
|
|
184 |
nameKey: More
|
|
185 |
translateLabel: true
|
|
186 |
)
|
|
187 |
)
|
|
188 |
nil
|
|
189 |
nil
|
|
190 |
)
|
|
191 |
|
|
192 |
"Modified: / 18-10-2008 / 18:50:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
193 |
! !
|
|
194 |
|
|
195 |
!NewSystemBrowserCodeView methodsFor:'accessing'!
|
|
196 |
|
|
197 |
browser
|
|
198 |
^ browser ? menuHolder
|
|
199 |
|
|
200 |
"Created: / 25-12-2007 / 10:20:01 / janfrog"
|
|
201 |
"Modified: / 26-12-2007 / 12:22:56 / janfrog"
|
|
202 |
!
|
|
203 |
|
|
204 |
browser:something
|
|
205 |
browser := something.
|
|
206 |
|
|
207 |
"Created: / 25-12-2007 / 10:20:01 / janfrog"
|
|
208 |
!
|
|
209 |
|
|
210 |
findNode
|
|
211 |
|
|
212 |
^selectedNode
|
|
213 |
ifNil:[self findNodeForInterval: self selectedInterval]
|
|
214 |
ifNotNil:[selectedNode]
|
|
215 |
|
|
216 |
"Created: / 18-02-2008 / 22:52:24 / janfrog"
|
|
217 |
"Modified: / 19-02-2008 / 09:35:11 / janfrog"
|
|
218 |
!
|
|
219 |
|
|
220 |
findNodeForInterval:anInterval
|
|
221 |
|
|
222 |
"
|
|
223 |
An empty interval check based on Claus suggestion
|
|
224 |
(email Fri, 10 Oct 2008 16:10:25 +0200)
|
|
225 |
"
|
10023
|
226 |
anInterval isEmpty ifTrue:[^nil].
|
8775
|
227 |
|
|
228 |
^self findNodeIn: self parseTree forInterval: anInterval
|
|
229 |
|
|
230 |
"Created: / 19-02-2008 / 09:44:50 / janfrog"
|
|
231 |
"Modified: / 18-10-2008 / 16:47:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
10023
|
232 |
"Modified: / 01-09-2009 / 22:45:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
8775
|
233 |
!
|
|
234 |
|
|
235 |
findNodeIn:tree forInterval:interval
|
|
236 |
|node wouldReturn|
|
|
237 |
|
|
238 |
node := nil.
|
|
239 |
tree = #error ifTrue:[^nil].
|
|
240 |
tree nodesDo:[:each |
|
|
241 |
(each intersectsInterval:interval) ifTrue:[
|
|
242 |
(node isNil or:[node == each parent]) ifTrue:[
|
|
243 |
node := each
|
|
244 |
] ifFalse:[
|
|
245 |
(node parent notNil
|
|
246 |
and:[node parent isCascade and:[each parent isCascade]]) ifFalse:[^ nil]
|
|
247 |
]
|
|
248 |
] ifFalse:[
|
|
249 |
node notNil ifTrue:[
|
|
250 |
"/ already found one - beyond that one; leave
|
|
251 |
wouldReturn notNil ifTrue:[wouldReturn := node].
|
|
252 |
]
|
|
253 |
].
|
|
254 |
].
|
|
255 |
(wouldReturn notNil and:[wouldReturn ~~ node]) ifTrue:[self halt].
|
|
256 |
^ node
|
|
257 |
|
|
258 |
"Created: / 19-02-2008 / 09:40:24 / janfrog"
|
|
259 |
"Modified: / 21-02-2008 / 09:35:31 / janfrog"
|
|
260 |
!
|
|
261 |
|
|
262 |
selectedClass
|
|
263 |
|
|
264 |
^self browser theSingleSelectedClass
|
|
265 |
|
|
266 |
"Created: / 21-02-2008 / 09:26:55 / janfrog"
|
|
267 |
!
|
|
268 |
|
|
269 |
selectedNode
|
|
270 |
^ self findNode
|
|
271 |
|
|
272 |
"Created: / 21-02-2008 / 09:17:29 / janfrog"
|
|
273 |
!
|
|
274 |
|
|
275 |
selectedSelector
|
|
276 |
|selectedText|
|
|
277 |
|
|
278 |
^ (selectedText := self selectionAsString) isNilOrEmptyCollection
|
10023
|
279 |
ifFalse:[ (SystemBrowser extractSelectorFrom:selectedText) asSymbol ]
|
8775
|
280 |
ifTrue:[
|
|
281 |
selectedNode ifNil:[ self highlightNodeAtCursor ].
|
|
282 |
(selectedNode notNil and:[ selectedNode isMessage ]) ifTrue:[
|
|
283 |
selectedNode selector
|
|
284 |
] ifFalse:[ nil ]
|
|
285 |
]
|
|
286 |
|
|
287 |
"Created: / 26-12-2007 / 11:12:26 / janfrog"
|
|
288 |
"Modified: / 19-02-2008 / 09:16:11 / janfrog"
|
|
289 |
! !
|
|
290 |
|
|
291 |
!NewSystemBrowserCodeView methodsFor:'accessing-contents'!
|
|
292 |
|
|
293 |
list: anObject
|
|
294 |
|
|
295 |
super list: anObject.
|
|
296 |
self updateParseTree.
|
|
297 |
|
|
298 |
"Created: / 25-12-2007 / 10:05:17 / janfrog"
|
|
299 |
! !
|
|
300 |
|
|
301 |
!NewSystemBrowserCodeView methodsFor:'change & update'!
|
|
302 |
|
|
303 |
updateParseTree
|
|
304 |
|
|
305 |
self startParsingProcess
|
|
306 |
"/Transcript showCR:'Updating parse tree'
|
|
307 |
|
|
308 |
"Created: / 25-12-2007 / 10:05:49 / janfrog"
|
|
309 |
"Modified: / 25-12-2007 / 21:29:28 / janfrog"
|
|
310 |
! !
|
|
311 |
|
|
312 |
!NewSystemBrowserCodeView methodsFor:'event handling'!
|
|
313 |
|
|
314 |
buttonMotion:button x:x y:y
|
8874
|
315 |
(button == 0 and:[ self sensor ctrlDown ])
|
8775
|
316 |
ifTrue:[
|
8874
|
317 |
^ self
|
8775
|
318 |
highlightNodeAtX:x y:y;
|
|
319 |
redraw
|
|
320 |
]
|
|
321 |
ifFalse:[
|
8874
|
322 |
^ super
|
8775
|
323 |
buttonMotion:button
|
|
324 |
x:x
|
|
325 |
y:y
|
|
326 |
]
|
|
327 |
|
|
328 |
"Created: / 25-12-2007 / 21:53:50 / janfrog"
|
|
329 |
"Modified: / 19-02-2008 / 09:15:09 / janfrog"
|
|
330 |
!
|
|
331 |
|
10023
|
332 |
buttonPress: button x: x y: y
|
|
333 |
| node |
|
8775
|
334 |
|
10023
|
335 |
(self sensor ctrlDown and: [ (node := self selectedNode) notNil ])
|
|
336 |
ifTrue:
|
|
337 |
[ button = 1
|
|
338 |
ifTrue: [ ^ self openMenu: (node leftClickMenuInCodeView: self) ].
|
|
339 |
button = #paste
|
|
340 |
ifTrue: [ ^ self openMenu: (node middleClickMenuInCodeView: self) ].
|
|
341 |
button = 2
|
|
342 |
ifTrue: [ ^ self openMenu: (node rightClickMenuInCodeView: self) ] ].
|
8775
|
343 |
super
|
10023
|
344 |
buttonPress: button
|
|
345 |
x: x
|
|
346 |
y: y
|
8775
|
347 |
|
|
348 |
"Created: / 26-12-2007 / 11:39:50 / janfrog"
|
|
349 |
"Modified: / 21-02-2008 / 09:17:29 / janfrog"
|
|
350 |
!
|
|
351 |
|
|
352 |
handleNonCommandKey:keyArg
|
|
353 |
|
|
354 |
super handleNonCommandKey: keyArg.
|
|
355 |
self startParsingProcess.
|
|
356 |
|
|
357 |
"Created: / 18-02-2008 / 17:18:22 / janfrog"
|
|
358 |
!
|
|
359 |
|
|
360 |
keyPress:key x:x y:y
|
|
361 |
(x notNil and:[ y notNil ]) ifTrue:[
|
|
362 |
key = #'Control_L' ifTrue:[
|
|
363 |
self
|
|
364 |
highlightNodeAtX:x y:y;
|
|
365 |
redraw
|
|
366 |
].
|
|
367 |
"key = #Alt_L ifTrue: [self highlightParseTreeNodeAtX: x y: y; redraw]"
|
|
368 |
].
|
|
369 |
|
|
370 |
(#( #Tab #Return #BackSpace ) includes:key) ifTrue:[
|
|
371 |
self startParsingProcess
|
|
372 |
].
|
|
373 |
|
|
374 |
key == #GoBack ifTrue:[self goBack].
|
|
375 |
|
|
376 |
^ super
|
|
377 |
keyPress:key
|
|
378 |
x:x
|
|
379 |
y:y
|
|
380 |
|
|
381 |
"Created: / 25-12-2007 / 23:49:38 / janfrog"
|
|
382 |
"Modified: / 27-02-2008 / 12:18:56 / janfrog"
|
|
383 |
"Modified: / 12-03-2009 / 16:35:56 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
384 |
!
|
|
385 |
|
|
386 |
keyRelease: key x: x y: y
|
|
387 |
(key = #Control_L) ifTrue:
|
|
388 |
[ selectedNode := nil. self highlightClear; redraw ].
|
|
389 |
"(key = #Alt_L) ifTrue:
|
|
390 |
[ parseTreeNode := nil. self highlightClear; redraw ]."
|
|
391 |
|
|
392 |
^ super
|
|
393 |
keyRelease: key
|
|
394 |
x: x
|
|
395 |
y: y
|
|
396 |
|
|
397 |
"Created: / 25-12-2007 / 23:15:15 / janfrog"
|
|
398 |
"Modified: / 19-02-2008 / 09:16:11 / janfrog"
|
|
399 |
! !
|
|
400 |
|
|
401 |
!NewSystemBrowserCodeView methodsFor:'menu'!
|
|
402 |
|
10023
|
403 |
browseClassesMenu: classes
|
|
404 |
| menu|
|
|
405 |
|
|
406 |
menu := Menu new.
|
|
407 |
classes do:
|
|
408 |
[:cls|
|
|
409 |
menu addItem:(MenuItem
|
|
410 |
label: ('Browse ' , cls fullName asText allBold)
|
|
411 |
value:[self browseClass: cls])].
|
|
412 |
|
|
413 |
^ menu
|
|
414 |
|
|
415 |
"Modified: / 19-10-2008 / 08:16:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
416 |
"Created: / 01-09-2009 / 09:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
417 |
!
|
|
418 |
|
8775
|
419 |
editMenu
|
|
420 |
|
|
421 |
| editMenu superEditMenu moreMenu moreMenuItem |
|
|
422 |
editMenu := self class editMenuSpec decodeAsLiteralArray.
|
|
423 |
superEditMenu := super editMenu.
|
|
424 |
moreMenu := superEditMenu subMenuAt: superEditMenu numberOfItems.
|
|
425 |
moreMenuItem := editMenu menuItemLabeled: 'More'.
|
|
426 |
moreMenuItem submenu: moreMenu asMenu.
|
|
427 |
editMenu findGuiResourcesIn: self.
|
|
428 |
^editMenu
|
|
429 |
|
|
430 |
"Created: / 25-12-2007 / 10:10:01 / janfrog"
|
|
431 |
"Modified: / 25-12-2007 / 19:50:53 / janfrog"
|
|
432 |
"Modified: / 18-10-2008 / 20:31:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
433 |
!
|
|
434 |
|
|
435 |
messageNodeContextMenu:messageNode
|
|
436 |
|menu|
|
|
437 |
|
|
438 |
menu := Menu new.
|
|
439 |
menu
|
|
440 |
addItem:((MenuItem new)
|
|
441 |
label:'Implementors';
|
|
442 |
shortcutKey:#ImplementorsOfIt;
|
|
443 |
submenuChannel:(Promise
|
|
444 |
value:[ self messageNodeImplementorsMenu:messageNode ]));
|
|
445 |
addItem:((MenuItem new)
|
|
446 |
label:'Senders';
|
|
447 |
shortcutKey:#SendersOfIt;
|
|
448 |
submenuChannel:(Promise value:[ self messageNodeSendersMenu:messageNode ])).
|
|
449 |
^ menu
|
|
450 |
|
|
451 |
"Created: / 18-02-2008 / 21:05:36 / janfrog"
|
|
452 |
!
|
|
453 |
|
|
454 |
messageNodeImplementorsMenu:messageNode
|
|
455 |
|implementors selector menu|
|
|
456 |
|
|
457 |
menu := Menu new.
|
|
458 |
implementors := self implementorsOf:(selector := messageNode selector).
|
|
459 |
implementors isNilOrEmptyCollection ifTrue:[
|
|
460 |
menu addItem:(MenuItem label:'No implementors found') disable
|
|
461 |
] ifFalse:[
|
|
462 |
menu addItem:(MenuItem
|
|
463 |
label:(selector storeString , (' (all implementors) ') asText allItalic)
|
|
464 |
value:[
|
|
465 |
self browseMethods:implementors
|
|
466 |
label:'Implementors of ' , selector storeString
|
|
467 |
]).
|
|
468 |
menu addSeparator.
|
|
469 |
implementors do:[:mth |
|
|
470 |
menu
|
|
471 |
addItem:(MenuItem label:(selector storeString
|
|
472 |
, (' in ' , mth containingClass name asText allBold))
|
|
473 |
value:[ self browseMethod:mth label: 'Implementor of ' , selector storeString ])
|
|
474 |
]
|
|
475 |
].
|
|
476 |
^ menu
|
|
477 |
|
|
478 |
"Created: / 18-02-2008 / 21:05:47 / janfrog"
|
|
479 |
"Modified: / 19-10-2008 / 08:16:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
480 |
!
|
|
481 |
|
|
482 |
messageNodeSendersMenu:messageNode
|
|
483 |
|implementors selector menu|
|
|
484 |
|
|
485 |
menu := Menu new.
|
|
486 |
implementors := self sendersOf:(selector := messageNode selector).
|
|
487 |
implementors isNilOrEmptyCollection ifTrue:[
|
|
488 |
menu addItem:(MenuItem label:'No senders found') disable
|
|
489 |
] ifFalse:[
|
|
490 |
menu addItem:(MenuItem
|
|
491 |
label:(selector storeString , (' (all senders)') asText allItalic)
|
|
492 |
value:[
|
|
493 |
self browseMethods:implementors
|
|
494 |
label:'Senders of ' , selector storeString
|
|
495 |
]).
|
|
496 |
menu addSeparator.
|
|
497 |
implementors do:[:mth |
|
|
498 |
menu
|
|
499 |
addItem:(MenuItem label:(mth selector storeString
|
|
500 |
, (' in ' , mth containingClass name asText allBold))
|
|
501 |
value:[ self browseMethod:mth label: 'Sender of ' , selector storeString ])
|
|
502 |
]
|
|
503 |
].
|
|
504 |
^ menu
|
|
505 |
|
|
506 |
"Created: / 18-02-2008 / 21:05:56 / janfrog"
|
|
507 |
"Modified: / 19-10-2008 / 08:17:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
508 |
!
|
|
509 |
|
|
510 |
openMenu: aMenuOrNil
|
|
511 |
|
|
512 |
aMenuOrNil ifNotNil:
|
|
513 |
[self highlightClear; redraw.
|
|
514 |
aMenuOrNil startUp].
|
|
515 |
|
|
516 |
"Created: / 18-02-2008 / 19:03:08 / janfrog"
|
|
517 |
!
|
|
518 |
|
|
519 |
variableNodeMenuContext:variableNode
|
|
520 |
|
|
521 |
| menu |
|
|
522 |
menu := Menu new.
|
|
523 |
menu
|
|
524 |
addItem:
|
|
525 |
(MenuItem new
|
|
526 |
label: 'Rename Local Variable';
|
|
527 |
value:[self refactorMenuRenameLocalVariable];
|
|
528 |
enabled:(self isLocalVariableNode: variableNode));
|
|
529 |
addItem:
|
|
530 |
(MenuItem new
|
|
531 |
label: 'Rename Instance Variable';
|
|
532 |
value:[self refactorMenuRenameInstanceVariable];
|
|
533 |
enabled:(self isInstanceVariableNode: variableNode)).
|
|
534 |
|
|
535 |
^menu
|
|
536 |
|
|
537 |
"Created: / 18-02-2008 / 21:10:46 / janfrog"
|
|
538 |
"Modified: / 21-02-2008 / 09:40:09 / janfrog"
|
|
539 |
! !
|
|
540 |
|
|
541 |
!NewSystemBrowserCodeView methodsFor:'menu - actions'!
|
|
542 |
|
|
543 |
accept
|
|
544 |
|
|
545 |
super accept.
|
|
546 |
self startParsingProcess
|
|
547 |
|
|
548 |
"Created: / 26-12-2007 / 12:33:19 / janfrog"
|
|
549 |
!
|
|
550 |
|
10023
|
551 |
browseClass: class
|
|
552 |
|
|
553 |
self browser ifNil: [^NewSystemBrowser browseClass:class].
|
|
554 |
(UserPreferences current alwaysOpenNewTabWhenCtrlClick or:[self browser navigationState modified])
|
|
555 |
ifTrue:
|
|
556 |
[self browser
|
|
557 |
spawnClassBrowserFor:(Array with: class)
|
|
558 |
in:#newBuffer]
|
|
559 |
ifFalse:
|
|
560 |
[self browser
|
|
561 |
switchToClass: class].
|
|
562 |
|
|
563 |
"Modified: / 19-02-2008 / 10:15:17 / janfrog"
|
|
564 |
"Created: / 01-09-2009 / 08:52:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
565 |
!
|
|
566 |
|
8775
|
567 |
browseImplementorsOfIt
|
|
568 |
|
|
569 |
| selector implementors |
|
|
570 |
selector := self selectedSelector.
|
|
571 |
implementors := self implementorsOf: selector.
|
|
572 |
self browseMethods: implementors label: 'Implementors of: ', selector storeString
|
|
573 |
|
|
574 |
"Created: / 26-12-2007 / 11:02:41 / janfrog"
|
|
575 |
!
|
|
576 |
|
|
577 |
browseMethod: method label: label
|
|
578 |
|
|
579 |
self browser ifNil: [^NewSystemBrowser openInMethod:method].
|
|
580 |
(UserPreferences current alwaysOpenNewTabWhenCtrlClick or:[self browser navigationState modified])
|
|
581 |
ifTrue:
|
|
582 |
[self browser
|
|
583 |
spawnMethodBrowserFor:(Array with: method)
|
|
584 |
in:#newBuffer
|
|
585 |
label:label]
|
|
586 |
ifFalse:
|
|
587 |
[self browser
|
|
588 |
switchToClass: method containingClass
|
|
589 |
selector: method selector].
|
|
590 |
|
|
591 |
"Modified: / 19-02-2008 / 10:15:17 / janfrog"
|
|
592 |
"Created: / 19-10-2008 / 08:16:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
593 |
!
|
|
594 |
|
|
595 |
browseMethods: methods label: label
|
|
596 |
|
|
597 |
methods size = 1 ifTrue:
|
|
598 |
[^self browseMethod: methods anyOne label: label].
|
|
599 |
|
|
600 |
self browser
|
|
601 |
ifNil: [NewSystemBrowser browseMethods: methods title: label]
|
|
602 |
ifNotNil:[self browser spawnMethodBrowserFor:methods in:#newBuffer label:label]
|
|
603 |
|
|
604 |
"Created: / 26-12-2007 / 11:32:04 / janfrog"
|
|
605 |
"Modified: / 19-10-2008 / 08:17:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
606 |
!
|
|
607 |
|
|
608 |
browseSendersOfIt
|
|
609 |
|
|
610 |
| selector implementors |
|
|
611 |
selector := self selectedSelector.
|
|
612 |
implementors := self sendersOf: selector.
|
|
613 |
self browseMethods: implementors label: 'Senders of: ', selector storeString
|
|
614 |
|
|
615 |
"Created: / 26-12-2007 / 11:35:43 / janfrog"
|
|
616 |
!
|
|
617 |
|
|
618 |
goBack
|
|
619 |
|
|
620 |
(self browser respondsTo: #goBack)
|
|
621 |
ifTrue:[self browser goBack]
|
|
622 |
|
|
623 |
"Created: / 27-02-2008 / 12:18:02 / janfrog"
|
|
624 |
!
|
|
625 |
|
|
626 |
inspectParseTree
|
|
627 |
^ self parseTree inspect
|
|
628 |
|
|
629 |
"Created: / 25-12-2007 / 21:36:09 / janfrog"
|
|
630 |
"Modified: / 19-02-2008 / 09:20:03 / janfrog"
|
|
631 |
!
|
|
632 |
|
|
633 |
inspectSelectedSelector
|
|
634 |
|
|
635 |
^self selectedSelector inspect
|
|
636 |
|
|
637 |
"Created: / 26-12-2007 / 11:16:48 / janfrog"
|
|
638 |
!
|
|
639 |
|
|
640 |
refactorMenuRenameInstanceVariable
|
|
641 |
|
|
642 |
self topView application codeMenuRenameTemporary
|
|
643 |
|
|
644 |
"Created: / 21-02-2008 / 09:15:08 / janfrog"
|
|
645 |
!
|
|
646 |
|
|
647 |
refactorMenuRenameLocalVariable
|
|
648 |
|
|
649 |
self browser codeMenuRenameTemporary
|
|
650 |
|
|
651 |
"Created: / 18-02-2008 / 21:21:26 / janfrog"
|
|
652 |
"Modified: / 19-02-2008 / 09:59:11 / janfrog"
|
|
653 |
! !
|
|
654 |
|
|
655 |
!NewSystemBrowserCodeView methodsFor:'menu - double dispatch'!
|
|
656 |
|
|
657 |
blueButtonMenuForMessageNode:messageNode
|
|
658 |
^ self messageNodeContextMenu:messageNode
|
|
659 |
|
|
660 |
"Created: / 18-02-2008 / 19:12:56 / janfrog"
|
|
661 |
"Modified: / 18-02-2008 / 21:05:36 / janfrog"
|
|
662 |
!
|
|
663 |
|
|
664 |
blueButtonMenuForVariableNode: messageNode
|
|
665 |
|
|
666 |
^self variableNodeMenuContext:messageNode
|
|
667 |
|
|
668 |
"Created: / 18-02-2008 / 21:04:32 / janfrog"
|
|
669 |
!
|
|
670 |
|
10023
|
671 |
leftClickMenuForMessageNode: messageNode
|
|
672 |
^ self messageNodeImplementorsMenu: messageNode
|
|
673 |
|
|
674 |
"Modified: / 18-02-2008 / 21:05:47 / janfrog"
|
|
675 |
!
|
|
676 |
|
|
677 |
leftClickMenuForVariableNode: varNode
|
|
678 |
|
|
679 |
| environment classes |
|
|
680 |
self browser ifNil:[^nil].
|
|
681 |
environment := self browser theSingleSelectedMethod mclass environment.
|
|
682 |
classes := OrderedCollection new.
|
|
683 |
[ environment notNil ] whileTrue:
|
|
684 |
[| cls |
|
|
685 |
cls := environment at: varNode name asSymbol.
|
|
686 |
cls ifNotNil:[classes add: cls].
|
|
687 |
environment :=
|
|
688 |
environment = Smalltalk
|
|
689 |
ifTrue:[environment := nil]
|
|
690 |
ifFalse:[environment environment]].
|
|
691 |
^classes isEmpty
|
|
692 |
ifTrue:[self browseClassesMenu: classes ]
|
|
693 |
ifFalse:[self variableNodeMenuContext: varNode]
|
|
694 |
|
|
695 |
"Modified: / 18-02-2008 / 21:05:47 / janfrog"
|
|
696 |
"Created: / 01-09-2009 / 08:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
697 |
"Modified: / 01-09-2009 / 09:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
698 |
!
|
|
699 |
|
|
700 |
middleClickMenuForMessageNode: messageNode
|
|
701 |
^ self messageNodeSendersMenu: messageNode
|
|
702 |
|
|
703 |
"Created: / 18-02-2008 / 19:08:50 / janfrog"
|
|
704 |
"Modified: / 18-02-2008 / 21:05:56 / janfrog"
|
|
705 |
!
|
|
706 |
|
8775
|
707 |
redButtonMenuForMessageNode:messageNode
|
|
708 |
^ self messageNodeImplementorsMenu:messageNode
|
|
709 |
|
|
710 |
"Modified: / 18-02-2008 / 21:05:47 / janfrog"
|
|
711 |
!
|
|
712 |
|
10023
|
713 |
rightClickMenuForMessageNode: messageNode
|
|
714 |
^ self messageNodeContextMenu: messageNode
|
|
715 |
|
|
716 |
"Created: / 18-02-2008 / 19:12:56 / janfrog"
|
|
717 |
"Modified: / 18-02-2008 / 21:05:36 / janfrog"
|
|
718 |
!
|
|
719 |
|
|
720 |
rightClickMenuForVariableNode: variableNode
|
|
721 |
^ self variableNodeMenuContext: variableNode
|
|
722 |
|
|
723 |
"Created: / 18-02-2008 / 21:04:32 / janfrog"
|
|
724 |
!
|
|
725 |
|
8775
|
726 |
yellowButtonMenuForMessageNode:messageNode
|
|
727 |
^ self messageNodeSendersMenu:messageNode
|
|
728 |
|
|
729 |
"Created: / 18-02-2008 / 19:08:50 / janfrog"
|
|
730 |
"Modified: / 18-02-2008 / 21:05:56 / janfrog"
|
|
731 |
! !
|
|
732 |
|
|
733 |
!NewSystemBrowserCodeView methodsFor:'private'!
|
|
734 |
|
|
735 |
implementorsOf: selector
|
|
736 |
|
|
737 |
selector ifNil:[^#()].
|
|
738 |
^SystemBrowser
|
|
739 |
findImplementorsOf: selector
|
|
740 |
in: Smalltalk allClasses
|
|
741 |
ignoreCase: false
|
|
742 |
|
|
743 |
"Created: / 26-12-2007 / 11:37:11 / janfrog"
|
|
744 |
!
|
|
745 |
|
|
746 |
sendersOf: selector
|
|
747 |
|
|
748 |
^SystemBrowser
|
|
749 |
findSendersOf: selector
|
|
750 |
in: Smalltalk allClasses
|
|
751 |
ignoreCase: false
|
|
752 |
|
|
753 |
"Created: / 26-12-2007 / 11:37:22 / janfrog"
|
|
754 |
! !
|
|
755 |
|
|
756 |
!NewSystemBrowserCodeView methodsFor:'private - highlighting'!
|
|
757 |
|
|
758 |
highlightClear
|
10023
|
759 |
self list ifNil:[ ^ self ].
|
|
760 |
self list do:[:line |
|
|
761 |
line isText ifTrue:[
|
|
762 |
line emphasisAllRemove:self selectorEmphasis
|
|
763 |
]
|
|
764 |
]
|
8775
|
765 |
|
|
766 |
"Created: / 25-12-2007 / 23:26:27 / janfrog"
|
|
767 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog"
|
|
768 |
!
|
|
769 |
|
|
770 |
highlightFrom: start to: end
|
|
771 |
"Remove underlined emphasis"
|
|
772 |
|
|
773 |
|startLine startCol endLine endCol|
|
|
774 |
|
|
775 |
startLine := self lineOfCharacterPosition:start.
|
|
776 |
startCol := start - (self characterPositionOfLine:startLine col:1) + 1.
|
|
777 |
endLine := self lineOfCharacterPosition:end.
|
|
778 |
endCol := end - (self characterPositionOfLine:endLine col:1) + 1.
|
|
779 |
self highlightFromLine: startLine col: startCol toLine: endLine col: endCol
|
|
780 |
|
|
781 |
"Created: / 25-12-2007 / 22:56:28 / janfrog"
|
|
782 |
!
|
|
783 |
|
10023
|
784 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol emphasis: em
|
|
785 |
|line start end|
|
8775
|
786 |
|
10023
|
787 |
(lineNo between:startLine and:endLine) ifFalse:[
|
|
788 |
^ self
|
|
789 |
].
|
|
790 |
line := self listAt:lineNo.
|
|
791 |
start := lineNo = startLine ifTrue:[
|
|
792 |
startCol
|
|
793 |
] ifFalse:[
|
|
794 |
line indexOfFirstNonBlankCharacter
|
|
795 |
].
|
|
796 |
end := lineNo = endLine ifTrue:[
|
|
797 |
endCol
|
|
798 |
] ifFalse:[ line size ].
|
|
799 |
line
|
|
800 |
emphasisFrom:start
|
|
801 |
to:end
|
|
802 |
add: em
|
8775
|
803 |
|
10023
|
804 |
"Created: / 25-06-2010 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
8775
|
805 |
!
|
|
806 |
|
|
807 |
highlightNode:node
|
|
808 |
selectedNode == node ifTrue:[^ self].
|
|
809 |
selectedNode := node.
|
|
810 |
selectedNode ifNil:[ ^ self highlightClear ].
|
|
811 |
selectedNode highlightInCodeView:self.
|
|
812 |
|
|
813 |
"Created: / 19-02-2008 / 09:14:38 / janfrog"
|
|
814 |
!
|
|
815 |
|
|
816 |
highlightNodeAtCursor
|
|
817 |
self highlightNodeAtLine:self cursorLine col:self cursorCol
|
|
818 |
|
|
819 |
"Created: / 19-02-2008 / 09:14:46 / janfrog"
|
|
820 |
!
|
|
821 |
|
|
822 |
highlightNodeAtLine:line col:col
|
|
823 |
|characterPosition node|
|
|
824 |
|
|
825 |
(self parseTree isNil or:[ self parseTree = #error ]) ifTrue:[
|
|
826 |
^ self
|
|
827 |
].
|
|
828 |
characterPosition := self characterPositionOfLine:line col:col.
|
|
829 |
node := self findNodeForInterval: (characterPosition to:characterPosition).
|
|
830 |
self highlightNode:node
|
|
831 |
|
|
832 |
"Created: / 19-02-2008 / 09:14:58 / janfrog"
|
|
833 |
!
|
|
834 |
|
|
835 |
highlightNodeAtX:x y:y
|
|
836 |
|visibleLine line col|
|
|
837 |
|
|
838 |
(self parseTree isNil or:[ self parseTree = #error ]) ifTrue:[
|
|
839 |
^ self
|
|
840 |
].
|
|
841 |
visibleLine := self visibleLineOfY:y.
|
|
842 |
col := self colOfX:x inVisibleLine:visibleLine.
|
|
843 |
line := self visibleLineToAbsoluteLine:visibleLine.
|
|
844 |
self highlightNodeAtLine:line col:col
|
|
845 |
|
|
846 |
"Created: / 19-02-2008 / 09:15:09 / janfrog"
|
|
847 |
!
|
|
848 |
|
|
849 |
highlightWithoutClearFrom: start to: end
|
|
850 |
"Remove underlined emphasis"
|
|
851 |
|
|
852 |
|startLine startCol endLine endCol|
|
|
853 |
|
|
854 |
startLine := self lineOfCharacterPosition:start.
|
|
855 |
startCol := start - (self characterPositionOfLine:startLine col:1) + 1.
|
|
856 |
endLine := self lineOfCharacterPosition:end.
|
|
857 |
endCol := end - (self characterPositionOfLine:endLine col:1) + 1.
|
|
858 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol
|
|
859 |
|
|
860 |
"Created: / 25-12-2007 / 23:27:14 / janfrog"
|
|
861 |
!
|
|
862 |
|
|
863 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol
|
|
864 |
|
|
865 |
self list keysAndValuesDo:
|
|
866 |
[:lineNo :line|
|
|
867 |
|start end|
|
|
868 |
line isText ifTrue:
|
|
869 |
[self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]].
|
|
870 |
|
|
871 |
"Created: / 25-12-2007 / 23:35:07 / janfrog"
|
10023
|
872 |
!
|
|
873 |
|
|
874 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol emphasis: em
|
|
875 |
|
|
876 |
self list keysAndValuesDo:
|
|
877 |
[:lineNo :line|
|
|
878 |
|start end|
|
|
879 |
line isText ifTrue:
|
|
880 |
[self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol emphasis: em]].
|
|
881 |
|
|
882 |
"Created: / 25-06-2010 / 13:58:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
883 |
!
|
|
884 |
|
|
885 |
selectorEmphasis
|
|
886 |
^ highlightEmphasis
|
|
887 |
ifNil:[ highlightEmphasis := Array with:#underline with:#bold ]
|
|
888 |
|
|
889 |
"Created: / 25-12-2007 / 22:57:23 / janfrog"
|
|
890 |
"Modified: / 26-12-2007 / 11:16:14 / janfrog"
|
|
891 |
"Modified: / 01-09-2009 / 22:29:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
8775
|
892 |
! !
|
|
893 |
|
|
894 |
!NewSystemBrowserCodeView methodsFor:'private - highlighting - nodes'!
|
|
895 |
|
|
896 |
highlightLiteralNode: node
|
|
897 |
|
|
898 |
node value isSymbol ifTrue:
|
|
899 |
[self highlightFrom: node start to: node stop]
|
|
900 |
|
|
901 |
"Created: / 26-12-2007 / 10:19:08 / janfrog"
|
|
902 |
!
|
|
903 |
|
|
904 |
highlightMessageNode: node
|
|
905 |
|
|
906 |
self highlightClear.
|
|
907 |
node selectorParts do:
|
|
908 |
[:part|self highlightWithoutClearFrom: part start to: part stop]
|
|
909 |
|
|
910 |
"Created: / 25-12-2007 / 23:41:36 / janfrog"
|
|
911 |
!
|
|
912 |
|
|
913 |
highlightVariableNode: node
|
|
914 |
(#('self' 'super' 'here' 'thisContext') includes:node name) ifTrue:[^self].
|
|
915 |
^ self highlightFrom: node start to: node stop
|
|
916 |
|
|
917 |
"Created: / 25-12-2007 / 23:45:42 / janfrog"
|
|
918 |
"Modified: / 18-02-2008 / 20:51:51 / janfrog"
|
|
919 |
! !
|
|
920 |
|
|
921 |
!NewSystemBrowserCodeView methodsFor:'private - parsing'!
|
|
922 |
|
|
923 |
parseTree
|
|
924 |
|
|
925 |
^ parseTree
|
|
926 |
|
|
927 |
"Created: / 19-02-2008 / 09:20:03 / janfrog"
|
|
928 |
"Modified: / 19-10-2008 / 07:36:36 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
929 |
!
|
|
930 |
|
|
931 |
parseTree:something
|
|
932 |
parseTree := something.
|
|
933 |
|
|
934 |
"Created: / 19-10-2008 / 07:39:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
935 |
!
|
|
936 |
|
|
937 |
parseTree:something sequenceNumber: givenSeqNum
|
|
938 |
|
|
939 |
givenSeqNum < seqNum ifFalse:
|
|
940 |
[parseTree := something].
|
|
941 |
|
|
942 |
"Created: / 12-03-2009 / 16:29:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
943 |
!
|
|
944 |
|
|
945 |
startParsingProcess
|
|
946 |
|prio contents|
|
|
947 |
|
|
948 |
seqNum := ((seqNum ? 0) + 1).
|
|
949 |
parsingProcess
|
|
950 |
ifNotNil:[
|
|
951 |
parsingProcessRunning ~~ true ifTrue:[
|
|
952 |
^ self
|
|
953 |
].
|
|
954 |
self stopParsingProcess
|
|
955 |
].
|
|
956 |
prio := Processor userBackgroundPriority - 1.
|
|
957 |
self shown ifFalse:[
|
|
958 |
prio := prio - 1 max:1
|
|
959 |
].
|
|
960 |
contents := self contents.
|
|
961 |
parsingProcess := [
|
|
962 |
[
|
|
963 |
| tree |
|
|
964 |
tree := ((contents isNilOrEmptyCollection)
|
|
965 |
ifTrue:[ nil ]
|
|
966 |
ifFalse:[ RBParser parseMethod:contents onError:[:err :pos | #error ] ]).
|
|
967 |
self sensor
|
|
968 |
pushUserEvent:#parseTree:sequenceNumber:
|
|
969 |
for: self
|
|
970 |
withArguments:
|
|
971 |
(Array with: tree with: seqNum)
|
|
972 |
] ensure:[
|
|
973 |
parsingProcessRunning := false.
|
|
974 |
parsingProcess := nil.
|
|
975 |
]
|
|
976 |
] forkAt:prio
|
|
977 |
|
|
978 |
"Modified: / 19-02-2008 / 09:22:57 / janfrog"
|
|
979 |
"Created: / 21-08-2009 / 15:40:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
980 |
"Modified: / 22-08-2009 / 11:51:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
981 |
!
|
|
982 |
|
|
983 |
stopParsingProcess
|
|
984 |
|p|
|
|
985 |
|
|
986 |
(p := parsingProcess) notNil ifTrue:[
|
|
987 |
parsingProcess := nil.
|
|
988 |
p terminate.
|
|
989 |
"/ raise its prio to make it terminate quickly
|
|
990 |
p priority:(Processor userSchedulingPriority + 1)
|
|
991 |
]
|
|
992 |
|
|
993 |
"Created: / 25-12-2007 / 21:16:03 / janfrog"
|
|
994 |
! !
|
|
995 |
|
|
996 |
!NewSystemBrowserCodeView methodsFor:'private - testing'!
|
|
997 |
|
|
998 |
isInstanceVariableNode: node
|
|
999 |
|
|
1000 |
|
|
1001 |
node isVariable ifFalse:[^false].
|
|
1002 |
^(self selectedClass allInstVarNames includes:(node name))
|
|
1003 |
|
|
1004 |
"Created: / 21-02-2008 / 09:39:10 / janfrog"
|
|
1005 |
!
|
|
1006 |
|
|
1007 |
isLocalVariableNode: node
|
|
1008 |
|
|
1009 |
|
|
1010 |
(self parseTree arguments includes: node) ifTrue:[^true].
|
|
1011 |
(self parseTree body temporaries includes: node) ifTrue:[^true].
|
|
1012 |
^false
|
|
1013 |
|
|
1014 |
"Created: / 21-02-2008 / 09:32:33 / janfrog"
|
|
1015 |
! !
|
|
1016 |
|
|
1017 |
!NewSystemBrowserCodeView class methodsFor:'documentation'!
|
|
1018 |
|
8806
|
1019 |
version_CVS
|
10024
|
1020 |
^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowserCodeView.st,v 1.7 2011-07-01 14:21:48 cg Exp $'
|
8806
|
1021 |
!
|
|
1022 |
|
8819
|
1023 |
version_CVS_jvrany
|
10023
|
1024 |
^ '§Header: /opt/data/cvs/stx/goodies/libtool3/Tools__NewSystemBrowserCodeView.st,v 1.4 2008-02-27 13:45:41 vranyj1 Exp §'
|
|
1025 |
!
|
|
1026 |
|
|
1027 |
version_SVN
|
|
1028 |
^ '§Id: Tools__NewSystemBrowserCodeView.st 7486 2009-10-26 22:06:24Z vranyj1 §'
|
8775
|
1029 |
! !
|
|
1030 |
|
|
1031 |
NewSystemBrowserCodeView initialize!
|