Re: Batch code editing (was: [GD-General] C++ analyzers?)
Brought to you by:
vexxed72
From: Thatcher U. <tu...@tu...> - 2002-07-18 21:32:06
|
On Jul 18, 2002 at 02:09 -0700, Brian Hook wrote: > But does it do context and type sensitive changes? Will it only change > m_uFlags to m_uEntityFlags in only those instances where's it referenced > as an entity? Most search and replace tools, no matter how elaborate, > aren't designed to actually understand the actual code itself. > > That's my beef with doing things manually. If you change the name of a > variable you can easily find the problems by compiling and fixing > errors, but that's tedious and error prone. Also, silent errors can get > introduced with search and replace that's done incorrectly or that > doesn't handle all cases: > > int foo; > int bar; > int foobar; > int blahbar; > > s&r foo -> blah > > suddenly all your foo are blah, which is what you want, but now your > foobar are blahbar, which is NOT what you wanted. Forgot to mention another handy technique: search & replace with an intermediate name, like "m_foobar_TEMPORARY_CRAZY_UNIQUE_IDENTIFIER", fix the errors, then do a global perl script on the unique identifier. It'll be hard to turn foobar into blahbar that way. > Maybe I'm being na?ve, but this seems like the kind of thing that would > be trivially easy to implement (compared to writing a compiler + IDE), > yet all we keep getting are the basic things like automatic expansion of > member variables when you type "foo->". Hell, and that doesn't work 95% > of the time anymore in MSVC =| Well, yeah, I agree you have a point, I'm just throwing out random practical advice that I'm sure everybody knows already. The fundamental problem is that C++ is incredibly hard to parse; in fact it's still an unsolved problem :) But, I believe this new generation of compilers (GCC 3, and VC.net or whatever) is much better about exporting program metadata, so maybe it will be possible to build tools off that. -- Thatcher Ulrich http://tulrich.com |