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