是否有任何上下文相关的代码搜索工具? [英] Are there any context-sensitive code search tools?

查看:74
本文介绍了是否有任何上下文相关的代码搜索工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,在处理我试图熟悉的大量旧代码时,我感到非常沮丧.

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

但是,其他一些则很难手动发现,因为它们实际上是来自模块中其他函数的调用,这些模块仅在某些情况下才被编译,或者属于#if 0的更大代码块的一部分全部.

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.

我想要的是一种搜索工具,该工具将允许我搜索一个术语,并让我选择是否包含注释掉的代码或#if 0输出的代码.然后,搜索结果将显示在所需的#define列表的旁边,以使该代码段相关.

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.

我正在C/C ++中工作,但是除了特定的注释语法之外,我认为这些技术应该更普遍地适用.

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

是否存在这样的工具?

Does such a tool exist?

推荐答案

几乎所有体面的源浏览器都可以让您转到定义函数的位置,和/或列出该函数的所有调用,直接将您带到某个调用地点.通常,这将基于对源代码的相当完整的解析,因此它将忽略注释,预处理器所排除的代码,等等(实际上,在至少一种情况下,源浏览器使用的解析器几乎可以肯定是比编译器本身使用的更好).

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).

这篇关于是否有任何上下文相关的代码搜索工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆