author | vrany |
Sat, 09 Jul 2011 15:53:19 +0200 | |
changeset 10300 | 5ed6f3d35cbb |
parent 10172 | 6e6165958f2c |
child 10463 | 2f131c162757 |
permissions | -rw-r--r-- |
10023 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
10042 | 3 |
All Rights Reserved |
10023 | 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 |
|
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
17 |
instanceVariableNames:'browser parseTree selectedNode parsingProcess |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
18 |
parsingProcessRunning highlightEmphasis seqNum' |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
19 |
classVariableNames:'' |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
20 |
poolDictionaries:'' |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
21 |
category:'Interface-Browsers-New' |
8775 | 22 |
! |
23 |
||
10023 | 24 |
!NewSystemBrowserCodeView class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
10042 | 29 |
All Rights Reserved |
10023 | 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 |
|
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
678 |
| environment classes | |
10023 | 679 |
|
680 |
self browser ifNil:[^nil]. |
|
681 |
environment := self browser theSingleSelectedMethod mclass environment. |
|
682 |
classes := OrderedCollection new. |
|
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
683 |
[ environment notNil ] whileTrue:[ |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
684 |
| cls | |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
685 |
|
10023 | 686 |
cls := environment at: varNode name asSymbol. |
687 |
cls ifNotNil:[classes add: cls]. |
|
688 |
environment := |
|
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
689 |
(environment == Smalltalk) |
10023 | 690 |
ifTrue:[environment := nil] |
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
691 |
ifFalse:[environment environment] |
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
692 |
]. |
10023 | 693 |
^classes isEmpty |
694 |
ifTrue:[self browseClassesMenu: classes ] |
|
695 |
ifFalse:[self variableNodeMenuContext: varNode] |
|
696 |
||
697 |
"Modified: / 18-02-2008 / 21:05:47 / janfrog" |
|
698 |
"Created: / 01-09-2009 / 08:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
699 |
"Modified: / 01-09-2009 / 09:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
700 |
"Modified (format): / 05-07-2011 / 16:04:47 / cg" |
10023 | 701 |
! |
702 |
||
703 |
middleClickMenuForMessageNode: messageNode |
|
704 |
^ self messageNodeSendersMenu: messageNode |
|
705 |
||
706 |
"Created: / 18-02-2008 / 19:08:50 / janfrog" |
|
707 |
"Modified: / 18-02-2008 / 21:05:56 / janfrog" |
|
708 |
! |
|
709 |
||
8775 | 710 |
redButtonMenuForMessageNode:messageNode |
711 |
^ self messageNodeImplementorsMenu:messageNode |
|
712 |
||
713 |
"Modified: / 18-02-2008 / 21:05:47 / janfrog" |
|
714 |
! |
|
715 |
||
10023 | 716 |
rightClickMenuForMessageNode: messageNode |
717 |
^ self messageNodeContextMenu: messageNode |
|
718 |
||
719 |
"Created: / 18-02-2008 / 19:12:56 / janfrog" |
|
720 |
"Modified: / 18-02-2008 / 21:05:36 / janfrog" |
|
721 |
! |
|
722 |
||
723 |
rightClickMenuForVariableNode: variableNode |
|
724 |
^ self variableNodeMenuContext: variableNode |
|
725 |
||
726 |
"Created: / 18-02-2008 / 21:04:32 / janfrog" |
|
727 |
! |
|
728 |
||
8775 | 729 |
yellowButtonMenuForMessageNode:messageNode |
730 |
^ self messageNodeSendersMenu:messageNode |
|
731 |
||
732 |
"Created: / 18-02-2008 / 19:08:50 / janfrog" |
|
733 |
"Modified: / 18-02-2008 / 21:05:56 / janfrog" |
|
734 |
! ! |
|
735 |
||
736 |
!NewSystemBrowserCodeView methodsFor:'private'! |
|
737 |
||
738 |
implementorsOf: selector |
|
739 |
||
740 |
selector ifNil:[^#()]. |
|
741 |
^SystemBrowser |
|
742 |
findImplementorsOf: selector |
|
743 |
in: Smalltalk allClasses |
|
744 |
ignoreCase: false |
|
745 |
||
746 |
"Created: / 26-12-2007 / 11:37:11 / janfrog" |
|
747 |
! |
|
748 |
||
749 |
sendersOf: selector |
|
750 |
||
751 |
^SystemBrowser |
|
752 |
findSendersOf: selector |
|
753 |
in: Smalltalk allClasses |
|
754 |
ignoreCase: false |
|
755 |
||
756 |
"Created: / 26-12-2007 / 11:37:22 / janfrog" |
|
757 |
! ! |
|
758 |
||
759 |
!NewSystemBrowserCodeView methodsFor:'private - highlighting'! |
|
760 |
||
761 |
highlightClear |
|
10023 | 762 |
self list ifNil:[ ^ self ]. |
763 |
self list do:[:line | |
|
764 |
line isText ifTrue:[ |
|
765 |
line emphasisAllRemove:self selectorEmphasis |
|
766 |
] |
|
767 |
] |
|
8775 | 768 |
|
769 |
"Created: / 25-12-2007 / 23:26:27 / janfrog" |
|
770 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
771 |
! |
|
772 |
||
773 |
highlightFrom: start to: end |
|
774 |
"Remove underlined emphasis" |
|
775 |
||
776 |
|startLine startCol endLine endCol| |
|
777 |
||
778 |
startLine := self lineOfCharacterPosition:start. |
|
779 |
startCol := start - (self characterPositionOfLine:startLine col:1) + 1. |
|
780 |
endLine := self lineOfCharacterPosition:end. |
|
781 |
endCol := end - (self characterPositionOfLine:endLine col:1) + 1. |
|
782 |
self highlightFromLine: startLine col: startCol toLine: endLine col: endCol |
|
783 |
||
784 |
"Created: / 25-12-2007 / 22:56:28 / janfrog" |
|
785 |
! |
|
786 |
||
10023 | 787 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol emphasis: em |
788 |
|line start end| |
|
8775 | 789 |
|
10023 | 790 |
(lineNo between:startLine and:endLine) ifFalse:[ |
791 |
^ self |
|
792 |
]. |
|
793 |
line := self listAt:lineNo. |
|
794 |
start := lineNo = startLine ifTrue:[ |
|
795 |
startCol |
|
796 |
] ifFalse:[ |
|
797 |
line indexOfFirstNonBlankCharacter |
|
798 |
]. |
|
799 |
end := lineNo = endLine ifTrue:[ |
|
800 |
endCol |
|
801 |
] ifFalse:[ line size ]. |
|
802 |
line |
|
803 |
emphasisFrom:start |
|
804 |
to:end |
|
805 |
add: em |
|
8775 | 806 |
|
10023 | 807 |
"Created: / 25-06-2010 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8775 | 808 |
! |
809 |
||
810 |
highlightNode:node |
|
811 |
selectedNode == node ifTrue:[^ self]. |
|
812 |
selectedNode := node. |
|
813 |
selectedNode ifNil:[ ^ self highlightClear ]. |
|
814 |
selectedNode highlightInCodeView:self. |
|
815 |
||
816 |
"Created: / 19-02-2008 / 09:14:38 / janfrog" |
|
817 |
! |
|
818 |
||
819 |
highlightNodeAtCursor |
|
820 |
self highlightNodeAtLine:self cursorLine col:self cursorCol |
|
821 |
||
822 |
"Created: / 19-02-2008 / 09:14:46 / janfrog" |
|
823 |
! |
|
824 |
||
825 |
highlightNodeAtLine:line col:col |
|
826 |
|characterPosition node| |
|
827 |
||
828 |
(self parseTree isNil or:[ self parseTree = #error ]) ifTrue:[ |
|
829 |
^ self |
|
830 |
]. |
|
831 |
characterPosition := self characterPositionOfLine:line col:col. |
|
832 |
node := self findNodeForInterval: (characterPosition to:characterPosition). |
|
833 |
self highlightNode:node |
|
834 |
||
835 |
"Created: / 19-02-2008 / 09:14:58 / janfrog" |
|
836 |
! |
|
837 |
||
838 |
highlightNodeAtX:x y:y |
|
839 |
|visibleLine line col| |
|
840 |
||
841 |
(self parseTree isNil or:[ self parseTree = #error ]) ifTrue:[ |
|
842 |
^ self |
|
843 |
]. |
|
844 |
visibleLine := self visibleLineOfY:y. |
|
845 |
col := self colOfX:x inVisibleLine:visibleLine. |
|
846 |
line := self visibleLineToAbsoluteLine:visibleLine. |
|
847 |
self highlightNodeAtLine:line col:col |
|
848 |
||
849 |
"Created: / 19-02-2008 / 09:15:09 / janfrog" |
|
850 |
! |
|
851 |
||
852 |
highlightWithoutClearFrom: start to: end |
|
853 |
"Remove underlined emphasis" |
|
854 |
||
855 |
|startLine startCol endLine endCol| |
|
856 |
||
857 |
startLine := self lineOfCharacterPosition:start. |
|
858 |
startCol := start - (self characterPositionOfLine:startLine col:1) + 1. |
|
859 |
endLine := self lineOfCharacterPosition:end. |
|
860 |
endCol := end - (self characterPositionOfLine:endLine col:1) + 1. |
|
861 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
862 |
||
863 |
"Created: / 25-12-2007 / 23:27:14 / janfrog" |
|
864 |
! |
|
865 |
||
866 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
867 |
||
868 |
self list keysAndValuesDo: |
|
869 |
[:lineNo :line| |
|
870 |
|start end| |
|
871 |
line isText ifTrue: |
|
872 |
[self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]]. |
|
873 |
||
874 |
"Created: / 25-12-2007 / 23:35:07 / janfrog" |
|
10023 | 875 |
! |
876 |
||
877 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol emphasis: em |
|
878 |
||
879 |
self list keysAndValuesDo: |
|
880 |
[:lineNo :line| |
|
881 |
|start end| |
|
882 |
line isText ifTrue: |
|
883 |
[self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol emphasis: em]]. |
|
884 |
||
885 |
"Created: / 25-06-2010 / 13:58:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
886 |
! |
|
887 |
||
888 |
selectorEmphasis |
|
889 |
^ highlightEmphasis |
|
890 |
ifNil:[ highlightEmphasis := Array with:#underline with:#bold ] |
|
891 |
||
892 |
"Created: / 25-12-2007 / 22:57:23 / janfrog" |
|
893 |
"Modified: / 26-12-2007 / 11:16:14 / janfrog" |
|
894 |
"Modified: / 01-09-2009 / 22:29:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
8775 | 895 |
! ! |
896 |
||
897 |
!NewSystemBrowserCodeView methodsFor:'private - highlighting - nodes'! |
|
898 |
||
899 |
highlightLiteralNode: node |
|
900 |
||
901 |
node value isSymbol ifTrue: |
|
902 |
[self highlightFrom: node start to: node stop] |
|
903 |
||
904 |
"Created: / 26-12-2007 / 10:19:08 / janfrog" |
|
905 |
! |
|
906 |
||
907 |
highlightMessageNode: node |
|
908 |
||
909 |
self highlightClear. |
|
910 |
node selectorParts do: |
|
911 |
[:part|self highlightWithoutClearFrom: part start to: part stop] |
|
912 |
||
913 |
"Created: / 25-12-2007 / 23:41:36 / janfrog" |
|
914 |
! |
|
915 |
||
916 |
highlightVariableNode: node |
|
917 |
(#('self' 'super' 'here' 'thisContext') includes:node name) ifTrue:[^self]. |
|
918 |
^ self highlightFrom: node start to: node stop |
|
919 |
||
920 |
"Created: / 25-12-2007 / 23:45:42 / janfrog" |
|
921 |
"Modified: / 18-02-2008 / 20:51:51 / janfrog" |
|
922 |
! ! |
|
923 |
||
924 |
!NewSystemBrowserCodeView methodsFor:'private - parsing'! |
|
925 |
||
926 |
parseTree |
|
927 |
||
928 |
^ parseTree |
|
929 |
||
930 |
"Created: / 19-02-2008 / 09:20:03 / janfrog" |
|
931 |
"Modified: / 19-10-2008 / 07:36:36 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
932 |
! |
|
933 |
||
934 |
parseTree:something |
|
935 |
parseTree := something. |
|
936 |
||
937 |
"Created: / 19-10-2008 / 07:39:15 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
938 |
! |
|
939 |
||
940 |
parseTree:something sequenceNumber: givenSeqNum |
|
941 |
||
942 |
givenSeqNum < seqNum ifFalse: |
|
943 |
[parseTree := something]. |
|
944 |
||
945 |
"Created: / 12-03-2009 / 16:29:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
946 |
! |
|
947 |
||
948 |
startParsingProcess |
|
949 |
|prio contents| |
|
950 |
||
951 |
seqNum := ((seqNum ? 0) + 1). |
|
952 |
parsingProcess |
|
953 |
ifNotNil:[ |
|
954 |
parsingProcessRunning ~~ true ifTrue:[ |
|
955 |
^ self |
|
956 |
]. |
|
957 |
self stopParsingProcess |
|
958 |
]. |
|
959 |
prio := Processor userBackgroundPriority - 1. |
|
960 |
self shown ifFalse:[ |
|
961 |
prio := prio - 1 max:1 |
|
962 |
]. |
|
963 |
contents := self contents. |
|
964 |
parsingProcess := [ |
|
965 |
[ |
|
966 |
| tree | |
|
967 |
tree := ((contents isNilOrEmptyCollection) |
|
968 |
ifTrue:[ nil ] |
|
969 |
ifFalse:[ RBParser parseMethod:contents onError:[:err :pos | #error ] ]). |
|
970 |
self sensor |
|
971 |
pushUserEvent:#parseTree:sequenceNumber: |
|
972 |
for: self |
|
973 |
withArguments: |
|
974 |
(Array with: tree with: seqNum) |
|
975 |
] ensure:[ |
|
976 |
parsingProcessRunning := false. |
|
977 |
parsingProcess := nil. |
|
978 |
] |
|
979 |
] forkAt:prio |
|
980 |
||
981 |
"Modified: / 19-02-2008 / 09:22:57 / janfrog" |
|
982 |
"Created: / 21-08-2009 / 15:40:06 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
983 |
"Modified: / 22-08-2009 / 11:51:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
984 |
! |
|
985 |
||
986 |
stopParsingProcess |
|
987 |
|p| |
|
988 |
||
989 |
(p := parsingProcess) notNil ifTrue:[ |
|
990 |
parsingProcess := nil. |
|
991 |
p terminate. |
|
992 |
"/ raise its prio to make it terminate quickly |
|
993 |
p priority:(Processor userSchedulingPriority + 1) |
|
994 |
] |
|
995 |
||
996 |
"Created: / 25-12-2007 / 21:16:03 / janfrog" |
|
997 |
! ! |
|
998 |
||
999 |
!NewSystemBrowserCodeView methodsFor:'private - testing'! |
|
1000 |
||
1001 |
isInstanceVariableNode: node |
|
1002 |
||
1003 |
||
1004 |
node isVariable ifFalse:[^false]. |
|
1005 |
^(self selectedClass allInstVarNames includes:(node name)) |
|
1006 |
||
1007 |
"Created: / 21-02-2008 / 09:39:10 / janfrog" |
|
1008 |
! |
|
1009 |
||
1010 |
isLocalVariableNode: node |
|
1011 |
||
1012 |
||
1013 |
(self parseTree arguments includes: node) ifTrue:[^true]. |
|
1014 |
(self parseTree body temporaries includes: node) ifTrue:[^true]. |
|
1015 |
^false |
|
1016 |
||
1017 |
"Created: / 21-02-2008 / 09:32:33 / janfrog" |
|
1018 |
! ! |
|
1019 |
||
1020 |
!NewSystemBrowserCodeView class methodsFor:'documentation'! |
|
1021 |
||
8806 | 1022 |
version_CVS |
10172
6e6165958f2c
changed: #leftClickMenuForVariableNode:
Claus Gittinger <cg@exept.de>
parents:
10042
diff
changeset
|
1023 |
^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowserCodeView.st,v 1.9 2011-07-05 14:06:31 cg Exp $' |
10023 | 1024 |
! |
1025 |
||
1026 |
version_SVN |
|
1027 |
^ '§Id: Tools__NewSystemBrowserCodeView.st 7486 2009-10-26 22:06:24Z vranyj1 §' |
|
8775 | 1028 |
! ! |
1029 |
||
1030 |
NewSystemBrowserCodeView initialize! |