author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 07 Sep 2012 18:28:09 +0100 | |
branch | jv |
changeset 12287 | 400a99059170 |
parent 12207 | 17656fc80e6c |
child 12401 | 4714b9640528 |
permissions | -rw-r--r-- |
9988 | 1 |
" |
10097 | 2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
9988 | 4 |
|
10097 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9988 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
8776 | 27 |
|
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
ApplicationModel subclass:#MethodRewriter |
|
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
31 |
instanceVariableNames:'replaceTextView methods classes searchTextView |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
32 |
actionInProgresHolder infoHolder progressHolder |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
33 |
templateSearchPatternHolder templateReplacePatternHolder |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
34 |
selectedTemplateIndex templates selectedTabIndex |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
35 |
selectedClassesHolder' |
10126 | 36 |
classVariableNames:'' |
37 |
poolDictionaries:'' |
|
38 |
category:'Interface-MethodRewriter' |
|
8776 | 39 |
! |
40 |
||
9988 | 41 |
!MethodRewriter class methodsFor:'documentation'! |
42 |
||
43 |
copyright |
|
44 |
" |
|
10097 | 45 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
46 |
Copyright (c) 2009-2010 eXept Software AG |
|
47 |
||
48 |
Permission is hereby granted, free of charge, to any person |
|
49 |
obtaining a copy of this software and associated documentation |
|
50 |
files (the 'Software'), to deal in the Software without |
|
51 |
restriction, including without limitation the rights to use, |
|
52 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
53 |
copies of the Software, and to permit persons to whom the |
|
54 |
Software is furnished to do so, subject to the following |
|
55 |
conditions: |
|
9988 | 56 |
|
10097 | 57 |
The above copyright notice and this permission notice shall be |
58 |
included in all copies or substantial portions of the Software. |
|
59 |
||
60 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
61 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
62 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
63 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
64 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
65 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
66 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
67 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9988 | 68 |
" |
69 |
! ! |
|
8776 | 70 |
|
10126 | 71 |
!MethodRewriter class methodsFor:'example templates'! |
8776 | 72 |
|
73 |
templateReplaceAtIfAbsentByAtAifAbsentPut |
|
74 |
||
75 |
^Array |
|
10126 | 76 |
with:('Replace ','Dictionary>>#at:ifAbsent:'allBold,' by ','#at:ifAbsentPut:' allBold) |
8776 | 77 |
with: '``@dictionary |
78 |
at: ``@key |
|
79 |
ifAbsent: |
|
80 |
[| `@temps | |
|
81 |
`@.statements. |
|
82 |
``@dictionary at: ``@key put: ``@object]' |
|
83 |
with:'``@dictionary |
|
84 |
at: ``@key |
|
85 |
ifAbsentPut: |
|
86 |
[| `@temps | |
|
87 |
`@.statements. |
|
88 |
``@object]' |
|
89 |
||
90 |
"Created: / 12-12-2007 / 11:08:01 / janfrog" |
|
91 |
"Modified: / 17-02-2008 / 08:35:17 / janfrog" |
|
10126 | 92 |
"Modified: / 04-07-2011 / 17:41:21 / cg" |
8776 | 93 |
! |
94 |
||
10140
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
95 |
templateReplaceIfNilByIsNilIfTrue |
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
96 |
|
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
97 |
^Array |
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
98 |
with:('Replace ','ifNil:' allBold,' by ','isNil ifTrue:' allBold) |
10153 | 99 |
with: '``@receiver ifNil: ``@block' |
100 |
with: '``@receiver isNil ifTrue: ``@block' |
|
10140
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
101 |
|
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
102 |
"Created: / 04-07-2011 / 19:25:06 / cg" |
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
103 |
! |
2df2dde55877
added: #templateReplaceIfNilByIsNilIfTrue
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
104 |
|
10111
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
105 |
templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil |
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
106 |
|
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
107 |
^Array |
10126 | 108 |
with:('Replace ','isNilOrEmptyCollection' allBold,' by ','isEmptyOrNil' allBold) |
10153 | 109 |
with: '``@receiver isNilOrEmptyCollection' |
110 |
with: '``@receiver isEmptyOrNil''' |
|
10111
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
111 |
|
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
112 |
"Created: / 03-07-2011 / 21:59:47 / cg" |
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
113 |
! |
97f2db2aca32
added: #templateReplaceIsNilOrEmptyCollectionByIsEmptyOrNil
Claus Gittinger <cg@exept.de>
parents:
10110
diff
changeset
|
114 |
|
10128
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
115 |
templateReplaceSelfHaltBySelfBreakPoint |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
116 |
|initials| |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
117 |
|
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
118 |
initials := OperatingSystem getLoginName. |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
119 |
|
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
120 |
^Array |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
121 |
with:('Replace ','self halt' allBold,' by ','self breakPoint: #' allBold ,initials) |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
122 |
with: 'self halt' |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
123 |
with: 'self breakPoint: #',initials |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
124 |
|
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
125 |
"Modified: / 17-02-2008 / 08:35:09 / janfrog" |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
126 |
"Created: / 04-07-2011 / 17:43:46 / cg" |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
127 |
! |
4bd98e161a68
added: #templateReplaceSelfHaltBySelfBreakPoint
Claus Gittinger <cg@exept.de>
parents:
10126
diff
changeset
|
128 |
|
8776 | 129 |
templateReplaceSelfHaltBySelfError |
130 |
||
131 |
^Array |
|
10126 | 132 |
with:('Replace ','self halt'allBold,' by ','self error:''was: self halt''' allBold) |
8776 | 133 |
with: 'self halt' |
134 |
with: 'self error:''was: self error''' |
|
135 |
||
136 |
"Created: / 12-12-2007 / 11:29:51 / janfrog" |
|
137 |
"Modified: / 17-02-2008 / 08:35:09 / janfrog" |
|
10126 | 138 |
"Modified: / 04-07-2011 / 17:41:33 / cg" |
8776 | 139 |
! |
140 |
||
141 |
templates |
|
142 |
||
143 |
|templateSelectors| |
|
144 |
||
145 |
templateSelectors := |
|
146 |
(self class selectors select:[:e|(e startsWith:'template') |
|
147 |
and:[e ~= #templates and:[e ~= #templatesSpec]]]). |
|
148 |
^templateSelectors |
|
149 |
collect:[:e|self perform:e] |
|
150 |
||
151 |
" |
|
152 |
self templates |
|
153 |
" |
|
154 |
||
155 |
"Created: / 12-12-2007 / 11:03:32 / janfrog" |
|
156 |
! ! |
|
157 |
||
158 |
!MethodRewriter class methodsFor:'interface specs'! |
|
159 |
||
160 |
classesSpec |
|
161 |
"This resource specification was automatically generated |
|
162 |
by the UIPainter of ST/X." |
|
163 |
||
164 |
"Do not manually edit this!! If it is corrupted, |
|
165 |
the UIPainter may not be able to read the specification." |
|
166 |
||
167 |
" |
|
168 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#classesSpec |
|
169 |
Tools::MethodRewriter new openInterface:#classesSpec |
|
170 |
" |
|
171 |
||
172 |
<resource: #canvas> |
|
173 |
||
174 |
^ |
|
175 |
#(FullSpec |
|
176 |
name: classesSpec |
|
177 |
window: |
|
178 |
(WindowSpec |
|
179 |
label: 'Classes' |
|
180 |
name: 'Classes' |
|
181 |
min: (Point 10 10) |
|
182 |
bounds: (Rectangle 0 0 300 300) |
|
183 |
) |
|
184 |
component: |
|
185 |
(SpecCollection |
|
186 |
collection: ( |
|
187 |
(LabelSpec |
|
188 |
label: 'Hint: drag''n''drop classes from browser' |
|
189 |
name: 'HintLabel' |
|
190 |
layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
|
191 |
translateLabel: true |
|
192 |
adjust: left |
|
193 |
) |
|
194 |
(SelectionInListModelViewSpec |
|
195 |
name: 'ClassesList' |
|
196 |
layout: (LayoutFrame 0 0 30 0 0 1 -30 1) |
|
197 |
model: selectedClassesHolder |
|
198 |
hasHorizontalScrollBar: true |
|
199 |
hasVerticalScrollBar: true |
|
200 |
listModel: classes |
|
201 |
multipleSelectOk: true |
|
202 |
useIndex: false |
|
203 |
highlightMode: line |
|
204 |
properties: |
|
205 |
(PropertyListDictionary |
|
206 |
dragArgument: nil |
|
207 |
dropArgument: nil |
|
208 |
canDropSelector: canDropClasses: |
|
209 |
dropSelector: doDropClasses: |
|
210 |
) |
|
211 |
) |
|
212 |
(ActionButtonSpec |
|
213 |
label: 'Remove selected classes' |
|
214 |
name: 'RemoveClassesButton' |
|
215 |
layout: (LayoutFrame 5 0 -25 1 -5 1 -5 1) |
|
216 |
translateLabel: true |
|
217 |
model: removeSeletedClassesAction |
|
218 |
) |
|
219 |
) |
|
220 |
||
221 |
) |
|
222 |
) |
|
223 |
||
224 |
"Modified: / 12-12-2007 / 12:07:17 / janfrog" |
|
225 |
! |
|
226 |
||
227 |
searchAndReplaceSpec |
|
228 |
"This resource specification was automatically generated |
|
229 |
by the UIPainter of ST/X." |
|
230 |
||
231 |
"Do not manually edit this!! If it is corrupted, |
|
232 |
the UIPainter may not be able to read the specification." |
|
233 |
||
234 |
" |
|
235 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#searchAndReplaceSpec |
|
236 |
Tools::MethodRewriter new openInterface:#searchAndReplaceSpec |
|
237 |
" |
|
238 |
||
239 |
<resource: #canvas> |
|
240 |
||
241 |
^ |
|
242 |
#(FullSpec |
|
243 |
name: searchAndReplaceSpec |
|
244 |
window: |
|
245 |
(WindowSpec |
|
246 |
label: 'Method Rewriter' |
|
247 |
name: 'Method Rewriter' |
|
248 |
min: (Point 10 10) |
|
249 |
bounds: (Rectangle 0 0 418 294) |
|
250 |
) |
|
251 |
component: |
|
252 |
(SpecCollection |
|
253 |
collection: ( |
|
254 |
(VariableVerticalPanelSpec |
|
255 |
name: 'FindAndReplacePanel' |
|
256 |
layout: (LayoutFrame 0 0 0 0 0 1 -30 1) |
|
257 |
showHandle: true |
|
258 |
snapMode: both |
|
259 |
component: |
|
260 |
(SpecCollection |
|
261 |
collection: ( |
|
262 |
(ViewSpec |
|
263 |
name: 'FindBox' |
|
264 |
component: |
|
265 |
(SpecCollection |
|
266 |
collection: ( |
|
267 |
(LabelSpec |
|
268 |
label: 'Find:' |
|
269 |
name: 'FindLabel' |
|
270 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0) |
|
271 |
translateLabel: true |
|
272 |
adjust: left |
|
273 |
) |
|
274 |
(TextEditorSpec |
|
275 |
name: 'FindText' |
|
276 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1) |
|
277 |
hasHorizontalScrollBar: true |
|
278 |
hasVerticalScrollBar: true |
|
279 |
postBuildCallback: postBuildFindTextView: |
|
280 |
) |
|
281 |
) |
|
282 |
||
283 |
) |
|
284 |
) |
|
285 |
(ViewSpec |
|
286 |
name: 'ReplaceBox' |
|
287 |
component: |
|
288 |
(SpecCollection |
|
289 |
collection: ( |
|
290 |
(LabelSpec |
|
291 |
label: 'Replace with:' |
|
292 |
name: 'ReplaceLabel' |
|
293 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0) |
|
294 |
translateLabel: true |
|
295 |
adjust: left |
|
296 |
) |
|
297 |
(TextEditorSpec |
|
298 |
name: 'ReplaceText' |
|
299 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1) |
|
300 |
hasHorizontalScrollBar: true |
|
301 |
hasVerticalScrollBar: true |
|
302 |
postBuildCallback: postBuildReplaceTextView: |
|
303 |
) |
|
304 |
) |
|
305 |
||
306 |
) |
|
307 |
) |
|
308 |
) |
|
309 |
||
310 |
) |
|
311 |
handles: (Any 0.5 1.0) |
|
312 |
) |
|
313 |
(LabelSpec |
|
314 |
label: 'Enjoy' |
|
315 |
name: 'InfoLabel' |
|
316 |
layout: (LayoutFrame 5 0 -25 1 205 0 -5 1) |
|
317 |
visibilityChannel: actionInProgresHolder |
|
318 |
translateLabel: true |
|
319 |
labelChannel: infoHolder |
|
320 |
adjust: left |
|
321 |
) |
|
322 |
(ProgressIndicatorSpec |
|
323 |
name: 'ProgressIndicator' |
|
324 |
layout: (LayoutFrame 210 0 -25 1 -215 1 -5 1) |
|
325 |
visibilityChannel: actionInProgresHolder |
|
326 |
model: progressHolder |
|
327 |
) |
|
328 |
(ActionButtonSpec |
|
329 |
label: 'Search' |
|
330 |
name: 'SearchButton' |
|
331 |
layout: (LayoutFrame -210 1 -25 1 -110 1 -5 1) |
|
332 |
translateLabel: true |
|
333 |
model: doSearchAction |
|
334 |
) |
|
335 |
(ActionButtonSpec |
|
336 |
label: 'Rewrite' |
|
337 |
name: 'RewriteButton' |
|
338 |
layout: (LayoutFrame -105 1 -25 1 -5 1 -5 1) |
|
339 |
translateLabel: true |
|
340 |
model: doRewriteAction |
|
341 |
) |
|
342 |
) |
|
343 |
||
344 |
) |
|
345 |
) |
|
346 |
||
347 |
"Modified: / 12-12-2007 / 11:15:58 / janfrog" |
|
348 |
! |
|
349 |
||
350 |
templatesSpec |
|
351 |
"This resource specification was automatically generated |
|
352 |
by the UIPainter of ST/X." |
|
353 |
||
354 |
"Do not manually edit this!! If it is corrupted, |
|
355 |
the UIPainter may not be able to read the specification." |
|
356 |
||
357 |
" |
|
358 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#templatesSpec |
|
359 |
Tools::MethodRewriter new openInterface:#templatesSpec |
|
360 |
" |
|
361 |
||
362 |
<resource: #canvas> |
|
363 |
||
364 |
^ |
|
365 |
#(FullSpec |
|
366 |
name: templatesSpec |
|
367 |
window: |
|
368 |
(WindowSpec |
|
369 |
label: 'Method Rewriter' |
|
370 |
name: 'Method Rewriter' |
|
371 |
min: (Point 10 10) |
|
372 |
bounds: (Rectangle 0 0 472 354) |
|
373 |
) |
|
374 |
component: |
|
375 |
(SpecCollection |
|
376 |
collection: ( |
|
377 |
(VariableVerticalPanelSpec |
|
378 |
name: 'FindAndReplacePanel' |
|
379 |
layout: (LayoutFrame 0 0 0 0 0 1 -30 1) |
|
380 |
showHandle: true |
|
381 |
snapMode: both |
|
382 |
component: |
|
383 |
(SpecCollection |
|
384 |
collection: ( |
|
385 |
(SelectionInListModelViewSpec |
|
386 |
name: 'SelectionInListModelView1' |
|
387 |
model: selectedTemplateIndex |
|
388 |
hasHorizontalScrollBar: true |
|
389 |
hasVerticalScrollBar: true |
|
390 |
listModel: templateNameList |
|
391 |
highlightMode: line |
|
392 |
) |
|
393 |
(ViewSpec |
|
394 |
name: 'FindBox' |
|
395 |
component: |
|
396 |
(SpecCollection |
|
397 |
collection: ( |
|
398 |
(LabelSpec |
|
399 |
label: 'Find:' |
|
400 |
name: 'FindLabel' |
|
401 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0) |
|
402 |
translateLabel: true |
|
403 |
adjust: left |
|
404 |
) |
|
405 |
(TextEditorSpec |
|
406 |
name: 'FindText' |
|
407 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1) |
|
408 |
model: templateSearchPatternHolder |
|
409 |
hasHorizontalScrollBar: true |
|
410 |
hasVerticalScrollBar: true |
|
411 |
) |
|
412 |
) |
|
413 |
||
414 |
) |
|
415 |
) |
|
416 |
(ViewSpec |
|
417 |
name: 'ReplaceBox' |
|
418 |
component: |
|
419 |
(SpecCollection |
|
420 |
collection: ( |
|
421 |
(LabelSpec |
|
422 |
label: 'Replace with:' |
|
423 |
name: 'ReplaceLabel' |
|
424 |
layout: (LayoutFrame 0 0 0 0 0 1 20 0) |
|
425 |
translateLabel: true |
|
426 |
adjust: left |
|
427 |
) |
|
428 |
(TextEditorSpec |
|
429 |
name: 'ReplaceText' |
|
430 |
layout: (LayoutFrame 0 0 20 0 0 1 0 1) |
|
431 |
model: templateReplacePatternHolder |
|
432 |
hasHorizontalScrollBar: true |
|
433 |
hasVerticalScrollBar: true |
|
434 |
) |
|
435 |
) |
|
436 |
||
437 |
) |
|
438 |
) |
|
439 |
) |
|
440 |
||
441 |
) |
|
442 |
handles: (Any 0.2 0.6 1.0) |
|
443 |
) |
|
444 |
(ActionButtonSpec |
|
445 |
label: 'Use as template' |
|
446 |
name: 'UseAsTemplateButton' |
|
447 |
layout: (LayoutFrame 0 0 -25 1 -5 1 -5 1) |
|
448 |
translateLabel: true |
|
449 |
model: useAsTemplateAction |
|
450 |
) |
|
451 |
) |
|
452 |
||
453 |
) |
|
454 |
) |
|
455 |
||
456 |
"Modified: / 12-12-2007 / 11:23:34 / janfrog" |
|
457 |
! |
|
458 |
||
459 |
windowSpec |
|
460 |
"This resource specification was automatically generated |
|
461 |
by the UIPainter of ST/X." |
|
462 |
||
463 |
"Do not manually edit this!! If it is corrupted, |
|
464 |
the UIPainter may not be able to read the specification." |
|
465 |
||
466 |
" |
|
467 |
UIPainter new openOnClass:Tools::MethodRewriter andSelector:#windowSpec |
|
468 |
Tools::MethodRewriter new openInterface:#windowSpec |
|
469 |
Tools::MethodRewriter open |
|
470 |
" |
|
471 |
||
472 |
<resource: #canvas> |
|
473 |
||
474 |
^ |
|
475 |
#(FullSpec |
|
476 |
name: windowSpec |
|
477 |
window: |
|
478 |
(WindowSpec |
|
479 |
label: 'Method Rewriter' |
|
480 |
name: 'Method Rewriter' |
|
481 |
min: (Point 10 10) |
|
482 |
bounds: (Rectangle 0 0 658 490) |
|
483 |
) |
|
484 |
component: |
|
485 |
(SpecCollection |
|
486 |
collection: ( |
|
487 |
(NoteBookViewSpec |
|
488 |
name: 'NoteBook' |
|
489 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
490 |
model: selectedTabIndex |
|
491 |
menu: tabList |
|
492 |
useIndex: true |
|
493 |
fitLastRow: false |
|
494 |
) |
|
495 |
) |
|
496 |
||
497 |
) |
|
498 |
) |
|
499 |
||
500 |
"Modified: / 12-12-2007 / 11:39:31 / janfrog" |
|
501 |
! ! |
|
502 |
||
503 |
!MethodRewriter class methodsFor:'list specs'! |
|
504 |
||
505 |
tabList |
|
506 |
"This resource specification was automatically generated |
|
507 |
by the TabListEditor of ST/X." |
|
508 |
||
509 |
"Do not manually edit this!! If it is corrupted, |
|
510 |
the TabListEditor may not be able to read the specification." |
|
511 |
||
512 |
" |
|
513 |
TabListEditor new openOnClass: self andSelector:#tabList |
|
514 |
" |
|
515 |
||
516 |
<resource: #tabList> |
|
517 |
||
518 |
^ #( |
|
519 |
(TabItem |
|
520 |
label: 'Search and Replace' |
|
521 |
createNewBuilder: false |
|
522 |
minorKey: searchAndReplaceSpec |
|
523 |
) |
|
524 |
(TabItem |
|
525 |
label: 'Classes' |
|
526 |
createNewBuilder: false |
|
527 |
minorKey: classesSpec |
|
528 |
) |
|
529 |
(TabItem |
|
530 |
label: 'Templates' |
|
531 |
createNewBuilder: false |
|
532 |
minorKey: templatesSpec |
|
533 |
) |
|
534 |
) |
|
535 |
||
536 |
collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ] |
|
537 |
||
538 |
"Modified: / 12-12-2007 / 11:21:27 / janfrog" |
|
539 |
! ! |
|
540 |
||
541 |
!MethodRewriter methodsFor:'accessing'! |
|
542 |
||
543 |
actionInProgress: aBoolean |
|
544 |
||
545 |
^self actionInProgresHolder value: aBoolean |
|
546 |
||
547 |
"Created: / 12-12-2007 / 10:06:16 / janfrog" |
|
548 |
! |
|
549 |
||
550 |
classes |
|
551 |
^ classes ifNil:[classes := List new] |
|
552 |
||
553 |
"Created: / 20-07-2007 / 16:31:18 / janfrog" |
|
554 |
! |
|
555 |
||
556 |
classes: aCollection |
|
557 |
classes := (aCollection collect:[:cls|cls theNonMetaclass]) asList |
|
558 |
||
559 |
"Created: / 20-07-2007 / 16:31:18 / janfrog" |
|
560 |
"Modified: / 12-12-2007 / 09:47:01 / janfrog" |
|
561 |
! |
|
562 |
||
563 |
info: aString |
|
564 |
||
565 |
self infoHolder value: aString |
|
566 |
||
567 |
"Created: / 12-12-2007 / 10:00:50 / janfrog" |
|
568 |
! |
|
569 |
||
570 |
progress: anInteger |
|
571 |
||
572 |
self progressHolder value: anInteger |
|
573 |
||
574 |
"Created: / 12-12-2007 / 10:01:03 / janfrog" |
|
575 |
! |
|
576 |
||
577 |
replacePattern |
|
578 |
^ replaceTextView contents trimSeparators |
|
579 |
||
580 |
"Created: / 21-07-2007 / 06:29:22 / janfrog" |
|
581 |
! |
|
582 |
||
583 |
replacePattern: pattern |
|
584 |
^ replaceTextView contents: pattern trimSeparators |
|
585 |
||
586 |
"Created: / 12-12-2007 / 11:38:22 / janfrog" |
|
587 |
! |
|
588 |
||
589 |
searchPattern |
|
590 |
^ searchTextView contents trimSeparators |
|
591 |
||
592 |
"Created: / 20-07-2007 / 16:51:49 / janfrog" |
|
593 |
"Modified: / 21-07-2007 / 06:29:29 / janfrog" |
|
594 |
! |
|
595 |
||
596 |
searchPattern: pattern |
|
597 |
^ searchTextView contents: pattern trimSeparators |
|
598 |
||
599 |
"Created: / 12-12-2007 / 11:38:12 / janfrog" |
|
600 |
! |
|
601 |
||
602 |
selectedClasses |
|
603 |
||
604 |
^self selectedClassesHolder value |
|
605 |
||
606 |
"Created: / 12-12-2007 / 12:02:03 / janfrog" |
|
607 |
! |
|
608 |
||
609 |
selectedTemplate |
|
610 |
||
611 |
^self templates at:self selectedTemplateIndex value |
|
612 |
||
613 |
"Created: / 12-12-2007 / 11:20:32 / janfrog" |
|
614 |
! |
|
615 |
||
616 |
templates |
|
617 |
templates isNil ifTrue:[ |
|
618 |
templates := self class templates. |
|
619 |
]. |
|
620 |
^ templates |
|
621 |
||
622 |
"Created: / 12-12-2007 / 11:17:55 / janfrog" |
|
623 |
! ! |
|
624 |
||
625 |
!MethodRewriter methodsFor:'actions'! |
|
626 |
||
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
627 |
doRewrite: methodsMatching |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
628 |
| changes compositeChangeCollector | |
8776 | 629 |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
630 |
changes := ChangeSet new name:'Rewrite Changes'. |
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
631 |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
632 |
methodsMatching isEmptyOrNil ifTrue:[^Dialog warn:'No methods matching']. |
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
633 |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
634 |
self withMethods: methodsMatching do:[:mth| |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
635 |
| newTree newSource change | |
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
636 |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
637 |
newTree := ParseTreeSourceRewriter new |
10385
70d8ce47a6fd
comment/format in: #doRewrite
Claus Gittinger <cg@exept.de>
parents:
10170
diff
changeset
|
638 |
replace: self searchPattern |
70d8ce47a6fd
comment/format in: #doRewrite
Claus Gittinger <cg@exept.de>
parents:
10170
diff
changeset
|
639 |
with: self replacePattern; |
8776 | 640 |
executeTree: mth parseTree; |
641 |
tree. |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
642 |
newSource := newTree source notNil |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
643 |
ifTrue:[newTree source] |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
644 |
ifFalse:[newTree formattedCode]. |
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
645 |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
646 |
change := InteractiveAddMethodChange compile: newSource in:mth mclass classified:mth category. |
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
647 |
|
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
648 |
"/ collect in order to have only one change in the undo-list (instead of many) |
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
649 |
changes add: change. |
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
650 |
|
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
651 |
"/ mth mclass |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
652 |
"/ compile: newTree formattedCode |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
653 |
"/ classified: mth category |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
654 |
]. |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
655 |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
656 |
changes isEmpty ifTrue:[ ^ self ]. |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
657 |
|
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
658 |
"/Let the user to inspect and confirm changes...." |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
659 |
changes := ChangeSetBrowser2 confirmChanges: changes. |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
660 |
changes isEmpty ifTrue:[ ^ self ]. |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
661 |
|
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
662 |
"/Perform the refactoring..." |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
663 |
compositeChangeCollector := CompositeRefactoryChange new. |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
664 |
compositeChangeCollector name:'Rewrite Change'. |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
665 |
compositeChangeCollector changes: changes. |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
666 |
RefactoryChangeManager performChange:compositeChangeCollector. |
8776 | 667 |
|
668 |
"Created: / 20-07-2007 / 16:03:47 / janfrog" |
|
669 |
"Modified: / 21-07-2007 / 06:55:42 / janfrog" |
|
10458 | 670 |
"Modified: / 04-08-2011 / 19:05:25 / cg" |
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
671 |
"Created: / 22-03-2012 / 18:22:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8776 | 672 |
! |
673 |
||
674 |
doRewriteAction |
|
675 |
||
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
676 |
self doSearch: self searchPattern withResultDo: [:methodsMatching| |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
677 |
self doRewrite: methodsMatching |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
678 |
]. |
8776 | 679 |
|
680 |
"Created: / 12-12-2007 / 11:14:19 / janfrog" |
|
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
681 |
"Modified: / 22-03-2012 / 18:23:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8776 | 682 |
! |
683 |
||
684 |
doSearch |
|
685 |
|methods| |
|
686 |
||
687 |
methods := self methodsMatching. |
|
688 |
methods isEmpty |
|
689 |
ifTrue: |
|
690 |
[Dialog warn:'Nothing found'] |
|
691 |
ifFalse: |
|
692 |
[self showMethods:methods |
|
693 |
title:'Methods matching ' , self searchPattern] |
|
694 |
||
695 |
"Created: / 20-07-2007 / 16:08:08 / janfrog" |
|
696 |
"Modified: / 21-07-2007 / 06:51:58 / janfrog" |
|
697 |
! |
|
698 |
||
699 |
doSearchAction |
|
700 |
||
701 |
self |
|
702 |
doSearch: self searchPattern |
|
703 |
withResultDo: |
|
704 |
[:matchingMethods| |
|
705 |
matchingMethods isEmpty |
|
706 |
ifTrue:[Dialog warn:'No methods found'] |
|
707 |
ifFalse: |
|
708 |
[self |
|
709 |
showMethods: matchingMethods asArray |
|
710 |
title: 'Methods matching ', self searchPattern]] |
|
711 |
||
712 |
"Created: / 12-12-2007 / 11:14:25 / janfrog" |
|
713 |
! |
|
714 |
||
715 |
removeSeletedClassesAction |
|
716 |
||
717 |
self classes removeAll: self selectedClasses |
|
718 |
||
719 |
"Created: / 12-12-2007 / 12:05:15 / janfrog" |
|
720 |
! |
|
721 |
||
722 |
useAsTemplateAction |
|
723 |
||
724 |
self searchPattern: self templateSearchPatternHolder value. |
|
725 |
self replacePattern: self templateReplacePatternHolder value. |
|
726 |
self selectedTabIndex value:1 |
|
727 |
||
728 |
"Created: / 12-12-2007 / 11:14:15 / janfrog" |
|
729 |
! ! |
|
730 |
||
731 |
!MethodRewriter methodsFor:'aspects'! |
|
732 |
||
733 |
actionInProgresHolder |
|
734 |
"automatically generated by UIPainter ..." |
|
735 |
||
736 |
"*** the code below creates a default model when invoked." |
|
737 |
"*** (which may not be the one you wanted)" |
|
738 |
"*** Please change as required and accept it in the browser." |
|
739 |
"*** (and replace this comment by something more useful ;-)" |
|
740 |
||
741 |
actionInProgresHolder isNil ifTrue:[ |
|
742 |
actionInProgresHolder := true asValue. |
|
743 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
744 |
"/ actionInProgresHolder addDependent:self. |
|
745 |
"/ actionInProgresHolder onChangeSend:#actionInProgresHolderChanged to:self. |
|
746 |
]. |
|
747 |
^ actionInProgresHolder. |
|
748 |
||
749 |
"Created: / 12-12-2007 / 10:00:05 / janfrog" |
|
750 |
! |
|
751 |
||
752 |
infoHolder |
|
753 |
"automatically generated by UIPainter ..." |
|
754 |
||
755 |
"*** the code below creates a default model when invoked." |
|
756 |
"*** (which may not be the one you wanted)" |
|
757 |
"*** Please change as required and accept it in the browser." |
|
758 |
"*** (and replace this comment by something more useful ;-)" |
|
759 |
||
760 |
infoHolder isNil ifTrue:[ |
|
761 |
infoHolder := 'Really cool tool!!' asValue. |
|
762 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
763 |
"/ infoHolder addDependent:self. |
|
764 |
"/ infoHolder onChangeSend:#infoHolderChanged to:self. |
|
765 |
]. |
|
766 |
^ infoHolder. |
|
767 |
||
768 |
"Created: / 12-12-2007 / 10:00:05 / janfrog" |
|
769 |
"Modified: / 12-12-2007 / 11:40:17 / janfrog" |
|
770 |
! |
|
771 |
||
772 |
progressHolder |
|
773 |
"automatically generated by UIPainter ..." |
|
774 |
||
775 |
"*** the code below creates a default model when invoked." |
|
776 |
"*** (which may not be the one you wanted)" |
|
777 |
"*** Please change as required and accept it in the browser." |
|
778 |
"*** (and replace this comment by something more useful ;-)" |
|
779 |
||
780 |
progressHolder isNil ifTrue:[ |
|
781 |
progressHolder := 0 asValue |
|
782 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
783 |
"/ progressHolder addDependent:self. |
|
784 |
"/ progressHolder onChangeSend:#progressHolderChanged to:self. |
|
785 |
]. |
|
786 |
^ progressHolder. |
|
787 |
||
788 |
"Created: / 12-12-2007 / 10:00:05 / janfrog" |
|
789 |
! |
|
790 |
||
791 |
selectedClassesHolder |
|
792 |
"automatically generated by UIPainter ..." |
|
793 |
||
794 |
"*** the code below creates a default model when invoked." |
|
795 |
"*** (which may not be the one you wanted)" |
|
796 |
"*** Please change as required and accept it in the browser." |
|
797 |
"*** (and replace this comment by something more useful ;-)" |
|
798 |
||
799 |
selectedClassesHolder isNil ifTrue:[ |
|
800 |
selectedClassesHolder := ValueHolder new. |
|
801 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
802 |
"/ selectedClassesHolder addDependent:self. |
|
803 |
"/ selectedClassesHolder onChangeSend:#selectedClassesHolderChanged to:self. |
|
804 |
]. |
|
805 |
^ selectedClassesHolder. |
|
806 |
||
807 |
"Created: / 12-12-2007 / 12:01:40 / janfrog" |
|
808 |
! |
|
809 |
||
810 |
selectedTabIndex |
|
811 |
"automatically generated by UIPainter ..." |
|
812 |
||
813 |
"*** the code below creates a default model when invoked." |
|
814 |
"*** (which may not be the one you wanted)" |
|
815 |
"*** Please change as required and accept it in the browser." |
|
816 |
"*** (and replace this comment by something more useful ;-)" |
|
817 |
||
818 |
selectedTabIndex isNil ifTrue:[ |
|
819 |
selectedTabIndex := ValueHolder new. |
|
820 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
821 |
"/ selectedTabIndex addDependent:self. |
|
822 |
"/ selectedTabIndex onChangeSend:#selectedTabIndexChanged to:self. |
|
823 |
]. |
|
824 |
^ selectedTabIndex. |
|
825 |
||
826 |
"Created: / 12-12-2007 / 11:39:29 / janfrog" |
|
827 |
! |
|
828 |
||
829 |
selectedTemplateIndex |
|
830 |
||
831 |
selectedTemplateIndex isNil ifTrue:[ |
|
832 |
selectedTemplateIndex := ValueHolder new. |
|
833 |
selectedTemplateIndex onChangeSend:#selectedTemplateIndexChanged to:self. |
|
834 |
]. |
|
835 |
^ selectedTemplateIndex. |
|
836 |
||
837 |
"Created: / 12-12-2007 / 11:17:16 / janfrog" |
|
838 |
! |
|
839 |
||
840 |
tabList |
|
841 |
"Generated by the TabListEditor" |
|
842 |
||
843 |
|list| |
|
844 |
||
845 |
(list := builder bindingAt:#tabList) isNil ifTrue:[ |
|
846 |
builder aspectAt:#tabList put:(list := self class tabList). |
|
847 |
]. |
|
848 |
^ list |
|
849 |
||
850 |
"Created: / 20-07-2007 / 16:54:27 / janfrog" |
|
851 |
! |
|
852 |
||
853 |
templateNameList |
|
854 |
||
855 |
^self templates collect:[:tmpl|tmpl first] |
|
856 |
||
857 |
"Created: / 12-12-2007 / 11:17:16 / janfrog" |
|
858 |
! |
|
859 |
||
860 |
templateReplacePatternHolder |
|
861 |
"automatically generated by UIPainter ..." |
|
862 |
||
863 |
"*** the code below creates a default model when invoked." |
|
864 |
"*** (which may not be the one you wanted)" |
|
865 |
"*** Please change as required and accept it in the browser." |
|
866 |
"*** (and replace this comment by something more useful ;-)" |
|
867 |
||
868 |
templateReplacePatternHolder isNil ifTrue:[ |
|
869 |
templateReplacePatternHolder := '' asValue. |
|
870 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
871 |
"/ templateReplacePatternHolder addDependent:self. |
|
872 |
"/ templateReplacePatternHolder onChangeSend:#templateReplacePatternHolderChanged to:self. |
|
873 |
]. |
|
874 |
^ templateReplacePatternHolder. |
|
875 |
||
876 |
"Created: / 12-12-2007 / 11:17:16 / janfrog" |
|
877 |
! |
|
878 |
||
879 |
templateSearchPatternHolder |
|
880 |
"automatically generated by UIPainter ..." |
|
881 |
||
882 |
"*** the code below creates a default model when invoked." |
|
883 |
"*** (which may not be the one you wanted)" |
|
884 |
"*** Please change as required and accept it in the browser." |
|
885 |
"*** (and replace this comment by something more useful ;-)" |
|
886 |
||
887 |
templateSearchPatternHolder isNil ifTrue:[ |
|
888 |
templateSearchPatternHolder := '' asValue. |
|
889 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
890 |
"/ templateSearchPatternHolder addDependent:self. |
|
891 |
"/ templateSearchPatternHolder onChangeSend:#templateSearchPatternHolderChanged to:self. |
|
892 |
]. |
|
893 |
^ templateSearchPatternHolder. |
|
894 |
||
895 |
"Created: / 12-12-2007 / 11:17:16 / janfrog" |
|
896 |
! ! |
|
897 |
||
898 |
!MethodRewriter methodsFor:'change & update'! |
|
899 |
||
900 |
selectedTemplateIndexChanged |
|
901 |
||
902 |
self templateSearchPatternHolder value: self selectedTemplate second. |
|
903 |
self templateReplacePatternHolder value: self selectedTemplate third. |
|
904 |
||
905 |
"Created: / 12-12-2007 / 11:20:16 / janfrog" |
|
906 |
! ! |
|
907 |
||
908 |
!MethodRewriter methodsFor:'drag & drop'! |
|
909 |
||
910 |
canDropClasses: dropContext |
|
911 |
||
12287 | 912 |
^dropContext dropObjects allSatisfy: [:obj|obj isClassObject or:[obj isMethodObject]] |
8776 | 913 |
|
914 |
"Created: / 20-07-2007 / 16:58:13 / janfrog" |
|
915 |
! |
|
916 |
||
917 |
doDropClasses: dropContext |
|
918 |
||
919 |
| newClasses | |
|
920 |
newClasses := dropContext dropObjects |
|
12287 | 921 |
select:[:obj|obj isClassObject or:[obj isMethodObject]]. |
922 |
newClasses := newClasses |
|
923 |
collect:[:obj| |clsOrMethod| |
|
924 |
clsOrMethod := obj theObject. |
|
925 |
clsOrMethod isMethod ifTrue:[clsOrMethod containingClass] ifFalse:[clsOrMethod] |
|
926 |
] as:IdentitySet. |
|
927 |
||
8776 | 928 |
newClasses := newClasses reject:[:cls|self classes includes:cls]. |
929 |
self classes |
|
930 |
addAll: newClasses; |
|
931 |
changed:#content |
|
932 |
||
933 |
"Created: / 20-07-2007 / 16:58:16 / janfrog" |
|
934 |
! ! |
|
935 |
||
936 |
!MethodRewriter methodsFor:'hooks'! |
|
937 |
||
938 |
postBuildFindTextView: scrollableView |
|
939 |
||
940 |
searchTextView := scrollableView scrolledView |
|
941 |
||
942 |
"Created: / 20-07-2007 / 15:55:16 / janfrog" |
|
943 |
! |
|
944 |
||
945 |
postBuildReplaceTextView: scrollableView |
|
946 |
||
947 |
replaceTextView := scrollableView scrolledView |
|
948 |
||
949 |
"Created: / 20-07-2007 / 15:55:29 / janfrog" |
|
950 |
! ! |
|
951 |
||
952 |
!MethodRewriter methodsFor:'private'! |
|
953 |
||
954 |
doSearch: pattern withResultDo: block |
|
955 |
||
956 |
| matchingMethods | |
|
957 |
matchingMethods := Set new. |
|
958 |
self |
|
959 |
withMethodsDo: |
|
9988 | 960 |
[:mth| | tree | |
961 |
tree := mth parseTree. |
|
962 |
tree ifNil:[self breakPoint: #jv] ifNotNil:[ |
|
8776 | 963 |
(ParseTreeSearcher new) |
964 |
matches:self searchPattern do:[:aNode :answer | matchingMethods add:mth ]; |
|
9988 | 965 |
executeTree: tree] |
966 |
] |
|
8776 | 967 |
finallyDo: |
968 |
[block value: matchingMethods] |
|
969 |
||
970 |
"Created: / 12-12-2007 / 10:34:50 / janfrog" |
|
9988 | 971 |
"Modified: / 07-04-2011 / 22:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8776 | 972 |
! |
973 |
||
974 |
methods |
|
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
975 |
methods notNil ifTrue:[^ methods]. |
8776 | 976 |
|
977 |
^self methodsFor: classes |
|
978 |
||
979 |
"Modified: / 21-07-2007 / 06:24:07 / janfrog" |
|
10170
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
980 |
"Modified: / 05-07-2011 / 14:50:43 / cg" |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
981 |
! |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
982 |
|
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
983 |
methods:aCollection |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
984 |
methods := aCollection |
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
985 |
|
3239c0b672eb
allow for individual methods to be rewritten;
Claus Gittinger <cg@exept.de>
parents:
10153
diff
changeset
|
986 |
"Created: / 05-07-2011 / 14:50:52 / cg" |
8776 | 987 |
! |
988 |
||
989 |
methodsFor: aColletion |
|
990 |
||
991 |
^classes |
|
992 |
inject: Set new |
|
993 |
into: |
|
994 |
[:methods :cls| |
|
995 |
methods |
|
996 |
addAll: cls methodDictionary values; |
|
997 |
addAll: cls class methodDictionary values; |
|
998 |
yourself] |
|
999 |
||
1000 |
"Created: / 21-07-2007 / 06:25:42 / janfrog" |
|
1001 |
! |
|
1002 |
||
1003 |
methodsMatching |
|
1004 |
||
1005 |
^self methodsMatching: self searchPattern |
|
1006 |
||
1007 |
"Created: / 21-07-2007 / 06:26:44 / janfrog" |
|
1008 |
! |
|
1009 |
||
1010 |
methodsMatching: searchPattern |
|
1011 |
|matchingMethods| |
|
1012 |
||
1013 |
matchingMethods := OrderedCollection new. |
|
1014 |
self methods do:[:mth | |
|
1015 |
(ParseTreeSearcher new) |
|
1016 |
matches:searchPattern do:[:aNode :answer | matchingMethods add:mth ]; |
|
1017 |
executeTree:mth parseTree. |
|
1018 |
]. |
|
1019 |
^ matchingMethods |
|
1020 |
||
1021 |
"Created: / 21-07-2007 / 06:26:19 / janfrog" |
|
1022 |
! |
|
1023 |
||
1024 |
showMethods: methods title: title |
|
1025 |
||
1026 |
NewSystemBrowser |
|
1027 |
browseMethods:methods |
|
1028 |
title:title |
|
1029 |
sort:true |
|
1030 |
||
1031 |
"Created: / 21-07-2007 / 06:51:36 / janfrog" |
|
1032 |
! |
|
1033 |
||
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1034 |
withMethods: givenMethods do: methodBlock |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1035 |
|
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1036 |
^self withMethods: givenMethods do: methodBlock finallyDo: [] |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1037 |
|
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1038 |
"Created: / 22-03-2012 / 18:25:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1039 |
! |
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1040 |
|
8776 | 1041 |
withMethods: methods do: methodBlock finallyDo: finallyBlock |
1042 |
||
1043 |
[ |
|
1044 |
self actionInProgress: true. |
|
1045 |
methods asArray keysAndValuesDo: |
|
1046 |
[:idx :mth| |
|
1047 |
self info: mth selector storeString. |
|
1048 |
methodBlock value: mth. |
|
1049 |
self progress: ((100 / methods size) * idx) rounded]. |
|
1050 |
finallyBlock value |
|
1051 |
] ensure:[ |
|
1052 |
"/self actionInProgress: false. |
|
1053 |
self progress: 0. |
|
1054 |
self info: '' |
|
1055 |
] |
|
1056 |
||
1057 |
"Created: / 12-12-2007 / 10:32:16 / janfrog" |
|
1058 |
! |
|
1059 |
||
1060 |
withMethodsDo: methodBlock finallyDo: finallyBlock |
|
1061 |
||
1062 |
^self |
|
1063 |
withMethods: self methods asArray |
|
1064 |
do: methodBlock |
|
1065 |
finallyDo: finallyBlock |
|
1066 |
||
1067 |
"Modified: / 12-12-2007 / 10:32:48 / janfrog" |
|
1068 |
! ! |
|
1069 |
||
1070 |
!MethodRewriter methodsFor:'testing method'! |
|
1071 |
||
1072 |
testXXX |
|
1073 |
self halt:'Was halt' |
|
1074 |
||
1075 |
"Created: / 21-07-2007 / 07:55:24 / janfrog" |
|
1076 |
"Modified: / 12-12-2007 / 10:45:20 / janfrog" |
|
1077 |
! ! |
|
1078 |
||
1079 |
!MethodRewriter class methodsFor:'documentation'! |
|
1080 |
||
8803 | 1081 |
version_CVS |
12287 | 1082 |
^ '§Header: /cvs/stx/stx/libtool/Tools__MethodRewriter.st,v 1.16 2012/08/03 19:21:17 stefan Exp §' |
9988 | 1083 |
! |
1084 |
||
1085 |
version_SVN |
|
12287 | 1086 |
^ '$Id: Tools__MethodRewriter.st 8048 2012-09-07 17:28:09Z vranyj1 $' |
12207
17656fc80e6c
Improvements in method rewriter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
1087 |
! ! |