开发者

Are there any context-sensitive code search tools?

开发者 https://www.devze.com 2022-12-30 19:32 出处:网络
I have been getting very frustrated recently in dealing with a massive bulk of legacy code which I am trying to get familiar with.

I have been getting very frustrated recently in dealing with a massive bulk of legacy code which I am trying to get familiar with.

Say I try to search for a particular function call, I get loads of results that turn out to be completely irrelevant; some of them are easy to spot, eg a comment saying

// Fixed functionality in foo() so don't need to handle this here any more

But others are much harder to spot manually, because they turn out to be calls from other functions in modules that are only compiled in certain cases, or are part of a much larger block of code that is #if 0'd out in its entirety.

What I'd like would be a search tool that would allow me to search for a term and give me the choice to include or exclude commented out or #if 0'd out code. Then the search results would be displayed alongside a list of #defines that are required in order for that snippet of code to be relevant.

I'm working in C / 开发者_StackOverflowC++, but other than the specific comment syntax I guess the techniques should be more generally applicable.

Does such a tool exist?


Not entirely what you're after, but I find this quite handy.

GrepWin - A free visual "grep" tool for searching files.

I find it quite helpful because:

  • Its a separate app (doesn't lock up my editor)
  • Handles Regular expressions
  • Its fast
  • Can specify what folder to search, and what filetypes (handles regex's here too)
  • Can limit by file size
  • Can include subdirs (or exclude by regex)
  • etc.


Almost any decent source browser will let you go to where a function is defined, and/or list all the calls of that function and take you directly to a call site. This will normally be based on a fairly complete parse of the source code so it will ignore comments, code that's excluded by the preprocessor, and so on (in fact, in at least one case, the parser used by the source browser is almost certainly better than the one used in the compiler itself).

0

精彩评论

暂无评论...
验证码 换一张
取 消