简体   繁体   English

为C ++项目索引字符串文字

[英]Indexing string literals for c++ project

I have a huge c++ project and I find myself rgrep-ing for patterns that I know are in string literals. 我有一个庞大的c ++项目,我发现自己rgrep-ing我所知道的字符串文字模式。 Is there a way to get clang or x tags or cscope or whatever to build a file with a mapping of each string literal in the project to the file and line where it was found? 有没有办法获取clang或x标记或cscope或其他任何文件,以将项目中每个字符串文字映射到文件和找到它的行的映射?

I don't know of a way to make cscope or friends to do this. 我不知道让cscope或朋友这样做的方法。 You could almost certainly write a custom Starscope extractor that would do this, if you don't mind writing a dozen or so lines of Ruby (starscope: https://github.com/eapache/starscope , adding an extractor: https://github.com/eapache/starscope/blob/master/doc/LANGUAGE_SUPPORT.md#how-to-add-another-language ) 如果您不介意编写十几行Ruby(starscope: https : //github.com/eapache/starscope ,添加提取器: https:/ ,则几乎可以肯定可以编写一个自定义的Starscope提取器来执行此操作。 /github.com/eapache/starscope/blob/master/doc/LANGUAGE_SUPPORT.md#how-to-add-another-language

Alternatively it may just be enough to use something like ag instead, which is grep-like but generally a lot faster: https://github.com/ggreer/the_silver_searcher 另外,使用ag东西可能就足够了,它类似于grep,但通常要快得多: https : //github.com/ggreer/the_silver_searcher

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM