Komodo Hacks: Rename Occurrences
This Komodo hack allows you to rename all occurrences of a variable or method name wherever it appears in your code. This is the last of my macros this week that uses Bicycle Repair Man; if you missed my previous post on how to get the BRM package into Komodo, it can be found here.
You can download the macro here. Install it into Komodo by using the Import Package option under the Toolbox menu.
Usage notes:
You can download the macro here. Install it into Komodo by using the Import Package option under the Toolbox menu.
Usage notes:
- Highlight a variable or method in your code and double-click on the Rename macro in the toolbox. The macro will prompt you for the new variable or method name and then perform the rename operation.
- Before refactoring, Komodo will prompt you to save your file if necessary. (This is a requirement of BRM.)
- After refactoring, Komodo will tell you that your file or files have changed and prompt you to reload them. Go ahead! You should see your changes in the updated file(s). If you don't like what you see, you can Undo the changes, via the Edit menu or CTRL-Z.
- Rename Occurrences may not always work like you expect. As an example, you'll want to rename method names where they are originally defined; otherwise, the renaming will only be local and not propagate throughout your code.
Labels: hacks, komodo, python, refactoring

4 Comments:
Don't hack the bicycle repair man, we like bicycles. Hack the Python. Better yet, have the Komodo eat the Python. Then feed the BRM the macaroni.
By
Becky, At
9:19 PM
One might suspect you're making fun of my post ... ;)
By
Brandon Corfman, At
10:11 PM
Brandon - I am having trouble using this macro - running it is resulting in the following error message:
Traceback (most recent call last):
File "C:\Program Files\ActiveState Komodo IDE 4.0\lib\mozilla\components\koProject.py", line 2570, in evalPythonMacro
return eval('_code()', macroGlobals, macroGlobals)
File ">string>", line 0, in ?
File ">string>", line 88, in _code
File "C:\Program Files\ActiveState Komodo IDE 4.0\lib\python\lib\site-packages\bike\bikefacade.py", line 116, in __call__
return getattr(self.brmctx,self.name)(*args)
AttributeError: 'BRMContext_impl' object has no attribute 'rename'
I'm not sure yet if I am simply using the macro incorrectly, or if there's something wrong with my environment, but I thought I would mention it in case others were having the same problem.
By
John, At
8:24 PM
My thought is that either a) you got the wrong version of BRM (see my previous post which I linked), or b) you got a version of Komodo I didn't test (maybe a beta or other OS version besides Windows). It might help to check those two items.
By
Brandon Corfman, At
10:38 PM
Post a Comment
<$I18N$LinksToThisPost>:
Create a Link
<< Home