On May 18, 2012, at 7:10 PM, "Mehrdad" <wfunct...@hotmail.com> wrote: > > 2. Okay, so that's clever. :P Now tell me what you do when you have dozens of > lines in your source file like > > @property auto length() { return _range.length; } > > and you want to rename the field 'length'? How do you prevent the second one > from getting renamed?
sed using a regex that accounts for more of the line than just "length", like " length(". It only gets tricky if you are renaming a method call with a non-unique name, which is when you need to use compiler output to flag the offending lines since pure text analysis won't cut it. > Or say you have > > @property auto back() { ... } > @property moveBack() { assert(0, "Cannot move an element from the back!"); > } > auto popBack() { } // Remove an element from the back > > and you change the name of the property 'back' to 'last': > > @property auto back() { ... } > @property moveBack() { assert(0, "Cannot move an element from the last!"); > } > auto popBack() { } // Remove an element from the last > > Notice something funny? Three operations, one for each method actually being renamed. Ultimately, it's hard to replace a real refactoring tool since it has a compiler built-in though. That said, I don't personally do this kind of thing... pretty much ever. So using a special tool when needed seems like an option.