I'd like to ask, is there any ways to automatically replace all
references to some global ( Display, for instance) with message send and recompile all modified methods accordingly. In OB i saw some ways to manipulate with code on AST level, where it can clearly tell that Display is global. I tried to do a global text search & replace , but its quite inconvenient, because it still leaves a lot of manual work. The most bigger issues with textual replace is, that if you replace 'Display' with 'self getDisplay' in 'DisplayScreen' , you will get 'self getDisplayScreen' :) It is possible, of course to write a clever regex pattern to avoid such situations, but again, what if i don't want to touch comments? Another thing is assignment - with AST on hand, it can clearly tell, if you need to replace an assignment with setter message send, while if you doing a textual replace you have to deal with it by writing another regex. And finally, replacing using AST will guarantee that method will be compiled under any circumstances. Can anyone tell me, or show some code snippets, how to do this using OB? I found a lot of different refactoring features in OB, but can't find an easy way to do what i need. -- Best regards, Igor Stasenko AKA sig. |
Isn't there a rewrite tool for Squeak? |
2008/11/8 Boris Popov <[hidden email]>:
> Isn't there a rewrite tool for Squeak? > Never heard of it. Have any pointers? > Cheers! > > -Boris (via BlackBerry) -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Igor Stasenko
Its part of refactoring browser, google it, but I have no idea if squeak has something similar. |
2008/11/8, Boris Popov <[hidden email]>:
> Its part of refactoring browser, google it, but I have no idea if squeak has > something similar. Oh yes: http://www.refactory.com/RefactoringBrowser/Rewrite.html It has one show stopper though: it pretty prints the source code. Cheers Philippe |
http://www.lukas-renggli.ch/blog/ob-rb-3
On 11/8/08, Philippe Marschall <[hidden email]> wrote: > 2008/11/8, Boris Popov <[hidden email]>: >> Its part of refactoring browser, google it, but I have no idea if squeak >> has >> something similar. > > Oh yes: > http://www.refactory.com/RefactoringBrowser/Rewrite.html > > It has one show stopper though: it pretty prints the source code. > > Cheers > Philippe > > -- Lukas Renggli http://www.lukas-renggli.ch |
2008/11/9 Lukas Renggli <[hidden email]>:
> http://www.lukas-renggli.ch/blog/ob-rb-3 > Thanks for tip, (i found it before, but have no idea how to use it) in OB if i right-click on methods list, i can choose: open >> rewrite code or open >> search code, which replacing text in method source pane with, as i understand, a sample template for creating search/replace pattern. --- ParseTreeSearcher new matches: '`@object' do: [ :node :answer | node ]; matchesMethod: '`@method: `@args | `@temps | `@.statements' do: [ :node :answer | node ]; yourself --- now, the problem is, that i don't understand what to do next, and can't actually find anything useful. Do it - nothing happens Accept it - nothing happens.. i expecting to get a list of methods found with a nice 'Accept/Cancel' options which is shown on your screencast.. :) Can you help me please? > On 11/8/08, Philippe Marschall <[hidden email]> wrote: >> 2008/11/8, Boris Popov <[hidden email]>: >>> Its part of refactoring browser, google it, but I have no idea if squeak >>> has >>> something similar. >> >> Oh yes: >> http://www.refactory.com/RefactoringBrowser/Rewrite.html >> >> It has one show stopper though: it pretty prints the source code. >> >> Cheers >> Philippe >> >> > > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > -- Best regards, Igor Stasenko AKA sig. |
2008/11/9 Igor Stasenko <[hidden email]>:
> 2008/11/9 Lukas Renggli <[hidden email]>: >> http://www.lukas-renggli.ch/blog/ob-rb-3 >> > > Thanks for tip, (i found it before, but have no idea how to use it) > in OB if i right-click on methods list, i can choose: > open >> rewrite code > or > open >> search code, > > which replacing text in method source pane with, as i understand, a > sample template for creating search/replace pattern. > --- > ParseTreeSearcher new > matches: '`@object' do: [ :node :answer | node ]; > matchesMethod: '`@method: `@args | `@temps | `@.statements' do: [ > :node :answer | node ]; > yourself > --- > now, the problem is, that i don't understand what to do next, and > can't actually find anything useful. > Do it - nothing happens > Accept it - nothing happens.. > > i expecting to get a list of methods found with a nice 'Accept/Cancel' > options which is shown on your screencast.. :) > > Can you help me please? > ... to elaborate what i'm expecting to be easily done is to write a snippet, like: | rule | rule = ParseTreeSearcher new blablabla . OB showMeWhatYouFoundBasedOn: rule. or , in case if i want to ship it in changeset (a non-interactive version of changes), is something like: | rule | rule = ParseTreeRewriter new blablabla . OB silentlyRewriteMethodsBasedOn: rule. -- Best regards, Igor Stasenko AKA sig. |
i finally got it working!!
accept works if i open search from package list.. Basically this is all what i need so far.. and the search pattern is quite simple: ParseTreeSearcher new matches: 'Display' do: [ :node :answer | (node parent isAssignment and: [node parent variable == node]) ifTrue: [node] ifFalse: [nil]]; yourself - shows all assignments to Display global var. and if i change ifTrue/ifFalse, it will show me all references to Display, except assignments -- Best regards, Igor Stasenko AKA sig. |
It works for me from any pane (category, classes, protocols, and
methods). Are you using any OB extensions that could interfere here? Lukas On 11/9/08, Igor Stasenko <[hidden email]> wrote: > i finally got it working!! > accept works if i open search from package list.. > Basically this is all what i need so far.. > and the search pattern is quite simple: > > ParseTreeSearcher new > matches: 'Display' do: [ :node :answer | (node parent isAssignment > and: [node parent variable == node]) ifTrue: [node] ifFalse: [nil]]; > yourself > > - shows all assignments to Display global var. > and if i change ifTrue/ifFalse, it will show me all references to > Display, except assignments > > > -- > Best regards, > Igor Stasenko AKA sig. > > -- Lukas Renggli http://www.lukas-renggli.ch |
2008/11/9 Lukas Renggli <[hidden email]>:
> It works for me from any pane (category, classes, protocols, and > methods). Are you using any OB extensions that could interfere here? > i'm not sure why it wasn't worked for me in first time.. maybe because i'm too dumb to get how to use it.. or maybe because it is done in an anti-user-friendly manner and completely non-intuitive. No offsense to anyone :) > Lukas > > On 11/9/08, Igor Stasenko <[hidden email]> wrote: >> i finally got it working!! >> accept works if i open search from package list.. >> Basically this is all what i need so far.. >> and the search pattern is quite simple: >> >> ParseTreeSearcher new >> matches: 'Display' do: [ :node :answer | (node parent isAssignment >> and: [node parent variable == node]) ifTrue: [node] ifFalse: [nil]]; >> yourself >> >> - shows all assignments to Display global var. >> and if i change ifTrue/ifFalse, it will show me all references to >> Display, except assignments >> >> >> -- >> Best regards, >> Igor Stasenko AKA sig. >> >> > > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > -- Best regards, Igor Stasenko AKA sig. |
Free forum by Nabble | Edit this page |