8776
|
1 |
"{ Package: 'cvut:stx/goodies/libtool3' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Tools }"
|
|
4 |
|
|
5 |
ApplicationModel subclass:#MethodRewriter
|
|
6 |
instanceVariableNames:'replaceTextView classes searchTextView actionInProgresHolder
|
|
7 |
infoHolder progressHolder templateSearchPatternHolder
|
|
8 |
templateReplacePatternHolder selectedTemplateIndex templates
|
|
9 |
selectedTabIndex selectedClassesHolder'
|
|
10 |
classVariableNames:''
|
|
11 |
poolDictionaries:''
|
|
12 |
category:'Interface-Method rewriter'
|
|
13 |
!
|
|
14 |
|
|
15 |
|
|
16 |
!MethodRewriter class methodsFor:'examples'!
|
|
17 |
|
|
18 |
templateReplaceAtIfAbsentByAtAifAbsentPut
|
|
19 |
|
|
20 |
^Array
|
|
21 |
with:'Replace Dictionary>>#at:ifAbsent: by #at:ifAbsentPut:'
|
|
22 |
with: '``@dictionary
|
|
23 |
at: ``@key
|
|
24 |
ifAbsent:
|
|
25 |
[| `@temps |
|
|
26 |
`@.statements.
|
|
27 |
``@dictionary at: ``@key put: ``@object]'
|
|
28 |
with:'``@dictionary
|
|
29 |
at: ``@key
|
|
30 |
ifAbsentPut:
|
|
31 |
[| `@temps |
|
|
32 |
`@.statements.
|
|
33 |
``@object]'
|
|
34 |
|
|
35 |
"Created: / 12-12-2007 / 11:08:01 / janfrog"
|
|
36 |
"Modified: / 17-02-2008 / 08:35:17 / janfrog"
|
|
37 |
!
|
|
38 |
|
|
39 |
templateReplaceSelfHaltBySelfError
|
|
40 |
|
|
41 |
^Array
|
|
42 |
with:'Replace self halt by self error:''was: self halt'''
|
|
43 |
with: 'self halt'
|
|
44 |
with: 'self error:''was: self error'''
|
|
45 |
|
|
46 |
"Created: / 12-12-2007 / 11:29:51 / janfrog"
|
|
47 |
"Modified: / 17-02-2008 / 08:35:09 / janfrog"
|
|
48 |
!
|
|
49 |
|
|
50 |
templates
|
|
51 |
|
|
52 |
|templateSelectors|
|
|
53 |
|
|
54 |
templateSelectors :=
|
|
55 |
(self class selectors select:[:e|(e startsWith:'template')
|
|
56 |
and:[e ~= #templates and:[e ~= #templatesSpec]]]).
|
|
57 |
^templateSelectors
|
|
58 |
collect:[:e|self perform:e]
|
|
59 |
|
|
60 |
"
|
|
61 |
self templates
|
|
62 |
"
|
|
63 |
|
|
64 |
"Created: / 12-12-2007 / 11:03:32 / janfrog"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!MethodRewriter class methodsFor:'interface specs'!
|
|
68 |
|
|
69 |
classesSpec
|
|
70 |
"This resource specification was automatically generated
|
|
71 |
by the UIPainter of ST/X."
|
|
72 |
|
|
73 |
"Do not manually edit this!! If it is corrupted,
|
|
74 |
the UIPainter may not be able to read the specification."
|
|
75 |
|
|
76 |
"
|
|
77 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#classesSpec
|
|
78 |
Tools::MethodRewriter new openInterface:#classesSpec
|
|
79 |
"
|
|
80 |
|
|
81 |
<resource: #canvas>
|
|
82 |
|
|
83 |
^
|
|
84 |
#(FullSpec
|
|
85 |
name: classesSpec
|
|
86 |
window:
|
|
87 |
(WindowSpec
|
|
88 |
label: 'Classes'
|
|
89 |
name: 'Classes'
|
|
90 |
min: (Point 10 10)
|
|
91 |
bounds: (Rectangle 0 0 300 300)
|
|
92 |
)
|
|
93 |
component:
|
|
94 |
(SpecCollection
|
|
95 |
collection: (
|
|
96 |
(LabelSpec
|
|
97 |
label: 'Hint: drag''n''drop classes from browser'
|
|
98 |
name: 'HintLabel'
|
|
99 |
layout: (LayoutFrame 0 0 0 0 0 1 30 0)
|
|
100 |
translateLabel: true
|
|
101 |
adjust: left
|
|
102 |
)
|
|
103 |
(SelectionInListModelViewSpec
|
|
104 |
name: 'ClassesList'
|
|
105 |
layout: (LayoutFrame 0 0 30 0 0 1 -30 1)
|
|
106 |
model: selectedClassesHolder
|
|
107 |
hasHorizontalScrollBar: true
|
|
108 |
hasVerticalScrollBar: true
|
|
109 |
listModel: classes
|
|
110 |
multipleSelectOk: true
|
|
111 |
useIndex: false
|
|
112 |
highlightMode: line
|
|
113 |
properties:
|
|
114 |
(PropertyListDictionary
|
|
115 |
dragArgument: nil
|
|
116 |
dropArgument: nil
|
|
117 |
canDropSelector: canDropClasses:
|
|
118 |
dropSelector: doDropClasses:
|
|
119 |
)
|
|
120 |
)
|
|
121 |
(ActionButtonSpec
|
|
122 |
label: 'Remove selected classes'
|
|
123 |
name: 'RemoveClassesButton'
|
|
124 |
layout: (LayoutFrame 5 0 -25 1 -5 1 -5 1)
|
|
125 |
translateLabel: true
|
|
126 |
model: removeSeletedClassesAction
|
|
127 |
)
|
|
128 |
)
|
|
129 |
|
|
130 |
)
|
|
131 |
)
|
|
132 |
|
|
133 |
"Modified: / 12-12-2007 / 12:07:17 / janfrog"
|
|
134 |
!
|
|
135 |
|
|
136 |
searchAndReplaceSpec
|
|
137 |
"This resource specification was automatically generated
|
|
138 |
by the UIPainter of ST/X."
|
|
139 |
|
|
140 |
"Do not manually edit this!! If it is corrupted,
|
|
141 |
the UIPainter may not be able to read the specification."
|
|
142 |
|
|
143 |
"
|
|
144 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#searchAndReplaceSpec
|
|
145 |
Tools::MethodRewriter new openInterface:#searchAndReplaceSpec
|
|
146 |
"
|
|
147 |
|
|
148 |
<resource: #canvas>
|
|
149 |
|
|
150 |
^
|
|
151 |
#(FullSpec
|
|
152 |
name: searchAndReplaceSpec
|
|
153 |
window:
|
|
154 |
(WindowSpec
|
|
155 |
label: 'Method Rewriter'
|
|
156 |
name: 'Method Rewriter'
|
|
157 |
min: (Point 10 10)
|
|
158 |
bounds: (Rectangle 0 0 418 294)
|
|
159 |
)
|
|
160 |
component:
|
|
161 |
(SpecCollection
|
|
162 |
collection: (
|
|
163 |
(VariableVerticalPanelSpec
|
|
164 |
name: 'FindAndReplacePanel'
|
|
165 |
layout: (LayoutFrame 0 0 0 0 0 1 -30 1)
|
|
166 |
showHandle: true
|
|
167 |
snapMode: both
|
|
168 |
component:
|
|
169 |
(SpecCollection
|
|
170 |
collection: (
|
|
171 |
(ViewSpec
|
|
172 |
name: 'FindBox'
|
|
173 |
component:
|
|
174 |
(SpecCollection
|
|
175 |
collection: (
|
|
176 |
(LabelSpec
|
|
177 |
label: 'Find:'
|
|
178 |
name: 'FindLabel'
|
|
179 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0)
|
|
180 |
translateLabel: true
|
|
181 |
adjust: left
|
|
182 |
)
|
|
183 |
(TextEditorSpec
|
|
184 |
name: 'FindText'
|
|
185 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1)
|
|
186 |
hasHorizontalScrollBar: true
|
|
187 |
hasVerticalScrollBar: true
|
|
188 |
postBuildCallback: postBuildFindTextView:
|
|
189 |
)
|
|
190 |
)
|
|
191 |
|
|
192 |
)
|
|
193 |
)
|
|
194 |
(ViewSpec
|
|
195 |
name: 'ReplaceBox'
|
|
196 |
component:
|
|
197 |
(SpecCollection
|
|
198 |
collection: (
|
|
199 |
(LabelSpec
|
|
200 |
label: 'Replace with:'
|
|
201 |
name: 'ReplaceLabel'
|
|
202 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0)
|
|
203 |
translateLabel: true
|
|
204 |
adjust: left
|
|
205 |
)
|
|
206 |
(TextEditorSpec
|
|
207 |
name: 'ReplaceText'
|
|
208 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1)
|
|
209 |
hasHorizontalScrollBar: true
|
|
210 |
hasVerticalScrollBar: true
|
|
211 |
postBuildCallback: postBuildReplaceTextView:
|
|
212 |
)
|
|
213 |
)
|
|
214 |
|
|
215 |
)
|
|
216 |
)
|
|
217 |
)
|
|
218 |
|
|
219 |
)
|
|
220 |
handles: (Any 0.5 1.0)
|
|
221 |
)
|
|
222 |
(LabelSpec
|
|
223 |
label: 'Enjoy'
|
|
224 |
name: 'InfoLabel'
|
|
225 |
layout: (LayoutFrame 5 0 -25 1 205 0 -5 1)
|
|
226 |
visibilityChannel: actionInProgresHolder
|
|
227 |
translateLabel: true
|
|
228 |
labelChannel: infoHolder
|
|
229 |
adjust: left
|
|
230 |
)
|
|
231 |
(ProgressIndicatorSpec
|
|
232 |
name: 'ProgressIndicator'
|
|
233 |
layout: (LayoutFrame 210 0 -25 1 -215 1 -5 1)
|
|
234 |
visibilityChannel: actionInProgresHolder
|
|
235 |
model: progressHolder
|
|
236 |
)
|
|
237 |
(ActionButtonSpec
|
|
238 |
label: 'Search'
|
|
239 |
name: 'SearchButton'
|
|
240 |
layout: (LayoutFrame -210 1 -25 1 -110 1 -5 1)
|
|
241 |
translateLabel: true
|
|
242 |
model: doSearchAction
|
|
243 |
)
|
|
244 |
(ActionButtonSpec
|
|
245 |
label: 'Rewrite'
|
|
246 |
name: 'RewriteButton'
|
|
247 |
layout: (LayoutFrame -105 1 -25 1 -5 1 -5 1)
|
|
248 |
translateLabel: true
|
|
249 |
model: doRewriteAction
|
|
250 |
)
|
|
251 |
)
|
|
252 |
|
|
253 |
)
|
|
254 |
)
|
|
255 |
|
|
256 |
"Modified: / 12-12-2007 / 11:15:58 / janfrog"
|
|
257 |
!
|
|
258 |
|
|
259 |
templatesSpec
|
|
260 |
"This resource specification was automatically generated
|
|
261 |
by the UIPainter of ST/X."
|
|
262 |
|
|
263 |
"Do not manually edit this!! If it is corrupted,
|
|
264 |
the UIPainter may not be able to read the specification."
|
|
265 |
|
|
266 |
"
|
|
267 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#templatesSpec
|
|
268 |
Tools::MethodRewriter new openInterface:#templatesSpec
|
|
269 |
"
|
|
270 |
|
|
271 |
<resource: #canvas>
|
|
272 |
|
|
273 |
^
|
|
274 |
#(FullSpec
|
|
275 |
name: templatesSpec
|
|
276 |
window:
|
|
277 |
(WindowSpec
|
|
278 |
label: 'Method Rewriter'
|
|
279 |
name: 'Method Rewriter'
|
|
280 |
min: (Point 10 10)
|
|
281 |
bounds: (Rectangle 0 0 472 354)
|
|
282 |
)
|
|
283 |
component:
|
|
284 |
(SpecCollection
|
|
285 |
collection: (
|
|
286 |
(VariableVerticalPanelSpec
|
|
287 |
name: 'FindAndReplacePanel'
|
|
288 |
layout: (LayoutFrame 0 0 0 0 0 1 -30 1)
|
|
289 |
showHandle: true
|
|
290 |
snapMode: both
|
|
291 |
component:
|
|
292 |
(SpecCollection
|
|
293 |
collection: (
|
|
294 |
(SelectionInListModelViewSpec
|
|
295 |
name: 'SelectionInListModelView1'
|
|
296 |
model: selectedTemplateIndex
|
|
297 |
hasHorizontalScrollBar: true
|
|
298 |
hasVerticalScrollBar: true
|
|
299 |
listModel: templateNameList
|
|
300 |
highlightMode: line
|
|
301 |
)
|
|
302 |
(ViewSpec
|
|
303 |
name: 'FindBox'
|
|
304 |
component:
|
|
305 |
(SpecCollection
|
|
306 |
collection: (
|
|
307 |
(LabelSpec
|
|
308 |
label: 'Find:'
|
|
309 |
name: 'FindLabel'
|
|
310 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0)
|
|
311 |
translateLabel: true
|
|
312 |
adjust: left
|
|
313 |
)
|
|
314 |
(TextEditorSpec
|
|
315 |
name: 'FindText'
|
|
316 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1)
|
|
317 |
model: templateSearchPatternHolder
|
|
318 |
hasHorizontalScrollBar: true
|
|
319 |
hasVerticalScrollBar: true
|
|
320 |
)
|
|
321 |
)
|
|
322 |
|
|
323 |
)
|
|
324 |
)
|
|
325 |
(ViewSpec
|
|
326 |
name: 'ReplaceBox'
|
|
327 |
component:
|
|
328 |
(SpecCollection
|
|
329 |
collection: (
|
|
330 |
(LabelSpec
|
|
331 |
label: 'Replace with:'
|
|
332 |
name: 'ReplaceLabel'
|
|
333 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0)
|
|
334 |
translateLabel: true
|
|
335 |
adjust: left
|
|
336 |
)
|
|
337 |
(TextEditorSpec
|
|
338 |
name: 'ReplaceText'
|
|
339 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1)
|
|
340 |
model: templateReplacePatternHolder
|
|
341 |
hasHorizontalScrollBar: true
|
|
342 |
hasVerticalScrollBar: true
|
|
343 |
)
|
|
344 |
)
|
|
345 |
|
|
346 |
)
|
|
347 |
)
|
|
348 |
)
|
|
349 |
|
|
350 |
)
|
|
351 |
handles: (Any 0.2 0.6 1.0)
|
|
352 |
)
|
|
353 |
(ActionButtonSpec
|
|
354 |
label: 'Use as template'
|
|
355 |
name: 'UseAsTemplateButton'
|
|
356 |
layout: (LayoutFrame 0 0 -25 1 -5 1 -5 1)
|
|
357 |
translateLabel: true
|
|
358 |
model: useAsTemplateAction
|
|
359 |
)
|
|
360 |
)
|
|
361 |
|
|
362 |
)
|
|
363 |
)
|
|
364 |
|
|
365 |
"Modified: / 12-12-2007 / 11:23:34 / janfrog"
|
|
366 |
!
|
|
367 |
|
|
368 |
windowSpec
|
|
369 |
"This resource specification was automatically generated
|
|
370 |
by the UIPainter of ST/X."
|
|
371 |
|
|
372 |
"Do not manually edit this!! If it is corrupted,
|
|
373 |
the UIPainter may not be able to read the specification."
|
|
374 |
|
|
375 |
"
|
|
376 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#windowSpec
|
|
377 |
Tools::MethodRewriter new openInterface:#windowSpec
|
|
378 |
Tools::MethodRewriter open
|
|
379 |
"
|
|
380 |
|
|
381 |
<resource: #canvas>
|
|
382 |
|
|
383 |
^
|
|
384 |
#(FullSpec
|
|
385 |
name: windowSpec
|
|
386 |
window:
|
|
387 |
(WindowSpec
|
|
388 |
label: 'Method Rewriter'
|
|
389 |
name: 'Method Rewriter'
|
|
390 |
min: (Point 10 10)
|
|
391 |
bounds: (Rectangle 0 0 658 490)
|
|
392 |
)
|
|
393 |
component:
|
|
394 |
(SpecCollection
|
|
395 |
collection: (
|
|
396 |
(NoteBookViewSpec
|
|
397 |
name: 'NoteBook'
|
|
398 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
|
|
399 |
model: selectedTabIndex
|
|
400 |
menu: tabList
|
|
401 |
useIndex: true
|
|
402 |
fitLastRow: false
|
|
403 |
)
|
|
404 |
)
|
|
405 |
|
|
406 |
)
|
|
407 |
)
|
|
408 |
|
|
409 |
"Modified: / 12-12-2007 / 11:39:31 / janfrog"
|
|
410 |
! !
|
|
411 |
|
|
412 |
!MethodRewriter class methodsFor:'list specs'!
|
|
413 |
|
|
414 |
tabList
|
|
415 |
"This resource specification was automatically generated
|
|
416 |
by the TabListEditor of ST/X."
|
|
417 |
|
|
418 |
"Do not manually edit this!! If it is corrupted,
|
|
419 |
the TabListEditor may not be able to read the specification."
|
|
420 |
|
|
421 |
"
|
|
422 |
TabListEditor new openOnClass: self andSelector:#tabList
|
|
423 |
"
|
|
424 |
|
|
425 |
<resource: #tabList>
|
|
426 |
|
|
427 |
^ #(
|
|
428 |
(TabItem
|
|
429 |
label: 'Search and Replace'
|
|
430 |
createNewBuilder: false
|
|
431 |
minorKey: searchAndReplaceSpec
|
|
432 |
)
|
|
433 |
(TabItem
|
|
434 |
label: 'Classes'
|
|
435 |
createNewBuilder: false
|
|
436 |
minorKey: classesSpec
|
|
437 |
)
|
|
438 |
(TabItem
|
|
439 |
label: 'Templates'
|
|
440 |
createNewBuilder: false
|
|
441 |
minorKey: templatesSpec
|
|
442 |
)
|
|
443 |
)
|
|
444 |
|
|
445 |
collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ]
|
|
446 |
|
|
447 |
"Modified: / 12-12-2007 / 11:21:27 / janfrog"
|
|
448 |
! !
|
|
449 |
|
|
450 |
!MethodRewriter methodsFor:'accessing'!
|
|
451 |
|
|
452 |
actionInProgress: aBoolean
|
|
453 |
|
|
454 |
^self actionInProgresHolder value: aBoolean
|
|
455 |
|
|
456 |
"Created: / 12-12-2007 / 10:06:16 / janfrog"
|
|
457 |
!
|
|
458 |
|
|
459 |
classes
|
|
460 |
^ classes ifNil:[classes := List new]
|
|
461 |
|
|
462 |
"Created: / 20-07-2007 / 16:31:18 / janfrog"
|
|
463 |
!
|
|
464 |
|
|
465 |
classes: aCollection
|
|
466 |
classes := (aCollection collect:[:cls|cls theNonMetaclass]) asList
|
|
467 |
|
|
468 |
"Created: / 20-07-2007 / 16:31:18 / janfrog"
|
|
469 |
"Modified: / 12-12-2007 / 09:47:01 / janfrog"
|
|
470 |
!
|
|
471 |
|
|
472 |
info: aString
|
|
473 |
|
|
474 |
self infoHolder value: aString
|
|
475 |
|
|
476 |
"Created: / 12-12-2007 / 10:00:50 / janfrog"
|
|
477 |
!
|
|
478 |
|
|
479 |
progress: anInteger
|
|
480 |
|
|
481 |
self progressHolder value: anInteger
|
|
482 |
|
|
483 |
"Created: / 12-12-2007 / 10:01:03 / janfrog"
|
|
484 |
!
|
|
485 |
|
|
486 |
replacePattern
|
|
487 |
^ replaceTextView contents trimSeparators
|
|
488 |
|
|
489 |
"Created: / 21-07-2007 / 06:29:22 / janfrog"
|
|
490 |
!
|
|
491 |
|
|
492 |
replacePattern: pattern
|
|
493 |
^ replaceTextView contents: pattern trimSeparators
|
|
494 |
|
|
495 |
"Created: / 12-12-2007 / 11:38:22 / janfrog"
|
|
496 |
!
|
|
497 |
|
|
498 |
searchPattern
|
|
499 |
^ searchTextView contents trimSeparators
|
|
500 |
|
|
501 |
"Created: / 20-07-2007 / 16:51:49 / janfrog"
|
|
502 |
"Modified: / 21-07-2007 / 06:29:29 / janfrog"
|
|
503 |
!
|
|
504 |
|
|
505 |
searchPattern: pattern
|
|
506 |
^ searchTextView contents: pattern trimSeparators
|
|
507 |
|
|
508 |
"Created: / 12-12-2007 / 11:38:12 / janfrog"
|
|
509 |
!
|
|
510 |
|
|
511 |
selectedClasses
|
|
512 |
|
|
513 |
^self selectedClassesHolder value
|
|
514 |
|
|
515 |
"Created: / 12-12-2007 / 12:02:03 / janfrog"
|
|
516 |
!
|
|
517 |
|
|
518 |
selectedTemplate
|
|
519 |
|
|
520 |
^self templates at:self selectedTemplateIndex value
|
|
521 |
|
|
522 |
"Created: / 12-12-2007 / 11:20:32 / janfrog"
|
|
523 |
!
|
|
524 |
|
|
525 |
templates
|
|
526 |
templates isNil ifTrue:[
|
|
527 |
templates := self class templates.
|
|
528 |
].
|
|
529 |
^ templates
|
|
530 |
|
|
531 |
"Created: / 12-12-2007 / 11:17:55 / janfrog"
|
|
532 |
! !
|
|
533 |
|
|
534 |
!MethodRewriter methodsFor:'actions'!
|
|
535 |
|
|
536 |
doRewrite
|
|
537 |
|
|
538 |
| methodsMatching |
|
|
539 |
methodsMatching := self methodsMatching.
|
|
540 |
methodsMatching isNilOrEmptyCollection ifTrue:[^Dialog warn:'No methods matching'].
|
|
541 |
methodsMatching do:
|
|
542 |
[:mth|
|
|
543 |
| newTree |
|
|
544 |
newTree := ParseTreeRewriter new
|
|
545 |
replace: self searchPattern with: self replacePattern;
|
|
546 |
executeTree: mth parseTree;
|
|
547 |
tree.
|
|
548 |
mth mclass
|
|
549 |
compile: newTree formattedCode
|
|
550 |
classified: mth category
|
|
551 |
].
|
|
552 |
|
|
553 |
"Created: / 20-07-2007 / 16:03:47 / janfrog"
|
|
554 |
"Modified: / 21-07-2007 / 06:55:42 / janfrog"
|
|
555 |
!
|
|
556 |
|
|
557 |
doRewriteAction
|
|
558 |
|
|
559 |
self
|
|
560 |
doSearch: self searchPattern
|
|
561 |
withResultDo:
|
|
562 |
[:methodsMatching|
|
|
563 |
self
|
|
564 |
withMethods:methodsMatching
|
|
565 |
do:
|
|
566 |
[:mth|
|
|
567 |
| newTree |
|
|
568 |
newTree := ParseTreeRewriter new
|
|
569 |
replace: self searchPattern with: self replacePattern;
|
|
570 |
executeTree: mth parseTree;
|
|
571 |
tree.
|
|
572 |
mth mclass ifNotNil:
|
|
573 |
[mth mclass
|
|
574 |
compile: newTree formattedCode
|
|
575 |
classified: mth category]]
|
|
576 |
finallyDo:[]]
|
|
577 |
|
|
578 |
"Created: / 12-12-2007 / 11:14:19 / janfrog"
|
|
579 |
!
|
|
580 |
|
|
581 |
doSearch
|
|
582 |
|methods|
|
|
583 |
|
|
584 |
methods := self methodsMatching.
|
|
585 |
methods isEmpty
|
|
586 |
ifTrue:
|
|
587 |
[Dialog warn:'Nothing found']
|
|
588 |
ifFalse:
|
|
589 |
[self showMethods:methods
|
|
590 |
title:'Methods matching ' , self searchPattern]
|
|
591 |
|
|
592 |
"Created: / 20-07-2007 / 16:08:08 / janfrog"
|
|
593 |
"Modified: / 21-07-2007 / 06:51:58 / janfrog"
|
|
594 |
!
|
|
595 |
|
|
596 |
doSearchAction
|
|
597 |
|
|
598 |
self
|
|
599 |
doSearch: self searchPattern
|
|
600 |
withResultDo:
|
|
601 |
[:matchingMethods|
|
|
602 |
matchingMethods isEmpty
|
|
603 |
ifTrue:[Dialog warn:'No methods found']
|
|
604 |
ifFalse:
|
|
605 |
[self
|
|
606 |
showMethods: matchingMethods asArray
|
|
607 |
title: 'Methods matching ', self searchPattern]]
|
|
608 |
|
|
609 |
"Created: / 12-12-2007 / 11:14:25 / janfrog"
|
|
610 |
!
|
|
611 |
|
|
612 |
removeSeletedClassesAction
|
|
613 |
|
|
614 |
self classes removeAll: self selectedClasses
|
|
615 |
|
|
616 |
"Created: / 12-12-2007 / 12:05:15 / janfrog"
|
|
617 |
!
|
|
618 |
|
|
619 |
useAsTemplateAction
|
|
620 |
|
|
621 |
self searchPattern: self templateSearchPatternHolder value.
|
|
622 |
self replacePattern: self templateReplacePatternHolder value.
|
|
623 |
self selectedTabIndex value:1
|
|
624 |
|
|
625 |
"Created: / 12-12-2007 / 11:14:15 / janfrog"
|
|
626 |
! !
|
|
627 |
|
|
628 |
!MethodRewriter methodsFor:'aspects'!
|
|
629 |
|
|
630 |
actionInProgresHolder
|
|
631 |
"automatically generated by UIPainter ..."
|
|
632 |
|
|
633 |
"*** the code below creates a default model when invoked."
|
|
634 |
"*** (which may not be the one you wanted)"
|
|
635 |
"*** Please change as required and accept it in the browser."
|
|
636 |
"*** (and replace this comment by something more useful ;-)"
|
|
637 |
|
|
638 |
actionInProgresHolder isNil ifTrue:[
|
|
639 |
actionInProgresHolder := true asValue.
|
|
640 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
641 |
"/ actionInProgresHolder addDependent:self.
|
|
642 |
"/ actionInProgresHolder onChangeSend:#actionInProgresHolderChanged to:self.
|
|
643 |
].
|
|
644 |
^ actionInProgresHolder.
|
|
645 |
|
|
646 |
"Created: / 12-12-2007 / 10:00:05 / janfrog"
|
|
647 |
!
|
|
648 |
|
|
649 |
infoHolder
|
|
650 |
"automatically generated by UIPainter ..."
|
|
651 |
|
|
652 |
"*** the code below creates a default model when invoked."
|
|
653 |
"*** (which may not be the one you wanted)"
|
|
654 |
"*** Please change as required and accept it in the browser."
|
|
655 |
"*** (and replace this comment by something more useful ;-)"
|
|
656 |
|
|
657 |
infoHolder isNil ifTrue:[
|
|
658 |
infoHolder := 'Really cool tool!!' asValue.
|
|
659 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
660 |
"/ infoHolder addDependent:self.
|
|
661 |
"/ infoHolder onChangeSend:#infoHolderChanged to:self.
|
|
662 |
].
|
|
663 |
^ infoHolder.
|
|
664 |
|
|
665 |
"Created: / 12-12-2007 / 10:00:05 / janfrog"
|
|
666 |
"Modified: / 12-12-2007 / 11:40:17 / janfrog"
|
|
667 |
!
|
|
668 |
|
|
669 |
progressHolder
|
|
670 |
"automatically generated by UIPainter ..."
|
|
671 |
|
|
672 |
"*** the code below creates a default model when invoked."
|
|
673 |
"*** (which may not be the one you wanted)"
|
|
674 |
"*** Please change as required and accept it in the browser."
|
|
675 |
"*** (and replace this comment by something more useful ;-)"
|
|
676 |
|
|
677 |
progressHolder isNil ifTrue:[
|
|
678 |
progressHolder := 0 asValue
|
|
679 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
680 |
"/ progressHolder addDependent:self.
|
|
681 |
"/ progressHolder onChangeSend:#progressHolderChanged to:self.
|
|
682 |
].
|
|
683 |
^ progressHolder.
|
|
684 |
|
|
685 |
"Created: / 12-12-2007 / 10:00:05 / janfrog"
|
|
686 |
!
|
|
687 |
|
|
688 |
selectedClassesHolder
|
|
689 |
"automatically generated by UIPainter ..."
|
|
690 |
|
|
691 |
"*** the code below creates a default model when invoked."
|
|
692 |
"*** (which may not be the one you wanted)"
|
|
693 |
"*** Please change as required and accept it in the browser."
|
|
694 |
"*** (and replace this comment by something more useful ;-)"
|
|
695 |
|
|
696 |
selectedClassesHolder isNil ifTrue:[
|
|
697 |
selectedClassesHolder := ValueHolder new.
|
|
698 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
699 |
"/ selectedClassesHolder addDependent:self.
|
|
700 |
"/ selectedClassesHolder onChangeSend:#selectedClassesHolderChanged to:self.
|
|
701 |
].
|
|
702 |
^ selectedClassesHolder.
|
|
703 |
|
|
704 |
"Created: / 12-12-2007 / 12:01:40 / janfrog"
|
|
705 |
!
|
|
706 |
|
|
707 |
selectedTabIndex
|
|
708 |
"automatically generated by UIPainter ..."
|
|
709 |
|
|
710 |
"*** the code below creates a default model when invoked."
|
|
711 |
"*** (which may not be the one you wanted)"
|
|
712 |
"*** Please change as required and accept it in the browser."
|
|
713 |
"*** (and replace this comment by something more useful ;-)"
|
|
714 |
|
|
715 |
selectedTabIndex isNil ifTrue:[
|
|
716 |
selectedTabIndex := ValueHolder new.
|
|
717 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
718 |
"/ selectedTabIndex addDependent:self.
|
|
719 |
"/ selectedTabIndex onChangeSend:#selectedTabIndexChanged to:self.
|
|
720 |
].
|
|
721 |
^ selectedTabIndex.
|
|
722 |
|
|
723 |
"Created: / 12-12-2007 / 11:39:29 / janfrog"
|
|
724 |
!
|
|
725 |
|
|
726 |
selectedTemplateIndex
|
|
727 |
|
|
728 |
selectedTemplateIndex isNil ifTrue:[
|
|
729 |
selectedTemplateIndex := ValueHolder new.
|
|
730 |
selectedTemplateIndex onChangeSend:#selectedTemplateIndexChanged to:self.
|
|
731 |
].
|
|
732 |
^ selectedTemplateIndex.
|
|
733 |
|
|
734 |
"Created: / 12-12-2007 / 11:17:16 / janfrog"
|
|
735 |
!
|
|
736 |
|
|
737 |
tabList
|
|
738 |
"Generated by the TabListEditor"
|
|
739 |
|
|
740 |
|list|
|
|
741 |
|
|
742 |
(list := builder bindingAt:#tabList) isNil ifTrue:[
|
|
743 |
builder aspectAt:#tabList put:(list := self class tabList).
|
|
744 |
].
|
|
745 |
^ list
|
|
746 |
|
|
747 |
"Created: / 20-07-2007 / 16:54:27 / janfrog"
|
|
748 |
!
|
|
749 |
|
|
750 |
templateNameList
|
|
751 |
|
|
752 |
^self templates collect:[:tmpl|tmpl first]
|
|
753 |
|
|
754 |
"Created: / 12-12-2007 / 11:17:16 / janfrog"
|
|
755 |
!
|
|
756 |
|
|
757 |
templateReplacePatternHolder
|
|
758 |
"automatically generated by UIPainter ..."
|
|
759 |
|
|
760 |
"*** the code below creates a default model when invoked."
|
|
761 |
"*** (which may not be the one you wanted)"
|
|
762 |
"*** Please change as required and accept it in the browser."
|
|
763 |
"*** (and replace this comment by something more useful ;-)"
|
|
764 |
|
|
765 |
templateReplacePatternHolder isNil ifTrue:[
|
|
766 |
templateReplacePatternHolder := '' asValue.
|
|
767 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
768 |
"/ templateReplacePatternHolder addDependent:self.
|
|
769 |
"/ templateReplacePatternHolder onChangeSend:#templateReplacePatternHolderChanged to:self.
|
|
770 |
].
|
|
771 |
^ templateReplacePatternHolder.
|
|
772 |
|
|
773 |
"Created: / 12-12-2007 / 11:17:16 / janfrog"
|
|
774 |
!
|
|
775 |
|
|
776 |
templateSearchPatternHolder
|
|
777 |
"automatically generated by UIPainter ..."
|
|
778 |
|
|
779 |
"*** the code below creates a default model when invoked."
|
|
780 |
"*** (which may not be the one you wanted)"
|
|
781 |
"*** Please change as required and accept it in the browser."
|
|
782 |
"*** (and replace this comment by something more useful ;-)"
|
|
783 |
|
|
784 |
templateSearchPatternHolder isNil ifTrue:[
|
|
785 |
templateSearchPatternHolder := '' asValue.
|
|
786 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
787 |
"/ templateSearchPatternHolder addDependent:self.
|
|
788 |
"/ templateSearchPatternHolder onChangeSend:#templateSearchPatternHolderChanged to:self.
|
|
789 |
].
|
|
790 |
^ templateSearchPatternHolder.
|
|
791 |
|
|
792 |
"Created: / 12-12-2007 / 11:17:16 / janfrog"
|
|
793 |
! !
|
|
794 |
|
|
795 |
!MethodRewriter methodsFor:'change & update'!
|
|
796 |
|
|
797 |
selectedTemplateIndexChanged
|
|
798 |
|
|
799 |
self templateSearchPatternHolder value: self selectedTemplate second.
|
|
800 |
self templateReplacePatternHolder value: self selectedTemplate third.
|
|
801 |
|
|
802 |
"Created: / 12-12-2007 / 11:20:16 / janfrog"
|
|
803 |
! !
|
|
804 |
|
|
805 |
!MethodRewriter methodsFor:'drag & drop'!
|
|
806 |
|
|
807 |
canDropClasses: dropContext
|
|
808 |
|
|
809 |
^dropContext dropObjects allSatisfy: [:obj|obj isClassObject]
|
|
810 |
|
|
811 |
"Created: / 20-07-2007 / 16:58:13 / janfrog"
|
|
812 |
!
|
|
813 |
|
|
814 |
doDropClasses: dropContext
|
|
815 |
|
|
816 |
| newClasses |
|
|
817 |
newClasses := dropContext dropObjects
|
|
818 |
select:[:obj|obj isClassObject]
|
|
819 |
thenCollect:[:obj|obj theObject].
|
|
820 |
newClasses := newClasses reject:[:cls|self classes includes:cls].
|
|
821 |
self classes
|
|
822 |
addAll: newClasses;
|
|
823 |
changed:#content
|
|
824 |
|
|
825 |
"Created: / 20-07-2007 / 16:58:16 / janfrog"
|
|
826 |
! !
|
|
827 |
|
|
828 |
!MethodRewriter methodsFor:'hooks'!
|
|
829 |
|
|
830 |
postBuildFindTextView: scrollableView
|
|
831 |
|
|
832 |
searchTextView := scrollableView scrolledView
|
|
833 |
|
|
834 |
"Created: / 20-07-2007 / 15:55:16 / janfrog"
|
|
835 |
!
|
|
836 |
|
|
837 |
postBuildReplaceTextView: scrollableView
|
|
838 |
|
|
839 |
replaceTextView := scrollableView scrolledView
|
|
840 |
|
|
841 |
"Created: / 20-07-2007 / 15:55:29 / janfrog"
|
|
842 |
! !
|
|
843 |
|
|
844 |
!MethodRewriter methodsFor:'private'!
|
|
845 |
|
|
846 |
doSearch: pattern withResultDo: block
|
|
847 |
|
|
848 |
| matchingMethods |
|
|
849 |
matchingMethods := Set new.
|
|
850 |
self
|
|
851 |
withMethodsDo:
|
|
852 |
[:mth|
|
|
853 |
(ParseTreeSearcher new)
|
|
854 |
matches:self searchPattern do:[:aNode :answer | matchingMethods add:mth ];
|
|
855 |
executeTree:mth parseTree]
|
|
856 |
finallyDo:
|
|
857 |
[block value: matchingMethods]
|
|
858 |
|
|
859 |
"Created: / 12-12-2007 / 10:34:50 / janfrog"
|
|
860 |
!
|
|
861 |
|
|
862 |
methods
|
|
863 |
|
|
864 |
^self methodsFor: classes
|
|
865 |
|
|
866 |
"Modified: / 21-07-2007 / 06:24:07 / janfrog"
|
|
867 |
!
|
|
868 |
|
|
869 |
methodsFor: aColletion
|
|
870 |
|
|
871 |
^classes
|
|
872 |
inject: Set new
|
|
873 |
into:
|
|
874 |
[:methods :cls|
|
|
875 |
methods
|
|
876 |
addAll: cls methodDictionary values;
|
|
877 |
addAll: cls class methodDictionary values;
|
|
878 |
yourself]
|
|
879 |
|
|
880 |
"Created: / 21-07-2007 / 06:25:42 / janfrog"
|
|
881 |
!
|
|
882 |
|
|
883 |
methodsMatching
|
|
884 |
|
|
885 |
^self methodsMatching: self searchPattern
|
|
886 |
|
|
887 |
"Created: / 21-07-2007 / 06:26:44 / janfrog"
|
|
888 |
!
|
|
889 |
|
|
890 |
methodsMatching: searchPattern
|
|
891 |
|matchingMethods|
|
|
892 |
|
|
893 |
matchingMethods := OrderedCollection new.
|
|
894 |
self methods do:[:mth |
|
|
895 |
(ParseTreeSearcher new)
|
|
896 |
matches:searchPattern do:[:aNode :answer | matchingMethods add:mth ];
|
|
897 |
executeTree:mth parseTree.
|
|
898 |
].
|
|
899 |
^ matchingMethods
|
|
900 |
|
|
901 |
"Created: / 21-07-2007 / 06:26:19 / janfrog"
|
|
902 |
!
|
|
903 |
|
|
904 |
showMethods: methods title: title
|
|
905 |
|
|
906 |
NewSystemBrowser
|
|
907 |
browseMethods:methods
|
|
908 |
title:title
|
|
909 |
sort:true
|
|
910 |
|
|
911 |
"Created: / 21-07-2007 / 06:51:36 / janfrog"
|
|
912 |
!
|
|
913 |
|
|
914 |
withMethods: methods do: methodBlock finallyDo: finallyBlock
|
|
915 |
|
|
916 |
[
|
|
917 |
self actionInProgress: true.
|
|
918 |
methods asArray keysAndValuesDo:
|
|
919 |
[:idx :mth|
|
|
920 |
self info: mth selector storeString.
|
|
921 |
methodBlock value: mth.
|
|
922 |
self progress: ((100 / methods size) * idx) rounded].
|
|
923 |
finallyBlock value
|
|
924 |
] ensure:[
|
|
925 |
"/self actionInProgress: false.
|
|
926 |
self progress: 0.
|
|
927 |
self info: ''
|
|
928 |
]
|
|
929 |
|
|
930 |
"Created: / 12-12-2007 / 10:32:16 / janfrog"
|
|
931 |
!
|
|
932 |
|
|
933 |
withMethodsDo: methodBlock finallyDo: finallyBlock
|
|
934 |
|
|
935 |
^self
|
|
936 |
withMethods: self methods asArray
|
|
937 |
do: methodBlock
|
|
938 |
finallyDo: finallyBlock
|
|
939 |
|
|
940 |
"Modified: / 12-12-2007 / 10:32:48 / janfrog"
|
|
941 |
! !
|
|
942 |
|
|
943 |
!MethodRewriter methodsFor:'testing method'!
|
|
944 |
|
|
945 |
testXXX
|
|
946 |
self halt:'Was halt'
|
|
947 |
|
|
948 |
"Created: / 21-07-2007 / 07:55:24 / janfrog"
|
|
949 |
"Modified: / 12-12-2007 / 10:45:20 / janfrog"
|
|
950 |
! !
|
|
951 |
|
|
952 |
!MethodRewriter class methodsFor:'documentation'!
|
|
953 |
|
|
954 |
version
|
8817
|
955 |
^ '$Header: /cvs/stx/stx/libtool/Tools__MethodRewriter.st,v 1.3 2009-09-30 12:09:31 fm Exp $'
|
8803
|
956 |
!
|
|
957 |
|
|
958 |
version_CVS
|
8817
|
959 |
^ '$Header: /cvs/stx/stx/libtool/Tools__MethodRewriter.st,v 1.3 2009-09-30 12:09:31 fm Exp $'
|
8803
|
960 |
!
|
|
961 |
|
8817
|
962 |
version_CVS_jvrany
|
8803
|
963 |
^ 'Header: /opt/data/cvs/stx/goodies/libtool3/Tools__MethodRewriter.st,v 1.3 2008-02-17 10:12:04 vranyj1 Exp '
|
8776
|
964 |
! !
|