Re:SourceWeb: A C/C++ source code indexer and navigator
by ryanprichard on Thursday January 21, 2016 @01:24PM
(#10947157)
SourceWeb needs a list of C++ invocations (compile_commands.json), but it ignores compiler errors, so I'm not sure how precise the invocations need to be. If all the C++ source files in a directory were naively listed, the index might still be useful. I've never actually done that, though -- I normally use the sw-btrace tool to build the JSON file.
The indexer comes up with a globally-unique name for each "symbol" it indexes. This turned out to be a hard problem for things like templates and macros. The indexer names static functions by prepending a filename, e.g. "bio_ssl.c/ssl_write". For local variables, it also appends a file offset. With templates/macros, it can determine that a single identifier corresponds to arbitrarily many different symbols, and when you right-click that identifier in the GUI, it attempts to show them all in a popup menu, which fills the entire screen.
Re:SourceWeb: A C/C++ source code indexer and navigator
by nitrogen on Thursday January 21, 2016 @01:26PM
(#10947172)
I seem to recall cscope being much more powerful when run directly outside of vim, but it's been a very long time since I've tried it.
Re:SourceWeb: A C/C++ source code indexer and navigator
by vmorgulis on Thursday January 21, 2016 @06:48PM
(#10949519)
> ...if it doesn't compile, you can't parse.
I have the same problem with CastXML. It's clang-based too. It can't parse my project because of few C++17 "auto" functions.
I'm looking for a GCC-based solution for now.
If two different c++ classes use the same identifier for a member and you even fully qualify it in a .cpp definition (e.g. A::Temp and B::Temp), ctags/cscope still just picks the earliest occurrence of Temp.
Using the clang parser is the obvious thing to do (Qt Creator now has a plugin like this). The real downside to the linux command line tools I found (clic, rtags) is, that you need to provide compiler invokations for all .cpp files to the tools. With cmake, this is easy (call it with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON), but with plain make files, this is pain (specially, if you don't want to setup the whole dependencies): if it doesn't compile, you can't parse.
I would love to see a "parse what is possible", because I'd like to learn from source by running "apt-get source ..." and navigating through parts, that I am interested in without trying to compile everything. Best example for source, I don't want to compile is the Android source code (AOSP). Am I missing something?