I feel stupid for asking this, but I Googled and found nothing, checked classes
for comments and found nothing, then skimmed Pharo by Example and also found nothing. Lukas mentioned helpfully in another thread that you can use the regex refactoring tools in the OmniBrowser to transform code, but I can't seem to figure out how to do it. I figured out how to "scope" the refactoring to a class or class hierarchy, which results in a gold window popping up with the selected class(es) in the left-most panel. When I right-click on the class at the top and choose "refactor->source regex", I get a template in the code panel that looks like this: ORSourceRegexRefactoring new "Example 1: Replace symbols with strings" replace: '#(\w+)' with: '''$1''' ignoreCase: false; "Example 2: Replace 4 spaces with tabs" replace: ' ' with: ' ' ignoreCase: false; yourself I wanted to rename a method (and all senders of it in the selected scope) from "nextValue" to "nextItem", so I edit the template to this: ORSourceRegexRefactoring new replace: 'nextValue' with: 'nextItem' ignoreCase: false; yourself I highlight it all with Alt-a, then Do It with Alt-d, but nothing seems to happen. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
On 22 sept. 09, at 11:14, T.J. Richter wrote: > I feel stupid for asking this, but I Googled and found nothing, > checked classes > for comments and found nothing, then skimmed Pharo by Example and > also found > nothing. Lukas mentioned helpfully in another thread that you can > use the regex > refactoring tools in the OmniBrowser to transform code, but I can't > seem to > figure out how to do it. I figured out how to "scope" the > refactoring to a > class or class hierarchy, which results in a gold window popping up > with the > selected class(es) in the left-most panel. When I right-click on the > class at > the top and choose "refactor->source regex", I get a template in the > code > panel that looks like this: > > ORSourceRegexRefactoring new > > "Example 1: Replace symbols with strings" > replace: '#(\w+)' with: '''$1''' ignoreCase: false; > > "Example 2: Replace 4 spaces with tabs" > replace: ' ' with: ' ' ignoreCase: false; > > yourself > > I wanted to rename a method (and all senders of it in the selected > scope) from > "nextValue" to "nextItem", so I edit the template to this: Hi TJ The quick answer: if you want to do a standard refactoring in the scope, like renaming a method and update senders, you can use the standard action in the menu. It will do exactly what you want. The rewrite code tool is there for more tricky situations. The other answer: I myself often struggle with the syntax for those refex tools. Part of the reason I think is that the 'regex' matches on AST nodes and not on text, so regex expressions do not match string but nodes. The links I found useful are the two screencasts of Lukas in the following order: http://www.lukas-renggli.ch/blog/ob-rb-3 http://www.lukas-renggli.ch/blog/ob-rb-1 > > > ORSourceRegexRefactoring new > > replace: 'nextValue' with: 'nextItem' ignoreCase: false; > > yourself > > I highlight it all with Alt-a, then Do It with Alt-d, but nothing > seems to > happen. > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project -- Simon _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Alt-s... not Alt-d. That was my problem :)
Thanks for pointing me in the direction of those helpful screencasts. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by T. J. Richter
> I highlight it all with Alt-a, then Do It with Alt-d, but nothing seems to
> happen. All fine up to here. Just accept the code using Ctrl+S or the item 'accept' in the context menu. Depending on the size of the code to be searched it might take a while (a hourglass is displayed). Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |