Code Monkey home page Code Monkey logo

cquery's Introduction

Archived

cquery is no longer under development. clangd and ccls are both good replacements.

cquery

Join the chat at https://gitter.im/cquery-project/Lobby

cquery is a highly-scalable, low-latency language server for C/C++/Objective-C. It is tested and designed for large code bases like Chromium. cquery provides accurate and fast semantic analysis without interrupting workflow.

Demo

cquery implements almost the entire language server protocol and provides some extra features to boot:

>>> Getting started (CLICK HERE) <<<

Packaging status

Limitations

cquery is able to respond to queries quickly because it caches a huge amount of information. When a request comes in, cquery just looks it up in the cache without running many computations. As a result, there's a large memory overhead. For example, a full index of Chrome will take about 10gb of memory. If you exclude v8, webkit, and third_party, it goes down to about 6.5gb.

License

MIT

cquery's People

Contributors

acowley avatar agauniyal avatar andyleejordan avatar btolsch avatar daandemeyer avatar danielmartin avatar edjubuh avatar highcommander4 avatar innerout avatar jacobdufault avatar jacobdufault-google avatar jaelsasser avatar jamescookmd avatar jhasse avatar jiegec avatar kapows avatar khng300 avatar leszekswirski avatar maskray avatar patilarpith avatar pelmers avatar rianneogi avatar riatre avatar romix avatar scturtle avatar topisani avatar walter-erquinigo avatar xu-cheng avatar yanpas avatar yshui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cquery's Issues

Upgrade to clang 5

There are some weird indexing bugs with Chrome, so upgrading is going to take some investigation. All of the index tests pass, though.

server client version mismatch in emacs

Hello, I just pulled the recent cquery code base and played it with tmux project. I got

cquery client (v0) and server (v3) version mismatch. Please update your extension client (VSIX file). Make sure to uninstall the cquery extension and restart vscode before reinstalling.
error in process filter: Error parsing language server output: (error No Content-Length header) [46 times]
error in process filter: Error parsing language server output: (error Invalid header string) [4 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [88 times]
error in process filter: Error parsing language server output: (error Invalid header string) [4 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [80 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [44 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [44 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [12 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [44 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [38 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]
error in process filter: Error parsing language server output: (error No Content-Length header) [36 times]
error in process filter: Error parsing language server output: (error Invalid header string) [2 times]

Am i doing anything wrong or is it just not ready to use for now? Thanks!

[Compile Commands] Quotes are stripped from preprocessor definitions in cache json files

It would seem that for a compile_commands.json that includes a command which defines preprocessor values as strings, the quotes are stripped when the cquery caches the files. For example: in a compile_commands.json that includes the following:

    "directory": "...",
    "file": "...",
    "command": "... -D__BUILD_CONFIG__=\"Debug\" -D__BUILD_PLATFORM__=\"x64\" -D__BUILD_PROJECT__=\"demo\" ..."
  },

The resulting cache file would look similar to this:

{
	"version": 5,
	"last_modification_time": 1511303313,
	"import_file": "...",
	"args": [
		"cc",
		"-D__BUILD_CONFIG__=Debug",
		"-D__BUILD_PLATFORM__=x64",
		"-D__BUILD_PROJECT__=demo",
		"-DDEBUG",
		"...",
		"-xc++",
		"-std=c++11",
		"-resource-dir="/misc/cquery/clang_resource_dir"
	]
}

Notice how the values for __BUILD_PROJECT__, etc. no longer have their quotes; This results in errors such as the following:
image

Warn user to disable Microsoft C/C++ extension if they have it enabled

Warn user to disable Microsoft C/C++ extension if they have it enabled via a notification in vscode or similar.

When both are enabled there are confusing errors, ie, goto definition gets very slow. Native code debug and clang format are available in separate extensions outside of the Microsoft C/C++ one.

Relative paths break cquery

My build output is parsed relative to a build directory. The output of the build is of the form ../../../src/MyFile.cpp.

If I open a file from the problems tab vs code seems to open it as <full_path_to_build_dir>/../../../src/MyFile.cpp

In this case i get errors
Message: Unable to find file <full_path_to_build_dir>/../../../src/MyFile.cpp

If I close the file and re-open it it is opened without ../../../ and cquery is happy

I believe the following diff resolves the issue for me (although I haven't given it thorough testing and I doubt it's a cross platform fix)

diff --git a/src/language_server_api.cc b/src/language_server_api.cc
index 9c1471c..e6b38b6 100644
--- a/src/language_server_api.cc
+++ b/src/language_server_api.cc
@@ -1,5 +1,8 @@
 #include "language_server_api.h"

+#include <climits>
+#include <cstdlib>
+
 #include <doctest/doctest.h>
 #include <loguru.hpp>

@@ -260,6 +263,10 @@ std::string lsDocumentUri::GetPath() const {
   // std::transform(result.begin(), result.end(), result.begin(), ::tolower);
 #endif

+  char* newresult = realpath(result.c_str(), NULL);
+  result = std::string(newresult);
+  free(newresult);
+
   return result;
 }

Reduce log spam

Open the output view in vs code while cquery is indexing and notice tons and tons of errors and warnings that keep repeating endlessly forever. If anything, they would slow indexing a lot, and prevent us from seeing actual important logs.

Add settings deserialization validation in cquery C++

When we get the initialization message settings is immediately deserialized. We then re-serialize the deserialized content and print that to stderr.

It'd be good to do a diff on the content before the initial serialization (ie, what we actually receive) and the content after the deserializaiton/serialization round-trip so we could notify the user if the one of the settings was not of the correct type / deserialized correctly.

Extraneous closing brace false positive

I'm regularly getting an error about too many closing braces in functions even though the code compiles without any problems. The error disappears if I remove all code from the file and paste it back in.

I've not been able to reliably reproduce it yet.

Ambiguity on Windows support

Hi!

This language server looks really interesting. Unfortunately, I have not been able to make it work on Windows.

The readme does not seem to mention Windows support (or lack thereof). The configure script gives the error ERROR: Unknown platform win32. However, the VSCode extension has a setting called cquery.launch.command which is described with the following text:

Command to start the cquery binary (on Linux ./app, on Windows indexer.exe)

So, what is the Windows support status?

Note: I was able to compile cquery using Windows Subsystem for Linux, but I am unsure whether I can use the generated binary together with VSCode.

No autocompletion for C code

I use mix of C and C++ in my project. For some reason there is no auto-completion for C code although compile_commands.json has commands for C files and indexing does work.

c support?

does this support c? the readme doesn't mention c, only c++, but usually things that work with c++ also work with c.

Add continuous integration

I've made sure the build system of cquery is easy to integrate with CI, but it needs to be setup. I haven't taken the time to do it yet. Here's the steps:

git clone https://github.com/jacobdufault/cquery --recursive
./waf configure
./waf build

There are also some tests that should be run and a format script, but that can be dealt with later.

Got stuck at Creating completion session with arguments with full cpu usage

Hi! I am using cquery with LanguageClient-Neovim. However it seems that cquery got stuck after Creating completion session with arguments, occupying half of my cores while reporting progress as {"indexRequestCount":0,"doIdMapCount":0,"loadPreviousIndexCount":0,"onIdMappedCount":0,"onIndexedCount":0}.

Debug logs from LanguageClient-Neovim:

14:10:22 DEBUG   [MainThread] => {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///home/lz/code/c10k-server/a.cpp","version":5},"contentChanges":[{"text":"#include <iostream>\n\nint main()\n{\n\tstd::cin.\n}\n"}]}}
14:10:22 DEBUG   [MainThread] => {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/lz/code/c10k-server/a.cpp"},"position":{"line":4,"character":10}}}
14:10:22 DEBUG   [RPC-cpp   ] <= {"jsonrpc":"2.0","method":"$cquery/progress","params":{"indexRequestCount":0,"doIdMapCount":0,"loadPreviousIndexCount":0,"onIdMappedCount":0,"onIndexedCount":0}}
14:10:22 WARNING [RPC-cpp   ] no handler implemented for $cquery_progress
14:10:22 DEBUG   [RPC-cpp   ] <= {"jsonrpc":"2.0","method":"$cquery/progress","params":{"indexRequestCount":0,"doIdMapCount":0,"loadPreviousIndexCount":0,"onIdMappedCount":0,"onIndexedCount":0}}
14:10:22 WARNING [RPC-cpp   ] no handler implemented for $cquery_progress
14:10:22 DEBUG   [RPC-cpp   ] <= {"jsonrpc":"2.0","method":"$cquery/progress","params":{"indexRequestCount":0,"doIdMapCount":0,"loadPreviousIndexCount":0,"onIdMappedCount":0,"onIndexedCount":0}}
14:10:22 WARNING [RPC-cpp   ] no handler implemented for $cquery_progress
# No completion result received after 5 minutes

I tried to debug it and found threads occupying 100% CPU were all running std::string::_S_construct. GDB log is attached at https://gist.github.com/htfy96/61969e3939b69f9e3320e25ad63b5794, and here is
LanguageServer.log.
I was just wondering is this a bug or the expected behavior?

Add support for code formatting LSP operations

We should add at least support for textDocument/formatting, which formats the whole document, and textDocument/rangeFormatting, which formats a particular region of code.

Use clang-format as formatting engine and make sure styles are supported.

Type Hierarchy and Call Hierarchy trees are confusing.

Two issues here:
1- Clicking a tree item doesn't do anything.
2- You keep adding to the same tree with each invocation, which makes it very confusing. By default it
should clear the tree and repopulate, and provide some mechanism to view history of hierarchies
invoked earlier.

cquery doesnt understand relative paths in compile_commands.json

Build cquery:

% cd cquery
% ./waf configure
% ./waf build
# generates build/app

neovim configuration:

Install https://github.com/autozimu/LanguageClient-neovim

# Courtesy of https://github.com/autozimu/LanguageClient-neovim/wiki/cquery
let g:LanguageClient_serverCommands = {
    \ 'cpp': ['..../cquery/build/app', '--language-server'],
    \ }
let g:LanguageClient_loadSettings = 1
% cd $PROJECT
% cat .vim/settings.json
{
        "initializationOptions": {
                "cacheDirectory": "/tmp/cquery"
        }
}
% mkdir /tmp/cquery

Editing in neovim

Edit an file with neovim.

% cd /tmp/c
% cat > a.cc <<e
int foo() { return 42; }
int main() { return foo(); }
e
% echo 'a: a.cc' > Makefile
% bear make  # courtesy of https://github.com/rizsotto/Bear
# generates compile_commands.json
% cd /tmp; ln -s ~/Dev/Util/cquery/clang_resource_dir  # by default, cquery somehow sets -resource-dir=/tmp/c/../clang_resource_dir  # I have to use the hack here
% nvim a.cc
:LanguageClientStart
:call LanguageClient_textDocument_hover()
neovim complains {"jsonrpc": "2.0", "error": {"code": -32603, "message": "Unable to find file /tmp/c/a.cc"}, "id": 1}

compile_commands.json:

[
    {
        "arguments": [
            "c++",
            "-c",
            "-o",
            "a",
            "a.cc"
        ],
        "directory": "/tmp/c",
        "file": "a.cc"
    }
]

cquery_diagnostics.log:

arguments: /home/maskray/Dev/Util/cquery/build/app --language-server
Current dir: /tmp/c
File verbosity level: 9
date       time         ( uptime  ) [ thread name/id ]                   file:line     v| 
2017-11-18 22:34:42.796 (   0.000s) [main thread     ]             loguru.hpp:1952     0| Logging to 'cquery_diagnostics.log', mode: 'w', verbosity: 9
2017-11-18 22:34:42.797 (   0.001s) [querydb         ]        command_line.cc:1429     0| [querydb] Initialize in directory /tmp/c with uri file:///tmp/c
2017-11-18 22:34:42.797 (   0.001s) [querydb         ]        command_line.cc:1480     0| Using -resource-dir=/home/maskray/Dev/Util/cquery/clang_resource_dir
2017-11-18 22:34:42.797 (   0.001s) [stdout          ]               timer.cc:38       0| [e2e] Running initialize took 0.383ms
2017-11-18 22:34:42.797 (   0.001s) [querydb         ]        command_line.cc:1557     0| Starting 3 indexers
2017-11-18 22:34:42.797 (   0.001s) [querydb         ]             project.cc:235      0| Trying to load compile_commands.json
2017-11-18 22:34:42.798 (   0.001s) [querydb         ]               timer.cc:38       0| compile_commands.json clang time took 0.40ms
2017-11-18 22:34:42.798 (   0.001s) [querydb         ]               timer.cc:38       0| compile_commands.json our time took 0.31ms
2017-11-18 22:34:42.798 (   0.001s) [querydb         ]               timer.cc:38       0| [perf] Loaded compilation entries (1 files) took 0.303ms
2017-11-18 22:34:42.798 (   0.002s) [querydb         ]               timer.cc:38       0| [perf] Dispatched initial index requests took 0.5ms
2017-11-18 22:34:42.798 (   0.002s) [include_scanner ]               timer.cc:38       0| [perf] Scanning for includes took 0.428ms
2017-11-18 22:34:42.799 (   0.002s) [indexer2        ]        command_line.cc:950      0| Parsing /tmp/c/a.cc
2017-11-18 22:34:42.802 (   0.006s) [stdin           ] language_server_api.cc:164    ERR| Unable to find registered handler for method "workspace/didChangeConfiguration"

2017-11-18 22:34:42.806 (   0.010s) [querydb         ]        command_line.cc:118      0| Unable to find file "/tmp/c/a.cc"
2017-11-18 22:34:42.806 (   0.010s) [querydb         ]               timer.cc:38       0| [querydb] Loading cached index file for DidOpen (blocks CodeLens) took 0.137ms
2017-11-18 22:34:42.806 (   0.010s) [completeparse   ]      clang_complete.cc:273      0| Creating completion session with arguments c++, a.cc, -xc++, -std=c++11, -resource-dir=/home/maskray/Dev/Util/cquery/clang_resource_dir, -fparse-all-comments, -fspell-checking
2017-11-18 22:34:42.806 (   0.010s) [indexer0        ]        command_line.cc:950      0| Parsing /tmp/c/a.cc
2017-11-18 22:34:42.830 (   0.034s) [indexer2        ]clang_translation_unit.cc:49     ERR| libclang had ast read error for /tmp/c/a.cc with args c++, a.cc, -xc++, -std=c++11, -resource-dir=/home/maskray/Dev/Util/cquery/clang_resource_dir
2017-11-18 22:34:42.831 (   0.035s) [indexer0        ]clang_translation_unit.cc:49     ERR| libclang had ast read error for /tmp/c/a.cc with args c++, a.cc, -xc++, -std=c++11, -resource-dir=/home/maskray/Dev/Util/cquery/clang_resource_dir
2017-11-18 22:34:42.832 (   0.036s) [completeparse   ]clang_translation_unit.cc:49     ERR| libclang had ast read error for /tmp/c/a.cc with args c++, a.cc, -xc++, -std=c++11, -resource-dir=/home/maskray/Dev/Util/cquery/clang_resource_dir, -fparse-all-comments, -fspell-checking
2017-11-18 22:34:48.720 (   5.924s) [querydb         ]        command_line.cc:118      0| Unable to find file "/tmp/c/a.cc"
2017-11-18 22:35:01.246 (  18.450s) [querydb         ]        command_line.cc:118      0| Unable to find file "/tmp/c/a.cc"
Stack trace:
7       0x7fe08534aa8f clone + 63
6       0x7fe0860a9494 /lib/x86_64-linux-gnu/libpthread.so.0(+0x7494) [0x7fe0860a9494]
5       0x7fe085bd5e6f /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb9e6f) [0x7fe085bd5e6f]
4             0x52ef8d /home/maskray/Dev/Util/cquery/build/app() [0x52ef8d]
3             0x43b509 /home/maskray/Dev/Util/cquery/build/app() [0x43b509]
2             0x47d6ea /home/maskray/Dev/Util/cquery/build/app() [0x47d6ea]
1             0x47c1bc /home/maskray/Dev/Util/cquery/build/app() [0x47c1bc]
0             0x47ff46 /home/maskray/Dev/Util/cquery/build/app() [0x47ff46]
2017-11-18 22:36:12.495 (  89.699s) [stdin           ] language_server_api.cc:129   FATL| std::cin.good() is false; exiting

app: ... rapidjson/document.h:1731: ... Assertion `IsString()' failed.

Hi Jakob,

first I want to thank for your work on cquery! :)

I just tried running cquery with vscode and looking at the output section of cquery I'm getting all the time output like:

0  libclang.so.4   0x00007fc3839e4735
1  libclang.so.4   0x00007fc3839e4d76
2  libpthread.so.0 0x00007fc382046390
3  libc.so.6       0x00007fc3811fb428 gsignal + 56
4  libc.so.6       0x00007fc3811fd02a abort + 362
5  libc.so.6       0x00007fc3811f3bd7
6  libc.so.6       0x00007fc3811f3c82
7  app             0x0000000000510113
8  app             0x000000000045bb95
9  app             0x000000000045b83f
10 app             0x000000000045b5dc
11 app             0x000000000047f1a3
12 app             0x000000000047ebb3
13 app             0x000000000043c68c
14 app             0x00000000005329dd
15 libstdc++.so.6  0x00007fc381b67c80
16 libpthread.so.0 0x00007fc38203c6ba
17 libc.so.6       0x00007fc3812cd3dd clone + 109
[Info  - 12:34:23 PM] Connection to server got closed. Server will restart.
date       time         ( uptime  ) [ thread name/id ]                   file:line     v| 
2017-11-18 12:34:23.671 (   0.000s) [main thread     ]             loguru.hpp:1794     0| arguments: ./app --language-server
2017-11-18 12:34:23.671 (   0.000s) [main thread     ]             loguru.hpp:1797     0| Current dir: /home/dan/builds/cquery/build
2017-11-18 12:34:23.671 (   0.000s) [main thread     ]             loguru.hpp:1799     0| stderr verbosity: 0
2017-11-18 12:34:23.671 (   0.000s) [main thread     ]             loguru.hpp:1800     0| -----------------------------------
2017-11-18 12:34:23.671 (   0.000s) [main thread     ]             loguru.hpp:1952     0| Logging to 'cquery_diagnostics.log', mode: 'w', verbosity: 9
app: ../third_party/rapidjson/include/rapidjson/document.h:1731: const Ch *rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::GetString() const [Encoding = rapidjson::UTF8<char>, Allocator = rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>]: Assertion `IsString()' failed.

I'm on Ubuntu 16.04 and using vscode 1.18.1.

The output might indicate there's something wrong with my compile_commands.json which works fine with rtags. So here's just one entry of it:

{
  "directory": "/home/dan/intes/builds/trunk/debug/visper/src/sceneGraph",
  "command": "/usr/bin/g++49 -m64  -DAPPLICATIONMINOR=\"\" -DBUILDING_LIBS -DCONFIG_H=\\\"/home/dan/intes/src/trunk/visper/visper/src/config/vpConfig.linux-64.h\\\" -DFW_ENABLE_TASKLETS -DFW_SYSSTR=\\\"linux-64\\\" -DFW_VERS=\\\"0.62\\\" -DFW_VERS_MINOR=62 -DQT3_SUPPORT -DQT_3SUPPORT_LIB -DQT_CORE_LIB -DQT_DEBUG -DQT_DLL -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_OPENGL_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DQT_STATICPLUGIN -DQT_SVG_LIB -DQT_UITOOLS_LIB -DQT_XML_LIB -DSGA_OSG -DSHARED_LIBS -DSYSTEM=\\\"linux-64\\\" -DVISPER_VERS_PATCH=\\\"-dev\\\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -DsceneGraph_EXPORTS -g3 -ggdb  -Wall -W -Wno-unused-parameter -Wno-non-virtual-dtor -Wno-strict-aliasing -fPIC -I/home/dan/intes/builds/trunk/debug/visper/src/sceneGraph -I/home/dan/intes/src/trunk/visper/visper/src/sceneGraph -I/home/dan/intes/src/trunk/visper/visper -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/Qt3Support -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtOpenGL -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtScript -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtSvg -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtUiTools -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtGui -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtXml -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtSql -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtNetwork -isystem /proj/sciviz/framework-3rd/centos4u4_64/qt-sc.iViz_sciviz-4.6.3-2/include/QtCore -I/home/dan/intes/src/trunk/visper/visper/src -I/home/dan/intes/src/trunk/visper/framework -I/proj/sciviz/framework-3rd/centos4u4_64/python-2.7.2-static_socket_scivizFrame_0.62/include/python2.7 -I/proj/sciviz/framework-3rd/misc/boost_1_63_0 -I/home/dan/intes/src/trunk/visper/visper/src/sceneGraph/nodes -I/home/dan/intes/src/trunk/visper/visper/src/sceneGraph/visualStates    -o CMakeFiles/sceneGraph.dir/SgManager.cpp.o -c /home/dan/intes/src/trunk/visper/visper/src/sceneGraph/SgManager.cpp",
  "file": "/home/dan/intes/src/trunk/visper/visper/src/sceneGraph/SgManager.cpp"
}

Thanks for any hints!

Greetings,
Daniel

Waf: The wscript in ... is unreadable

./waf configure
Waf: The wscript in '/home/agauniyal/projects/cquery' is unreadable
Traceback (most recent call last):
  File "/home/agauniyal/projects/cquery/.waf3-1.9.8-17756245c4cc550633dacf3b08eec42a/waflib/Scripting.py", line 104, in waf_entry_point
    set_main_module(os.path.normpath(os.path.join(Context.run_dir,Context.WSCRIPT_FILE)))
  File "/home/agauniyal/projects/cquery/.waf3-1.9.8-17756245c4cc550633dacf3b08eec42a/waflib/Scripting.py", line 135, in set_main_module
    Context.g_module=Context.load_module(file_path)
  File "/home/agauniyal/projects/cquery/.waf3-1.9.8-17756245c4cc550633dacf3b08eec42a/waflib/Context.py", line 353, in load_module
    exec(compile(code,path,'exec'),module.__dict__)
  File "/home/agauniyal/projects/cquery/wscript", line 4, in <module>
    from urllib2 import urlopen # Python 2
ModuleNotFoundError: No module named 'urllib2'

Arch Linux has python3 as default ๐Ÿ˜›

waf needs to support python==python3 (was: Can't build on macOS)

โŸฉ ./waf configure

bunzip2: Data integrity error when decompressing.
	Input file = t.bz2, output file = t

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

bunzip2: Deleting output file t, if it exists.
Error: Waf cannot be unpacked, check that bzip2 support is present

bzip2 is installed.

Errors when building with gcc ; make gcc required for CI

I removed -Werror to show all errors as warning

Click to expand

Waf: Entering directory `/home/david/workspace/cpp/cquery/build'
CLANG_INCLUDE_DIR: /home/david/workspace/cpp/cquery/build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/include
CLANG_LIB_DIR:     /home/david/workspace/cpp/cquery/build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/lib
[ 1/33] Compiling src/cache.cc
[ 2/33] Compiling src/clang_complete.cc
[ 3/33] Compiling src/clang_cursor.cc
[ 4/33] Compiling src/clang_index.cc
[ 5/33] Compiling src/clang_translation_unit.cc
[ 6/33] Compiling src/clang_utils.cc
[ 7/33] Compiling src/command_line.cc
[ 8/33] Compiling src/file_consumer.cc
[ 9/33] Compiling src/include_complete.cc
../src/clang_complete.cc: In member function โ€˜void LruSessionCache::InsertEntry(std::shared_ptr<CompletionSession>)โ€™:
../src/clang_complete.cc:506:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (entries_.size() && entries_.size() >= max_entries_)
                          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~

[10/33] Compiling src/indexer.cc
[11/33] Compiling src/ipc.cc
[12/33] Compiling src/ipc_manager.cc
../src/include_complete.cc: In function โ€˜std::__cxx11::string {anonymous}::ElideLongPath(Config*, const string&)โ€™:
../src/include_complete.cc:23:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (path.size() <= config->includeCompletionMaximumPathLength)
       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[13/33] Compiling src/language_server_api.cc
[14/33] Compiling src/lex_utils.cc
../src/lex_utils.cc: In function โ€˜lsPosition CharPos(const string&, char, int)โ€™:
../src/lex_utils.cc:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (index < search.size()) {
          ~~~~~~^~~~~~~~~~~~~~~
In file included from /nix/store/dpza5shcrnf4m8rjsbxb34hf1vnppbbp-gcc-6.4.0/include/c++/6.4.0/cassert:44:0,
                 from ../third_party/rapidjson/include/rapidjson/rapidjson.h:401,
                 from ../third_party/rapidjson/include/rapidjson/allocators.h:18,
                 from ../third_party/rapidjson/include/rapidjson/reader.h:20,
                 from ../third_party/rapidjson/include/rapidjson/document.h:20,
                 from ../src/serializer.h:5,
                 from ../src/config.h:3,
                 from ../src/language_server_api.h:3,
                 from ../src/lex_utils.h:3,
                 from ../src/lex_utils.cc:1:
../src/lex_utils.cc:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   assert(index < search.size());
          ~~~~~~^~~~~~~~~~~~~~~
../src/lex_utils.cc: In function โ€˜std::experimental::optional<lsRange> ExtractQuotedRange(int, const string&)โ€™:
../src/lex_utils.cc:56:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (start < line.size()) {
          ~~~~~~^~~~~~~~~~~~~
../src/lex_utils.cc:62:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (start == line.size())
       ~~~~~~^~~~~~~~~~~~~~
../src/lex_utils.cc: In function โ€˜void LexFunctionDeclaration(const string&, lsPosition, std::experimental::optional<std::__cxx11::basic_string<char> >, std::__cxx11::string*, int*)โ€™:
../src/lex_utils.cc:90:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (name_end < buffer_content.size()) {
            ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../src/lex_utils.cc:143:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (end < buffer_content.size()) {
          ~~~~^~~~~~~~~~~~~~~~~~~~~~~
../src/lex_utils.cc: In function โ€˜std::__cxx11::string LexWordAroundPos(lsPosition, const string&)โ€™:
../src/lex_utils.cc:177:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while ((end + 1) < content.size()) {
          ~~~~~~~~~~^~~~~~~~~~~~~~~~
../src/lex_utils.cc: In function โ€˜void _DOCTEST_ANON_FUNC_6()โ€™:
../src/lex_utils.cc:226:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < content.size(); ++i) {
                   ~~^~~~~~~~~~~~~~~~

[15/33] Compiling src/match.cc
../src/language_server_api.cc: In function โ€˜std::experimental::optional<std::__cxx11::basic_string<char> > ReadJsonRpcContentFrom(std::function<std::experimental::optional<char>()>)โ€™:
../src/language_server_api.cc:73:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (size_t i = 0; i < content_length; ++i) {
                      ~~^~~~~~~~~~~~~~~~

[16/33] Compiling src/options.cc
[17/33] Compiling src/platform.cc
[18/33] Compiling src/platform_linux.cc
../src/indexer.cc: In member function โ€˜std::experimental::optional<std::__cxx11::basic_string<char> > {anonymous}::ConstructorCache::TryFindConstructorUsr(const string&, const std::vector<std::__cxx11::basic_string<char> >&)โ€™:
../src/indexer.cc:178:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
            i < std::min(param_type_desc.size(), ctor.param_type_desc.size());
            ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[19/33] Compiling src/platform_win.cc
[20/33] Compiling src/position.cc
../src/platform_linux.cc: In function โ€˜std::__cxx11::string NormalizePath(const string&)โ€™:
../src/platform_linux.cc:160:38: warning: ignoring return value of โ€˜char* realpath(const char*, char*)โ€™, declared with attribute warn_unused_result [-Wunused-result]
   (void) realpath(path.c_str(), name);
                                      ^

[21/33] Compiling src/project.cc
[22/33] Compiling src/query.cc
[23/33] Compiling src/query_utils.cc
../src/project.cc: In function โ€˜int {anonymous}::ComputeGuessScore(const string&, const string&)โ€™:
../src/project.cc:311:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i = 0; i < a.length() && i < b.length(); ++i) {
               ~~^~~~~~~~~~~~
../src/project.cc:311:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i = 0; i < a.length() && i < b.length(); ++i) {
                                 ~~^~~~~~~~~~~~
../src/project.cc:318:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = i; j < a.length(); ++j) {
                   ~~^~~~~~~~~~~~
../src/project.cc:322:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = i; j < b.length(); ++j) {
                   ~~^~~~~~~~~~~~
../src/project.cc:329:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int offset = 1; offset <= a.length() && offset <= b.length(); ++offset) {
                        ~~~~~~~^~~~~~~~~~~~~
../src/project.cc:329:55: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int offset = 1; offset <= a.length() && offset <= b.length(); ++offset) {
                                                ~~~~~~~^~~~~~~~~~~~~
../src/project.cc: In member function โ€˜void Project::Load(const std::vector<std::__cxx11::basic_string<char> >&, const string&, const string&)โ€™:
../src/project.cc:366:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < entries.size(); ++i)
                   ~~^~~~~~~~~~~~~~~~
../src/project.cc: In member function โ€˜void Project::ForAllFilteredFiles(Config*, std::function<void(int, const Project::Entry&)>)โ€™:
../src/project.cc:400:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < entries.size(); ++i) {
                   ~~^~~~~~~~~~~~~~~~
../src/project.cc: In function โ€˜void CheckFlags(const string&, const string&, std::vector<std::__cxx11::basic_string<char> >, std::vector<std::__cxx11::basic_string<char> >)โ€™:
../src/project.cc:434:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < std::min(result.args.size(), expected.size()); ++i) {
                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[24/33] Compiling src/serializer.cc
[25/33] Compiling src/standard_includes.cc
[26/33] Compiling src/task.cc
[27/33] Compiling src/test.cc
[28/33] Compiling src/third_party_impl.cc
../src/test.cc: In function โ€˜void DiffDocuments(std::__cxx11::string, std::__cxx11::string, rapidjson::Document&, rapidjson::Document&)โ€™:
../src/test.cc:49:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < len; ++i) {
                   ~~^~~~~

[29/33] Compiling src/timer.cc
[30/33] Compiling src/utils.cc
[31/33] Compiling src/work_thread.cc
[32/33] Compiling src/working_files.cc
../src/command_line.cc: In function โ€˜bool QueryDbMainLoop(Config*, QueryDatabase*, bool*, MultiQueueWaiter*, {anonymous}::QueueManager*, Project*, FileConsumer::SharedState*, {anonymous}::ImportManager*, {anonymous}::TimestampManager*, WorkingFiles*, ClangCompleteManager*, IncludeComplete*, {anonymous}::CodeCompleteCache*, {anonymous}::CodeCompleteCache*, {anonymous}::CodeCompleteCache*)โ€™:
../src/command_line.cc:1974:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             msg->params.position.line < file->all_buffer_lines.size())
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc: In lambda function:
../src/command_line.cc:2134:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (active_param < response.result.signatures.size()) {
                     ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc: In function โ€˜bool QueryDbMainLoop(Config*, QueryDatabase*, bool*, MultiQueueWaiter*, {anonymous}::QueueManager*, Project*, FileConsumer::SharedState*, {anonymous}::ImportManager*, {anonymous}::TimestampManager*, WorkingFiles*, ClangCompleteManager*, IncludeComplete*, {anonymous}::CodeCompleteCache*, {anonymous}::CodeCompleteCache*, {anonymous}::CodeCompleteCache*)โ€™:
../src/command_line.cc:2604:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < db->detailed_names.size(); ++i) {
                             ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc:2858:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < db->detailed_names.size(); ++i) {
                         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc:2866:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (response.result.size() >= config->maxWorkspaceSearchResults)
                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc:2871:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (response.result.size() < config->maxWorkspaceSearchResults) {
             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc:2872:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           for (int i = 0; i < db->detailed_names.size(); ++i) {
                           ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/command_line.cc:2880:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               if (response.result.size() >= config->maxWorkspaceSearchResults)
                   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/working_files.cc: In function โ€˜lsPosition {anonymous}::GetPositionForOffset(const string&, int)โ€™:
../src/working_files.cc:13:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (offset >= content.size())
       ~~~~~~~^~~~~~~~~~~~~~~~~
../src/working_files.cc: In member function โ€˜void WorkingFile::SetIndexContent(const string&)โ€™:
../src/working_files.cc:47:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < index_lines.size(); ++i) {
                   ~~^~~~~~~~~~~~~~~~~~~~
../src/working_files.cc: In member function โ€˜void WorkingFile::OnBufferContentUpdated()โ€™:
../src/working_files.cc:64:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < all_buffer_lines.size(); ++i) {
                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~
../src/working_files.cc: In member function โ€˜std::experimental::optional<int> WorkingFile::GetBufferLineFromIndexLine(int) constโ€™:
../src/working_files.cc:88:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (index_line < 1 || index_line > index_lines.size()) {
                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
../src/working_files.cc: In member function โ€˜std::experimental::optional<int> WorkingFile::GetIndexLineFromBufferLine(int) constโ€™:
../src/working_files.cc:125:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (buffer_line < 1 || buffer_line > all_buffer_lines.size()) {
                          ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
../src/working_files.cc: In member function โ€˜std::experimental::optional<std::__cxx11::basic_string<char> > WorkingFile::GetBufferLineContentFromIndexLine(int, std::experimental::optional<int>*) constโ€™:
../src/working_files.cc:167:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (*buffer_line < 1 || *buffer_line >= all_buffer_lines.size()) {
                           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
../src/working_files.cc: In member function โ€˜void WorkingFiles::OnClose(const Ipc_TextDocumentDidClose::Params&)โ€™:
../src/working_files.cc:361:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < files.size(); ++i) {
                   ~~^~~~~~~~~~~~~~

../src/query.cc: In member function โ€˜QueryFuncId IdMap::ToQuery(IndexFuncId) constโ€™:
../src/query.cc:307:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (id.id == -1)
       ~~~~~~^~~~~
../src/query.cc: In member function โ€˜void QueryDatabase::UpdateDetailedNames(size_t*, SymbolKind, size_t, const string&)โ€™:
../src/query.cc:817:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (*qualified_name_index == -1) {
       ~~~~~~~~~~~~~~~~~~~~~~^~~~~

Waf: Leaving directory `/home/david/workspace/cpp/cquery/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (33.769s)

reuse existing libclang.so when possible

It seems that waf does recognize installed clang but nonetheless still downloads its own version:

$ ./waf configure
Setting top to                           : /home/sergei/src/cquery
Setting out to                           : /home/sergei/src/cquery/build
Checking for 'clang++' (C++ compiler)    : /home/sergei/opt/clang/bin/clang++
Checking for header stdio.h              : yes
Checking for clang
Downloading tarball
   destination: build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
   source:      http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
Extracting
'configure' finished successfully (1m45.455s)

Fuzzy symbol search is broken

It just doesn't find anything I'm looking for anymore. Displays tons of results non of them is what I'm looking for.

cquery fails to build on macOS

The build fails with the following error:

[23/33] Compiling src/query_utils.cc
In file included from ../src/query_utils.cc:1:
In file included from ../src/query_utils.h:5:
In file included from ../src/query.h:3:
In file included from ../src/indexer.h:5:
In file included from ../src/clang_utils.h:3:
In file included from ../src/language_server_api.h:4:
In file included from ../src/ipc.h:4:
../src/utils.h:132:16: error: implicit instantiation of undefined template 'std::__1::hash<SymbolKind>'
  std::hash<T> hasher;
               ^
../src/query.h:86:1: note: in instantiation of function template specialization 'hash_combine<SymbolKind, unsigned long>' requested here
MAKE_HASHABLE(SymbolIdx, t.kind, t.idx);
^
../src/utils.h:143:7: note: expanded from macro 'MAKE_HASHABLE'
      hash_combine(ret, __VA_ARGS__);             \
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:397:50: note: template is declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
                                                 ^
1 error generated.

In file included from ../src/query.cc:1:
In file included from ../src/query.h:3:
In file included from ../src/indexer.h:5:
In file included from ../src/clang_utils.h:3:
In file included from ../src/language_server_api.h:4:
In file included from ../src/ipc.h:4:
../src/utils.h:132:16: error: implicit instantiation of undefined template 'std::__1::hash<SymbolKind>'
  std::hash<T> hasher;
               ^
../src/query.h:86:1: note: in instantiation of function template specialization 'hash_combine<SymbolKind, unsigned long>' requested here
MAKE_HASHABLE(SymbolIdx, t.kind, t.idx);
^
../src/utils.h:143:7: note: expanded from macro 'MAKE_HASHABLE'
      hash_combine(ret, __VA_ARGS__);             \
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:397:50: note: template is declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
                                                 ^
1 error generated.

In file included from ../src/command_line.cc:3:
In file included from ../src/clang_complete.h:4:
In file included from ../src/language_server_api.h:4:
In file included from ../src/ipc.h:4:
../src/utils.h:132:16: error: implicit instantiation of undefined template 'std::__1::hash<SymbolKind>'
  std::hash<T> hasher;
               ^
../src/query.h:86:1: note: in instantiation of function template specialization 'hash_combine<SymbolKind, unsigned long>' requested here
MAKE_HASHABLE(SymbolIdx, t.kind, t.idx);
^
../src/utils.h:143:7: note: expanded from macro 'MAKE_HASHABLE'
      hash_combine(ret, __VA_ARGS__);             \
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:397:50: note: template is declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
                                                 ^
1 error generated.
> clang --version
clang version 4.0.0 (trunk 287636)
Target: x86_64-apple-darwin17.0.0

Docs for how to use vscode on cquery source

I could use basic instructions like:

  • Which directory do I launch vscode from, /w/cquery or /w/cquery/src ?
  • Should I try to use build/compile_commands.json ?
  • Where are all the hard-coded paths I need to change?
  • Which compiler do I use to generate cquery.index.extraClangArguments ?

Add clang-format file

I use the ./format.sh and ./format.ps1 scripts to do formatting, but for those who format in-editor a clang-format specifying Chromium style would be very helpful.

Polish before publishing

Higher priority items I'd like to get addressed before publishing to the marketplace

  • make sure we don't load cached file if real file is not present
  • Very make_unique contributes constructor calls
  • extern const char not included in outline? see ash_switches.h
  • show warning for compile_commands.json, autogen if possible; maybe git rev-parse origin/master ; or git rev-parse HEAD
  • Verify when loading project we add to end of queue so existing open files are indexed first
  • we don't need to reindex file unless it has timestamp change, ever, try to add metrics to count how many files get updated after sync
  • reindex file is command line arguments change
  • max number of code lens results otherwise vscode will hang if the file has 20k+ code lens
  • Mention how to disable code lens in README
  • Drop clang_args in favor of pref or move to .cquery or similar
  • clang arg pref should be platform specific
  • Only status update every few hundred milliseconds
  • Reduce output
  • index perf: don't run every DoIdMap; stop after 500 or 1000 iterations
  • Move completion entirely off querydb thread so it never touches querydb
  • progress indicator needs to account for index threads which are busy (ie, +1 to a job when they remove the item from the queue until it is done being processed)

Misc issues that need to be dealt with at some point

  • Make warning "launch.workingDirectory" say "cquery.launch.workingDirectory"
  • std::sting -> std::string typo fixit does replaces trailing text content/space, it should insert the new string instead of replacing, likely a bug in FixIt generation
  • Fix show references for function declaration parameters
  • Code lens causing screen to scroll - microsoft/vscode#12294
  • Show warning for old pref names
  • No reload notification when adding new pref that changes from default value (include.blacklist)
  • Find ref on lambda parameter
  • gv on variable should show variables of the same type
  • Freshen should drop existing index
  • labeled stack traces on linux
  • Insert include by typing a symbol (ie, global symbol search)
  • see if we can set code lens command title to show custom string
  • Prefer smallest path found for include when scanning
  • Clickable controls in tooltips - microsoft/vscode#29076
  • See if we can integrate commit characters for code completion
  • Auto-implement doesn't strip override
  • Auto-implement select implemented content for fast ctrl-x ctrl-v
  • Call tree in context menu
  • Call tree - use icon for base/derived calls
  • Completion list private with - or similar
  • Don't show errors for ie, *.mojom files
  • Add task to reload compile_commands.json
  • Call tree should store index lines and look it up when the user requests goto definition
  • Add task to drop existing index and do a fresh import
  • Reparse top document - might be possible by hooking directly into extension API and sending a notification $cquery/onView
  • Call hierarchy; show class name and line, skip column MyMethod (Foobar:3). If no class name show file MyMethod (foo.cc:3)
  • Call hierarchy: sort by file and then by location in that file
  • Call tree fails on pure-virtual functions
  • Investigate jemalloc
  • Do not report global completions in certain situations, ie, o not report global completions in certain situations, ie, Example: type this: class Foo : public Bar {public:
  • Idea: only do live-indexing after a save, but use completion thread to do it.

Add docs about the emacs-client and how to configure it

Thanks for including the emacs-client!

It would be nice mention the emacs-client in the docs/README.

It would also be helpful to provide an example of what needs to be added to Emacs config to start using this client.

Which key combinations/commands one should use when editing the file to trigger the auto-completion, etc?

If this client is known to have conflicts with some other popular Emacs modes like e.g. ycmd or company-clang, it would be useful to mention what needs to be disabled or configured differently to make sure that cquery emacs client is used.

These emacs-client specific docs could be probably placed in the emacs sub-directory, together with the client's source code.

@topisani You are probably the best candidate for providing this information, or? :-)

False Positive: Source file is not valid UTF-8

I sometimes get a 'source file is not valid UTF-8' error when editing C++ code with cquery. Haven't been able to find out how to reproduce it.

a

Commenting/uncommenting line doesn't remove the error. Removing and pasting all the code in the file does remove the error

Link failure on Ubuntu using clang 3.4

[33/33] Linking build/app
src/cache.cc.1.o: In function constexpr_storage_t<const int &>': /work2/cquery/build/../third_party/optional.h:292: undefined reference to IndexFile::kCurrentVersion'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I fixed it by switching the constexpr kCurrentVersion to a normal static const defined in the .cc file:

const int IndexFile::kCurrentVersion = 4;

Build cquery failed on Ubuntu 17.10

compiler version

bingo@bingo-huawei cquery (master) $ clang++ --version
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/bingo/my/clang/bin
bingo@bingo-huawei cquery (master) $ g++ --version
g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bingo@bingo-huawei cquery (master) $ gcc --version
gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

compile

bingo@bingo-huawei cquery (master) $ ./waf configure
Setting top to                           : /data/saibing/git/c++/cquery 
Setting out to                           : /data/saibing/git/c++/cquery/build 
Checking for 'clang++' (C++ compiler)    : /home/bingo/my/clang/bin/clang++ 
Checking for header stdio.h              : yes 
Checking for clang
Found tarball at build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
Extracting
'configure' finished successfully (31.212s)


bingo@bingo-huawei cquery (master) $ ./waf build
Waf: Entering directory `/data/saibing/git/c++/cquery/build'
CLANG_INCLUDE_DIR: /data/saibing/git/c++/cquery/build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/include
CLANG_LIB_DIR:     /data/saibing/git/c++/cquery/build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/lib
[ 1/33] Compiling src/cache.cc
[ 2/33] Compiling src/clang_complete.cc
[ 3/33] Compiling src/clang_cursor.cc
[ 4/33] Compiling src/clang_index.cc
[ 5/33] Compiling src/clang_translation_unit.cc
[ 6/33] Compiling src/clang_utils.cc
[ 7/33] Compiling src/command_line.cc
[ 8/33] Compiling src/file_consumer.cc
[ 9/33] Compiling src/include_complete.cc
[10/33] Compiling src/indexer.cc
[11/33] Compiling src/ipc.cc
[12/33] Compiling src/ipc_manager.cc
[13/33] Compiling src/language_server_api.cc
[14/33] Compiling src/lex_utils.cc
../src/command_line.cc:3263:3: error: expected expression
  TEST_CASE("simple") {
  ^
../third_party/doctest/doctest/doctest.h:1624:19: note: expanded from macro 'TEST_CASE'
#define TEST_CASE DOCTEST_TEST_CASE
                  ^
../third_party/doctest/doctest/doctest.h:1199:5: note: expanded from macro 'DOCTEST_TEST_CASE'
    DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
    ^
../third_party/doctest/doctest/doctest.h:1193:5: note: expanded from macro 'DOCTEST_CREATE_AND_REGISTER_FUNCTION'
    static void f();                                                                               \
    ^
../src/command_line.cc:3354:2: error: expected ';' after top level declarator
}
 ^
 ;
../src/command_line.cc:3357:3: error: expected expression
  TEST_CASE("edges") {
  ^
../third_party/doctest/doctest/doctest.h:1624:19: note: expanded from macro 'TEST_CASE'
#define TEST_CASE DOCTEST_TEST_CASE
                  ^
../third_party/doctest/doctest/doctest.h:1199:5: note: expanded from macro 'DOCTEST_TEST_CASE'
    DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
    ^
../third_party/doctest/doctest/doctest.h:1193:5: note: expanded from macro 'DOCTEST_CREATE_AND_REGISTER_FUNCTION'
    static void f();                                                                               \
    ^
../src/command_line.cc:3389:2: error: expected ';' after top level declarator
}
 ^
 ;
../src/command_line.cc:3392:3: error: expected expression
  TEST_CASE("in document") {
  ^
../third_party/doctest/doctest/doctest.h:1624:19: note: expanded from macro 'TEST_CASE'
#define TEST_CASE DOCTEST_TEST_CASE
                  ^
../third_party/doctest/doctest/doctest.h:1199:5: note: expanded from macro 'DOCTEST_TEST_CASE'
    DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
    ^
../third_party/doctest/doctest/doctest.h:1193:5: note: expanded from macro 'DOCTEST_CREATE_AND_REGISTER_FUNCTION'
    static void f();                                                                               \
    ^
../src/command_line.cc:3445:2: error: expected ';' after top level declarator
}
 ^
 ;
6 errors generated.

../src/language_server_api.cc:99:3: error: expected expression
  TEST_CASE("ReadContentFromSource") {
  ^
../third_party/doctest/doctest/doctest.h:1624:19: note: expanded from macro 'TEST_CASE'
#define TEST_CASE DOCTEST_TEST_CASE
                  ^
../third_party/doctest/doctest/doctest.h:1199:5: note: expanded from macro 'DOCTEST_TEST_CASE'
    DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
    ^
../third_party/doctest/doctest/doctest.h:1193:5: note: expanded from macro 'DOCTEST_CREATE_AND_REGISTER_FUNCTION'
    static void f();                                                                               \
    ^
../src/language_server_api.cc:122:2: error: expected ';' after top level declarator
}
 ^
 ;
2 errors generated.

Seems not able to index in Webkit

I have not setup blacklist.

Log:

Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
[e2e] Running $cout took 1723441.1721718436ms
[Error - 11:23:52 AM] Request textDocument/hover failed.
  Message: Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
  Code: -32603 
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
[e2e] Running $cout took 1723697.1721973611ms
[Error - 11:23:53 AM] Request textDocument/documentHighlight failed.
  Message: Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
  Code: -32603 
Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
[e2e] Running $cout took 1723920.1722196792ms
[Error - 11:23:53 AM] Request textDocument/codeAction failed.
  Message: Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
  Code: -32603 
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)
Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
[e2e] Running $cout took 1725442.1723717369ms
[Error - 11:23:54 AM] Request textDocument/references failed.
  Message: Unable to find file /home/chaopeng/workspace/chromium/src/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
  Code: -32603 

What is "symbol rename"?

In the list of things you say cquery does is listed symbol rename. Is this the same as safely renaming a variable or method across the whole project? Because I tried to rename a variable but the renaming was never done, nor any error shown (although I admit I may not know where to look for the errors).

Cannot build cquery

Waf: Entering directory `/home/agauniyal/projects/cquery/build'
CLANG_INCLUDE_DIR: /home/agauniyal/projects/cquery/build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/include
CLANG_LIB_DIR:     /home/agauniyal/projects/cquery/build/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/lib
[ 1/33] Compiling src/cache.cc
[ 2/33] Compiling src/clang_complete.cc
[ 3/33] Compiling src/clang_cursor.cc
[ 4/33] Compiling src/clang_index.cc
[ 5/33] Compiling src/clang_translation_unit.cc
[ 6/33] Compiling src/clang_utils.cc
[ 7/33] Compiling src/command_line.cc
[ 8/33] Compiling src/file_consumer.cc
[ 9/33] Compiling src/include_complete.cc
[10/33] Compiling src/indexer.cc
[11/33] Compiling src/ipc.cc
[12/33] Compiling src/ipc_manager.cc
[13/33] Compiling src/language_server_api.cc
../src/command_line.cc:2007:16: error: lambda capture 'working_files' is not used [-Werror,-Wunused-lambda-capture]
              [working_files, global_code_complete_cache,
               ^
../src/command_line.cc:3014:37: error: lambda capture 'config' is not used [-Werror,-Wunused-lambda-capture]
  WorkThread::StartThread("stdin", [config, request_times]() {
                                    ^
2 errors generated.

Waf: Leaving directory `/home/agauniyal/projects/cquery/build'
Build failed
 -> task in 'app' failed with exit status 1 (run with -v to display more information)

Better support for empty/blank projects

https://www.reddit.com/r/cpp/comments/7djtz2/lowlatency_vscode_language_server_for_large_c/dpzsqx1/

About user-polish things, may I provide another suggestion? The c/c++ extension on marketplace has 1 great feature that helps me prototype quickly with cpp, it generates a default configuration file for each project which resolves system headers automatically and looks for header files in current directory.
So when I've to just test some new thing or write small function for which I don't want to write a cmake file and make proper directory structure and generate compile_commands.json and set everything, everything just works. Every other plugin asks me to setup tons of things which I don't want to when writing a bunch of cpp files that include only system headers or custom headers present in current directory(recursive) and its frustrating af. Better to open nano use that instead of code if there are no auto-completions. YCM solves this problem by asking to provide a default global config file which loads up when no config is present in cwd, please provide an option for cquery too (or better make it automatic like c/c++ extension does ;-) )

caveats to using on small to mid sized sources

Hi, I notice you mention this often

designed for large C++ code bases

so I was wondering are there any caveats to using on small to mid sized code bases? Or is it just that it suits large sized ones but will work equally well on other variants too. This seems a very interesting plugin and I can't wait to try it out ๐Ÿ˜ธ

Extend Emacs client to be an entire alternative to cc-mode

cc-mode uses a lot of semantic analysis to do syntax highlighting and indentation etc. But using semantic highlighting, keyword highlighting, and a few simple pieces of regex, that could probably all be replaced. It would also require clang-format support, which @danielmartin is working on.

cc-mode is also very slow to update, for example it still doesnt indent correctly after noexcept in constructor definitions.

Semantic highlighting should be the hardest part, and that already works, so i think this is feasable.

Activating extension `jacobdufault.cquery` failed: Cannot read property 'replace' of undefined

I've tried it on macOS(10.12.4) but failed

Here is the error stack:  TypeError: Cannot read property 'replace' of undefined
    at activate (/Users/Caffrey/Documents/cquery/vscode-client/out/src/extension.js:111:58)
    at Function.t._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:373080)
    at Function.t._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:372865)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:372640
    at Object.m [as _notify] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:62432)
    at Object.enter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:66006)
    at n.Class.derive._oncancel._run (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:67834)
    at n.Class.derive._oncancel._completed (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:67275)
    at c (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:70786)
    at n.Class.derive.join.i.forEach.J.then.o.(anonymous function) (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:71003)
(node:3566) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

if (!clientConfig.cacheDirectory) {
        console.log('Updating cache directory');
        clientConfig.cacheDirectory = context.storagePath.replace(/\\/g, '/') + "/cquerycache/";
        config.update('cacheDirectory', clientConfig.cacheDirectory, false /*global*/).then(() => {
            console.log('Updated config cache directory');
        }, (reason) => {
            console.log('Cache directory update failed');
            console.log(reason);
        });
    }

it seems like context.storagePath is undefined

libclang had ast read error for

I've tried to feed my project's compile_commands.json into cquery and get this error on every file. The special about this project is that it is build in container so in order to be parsed outside of container so I have to preprend a bunch of -isystem arguments to each compilation command. Here is an example of it:

2017-11-18 20:42:05.203 (   1.863s) [indexer1        ]        command_line.cc:950      0| Parsing /home/sergei/e8/code/foo-E8/user/system_offload/system_offload.c
2017-11-18 20:42:05.209 (   1.869s) [indexer1        ]clang_translation_unit.cc:49     ERR| libclang had ast read error for /home/sergei/e8/code/foo-E8/user/system_offload/system_offload.c with args cc, -isystem, /home/sergei/opt/clang/lib/clang/5.0.0/include, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/opt/rh/devtoolset-6/root/usr/include/c++/6.2.1, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/opt/rh/devtoolset-6/root/usr/include/c++/6.2.1/x86_64-redhat-linux, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/opt/rh/devtoolset-6/root/usr/include/c++/6.2.1/backward, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/usr/include, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/include, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/opt/rh/devtoolset-6/root/usr/include, -isystem, /home/sergei/mock/E8BR/E8BR_140/root/usr/local/include, -std=gnu90, -m64, -march=corei7, -mpclmul, -mpopcnt, -maes, -mcx16, -ggdb, -pthread, -DBUILD_CTRL_VERSION=v2.2.0, -DBUILD_HOST_VERSION=v2.2.0, -DBUILD_PROTOCOL_VERSION=220, -DBUILD_HASH=af2b72259771207e19f716f1def8a09f71f0e830, -DBUILD_TIMESTAMP=2017-November-15_18:28:36_UTC, -DOS_NAME=rhel7.3, -DOFED_VERSION=3.4-2.0.0.0, -DPKG_TYPE=rpm, -DE8_LOG_LEVEL=E8_LOG_LEVEL_INFO, -DE8_TRACE_LEVEL=E8_LOG_LEVEL_DEBUG, -DACCELIO_LOG_LEVEL=E8_LOG_LEVEL_DEBUG, -DOS_DETECT_RHEL7, -D_REENTRANT, -D_GNU_SOURCE, -Wall, -Wextra, -Werror, -Wno-unused-parameter, -Wconversion, -I/home/sergei/e8/code/foo-E8, -I/home/sergei/e8/code/foo-E8/portable/abstraction/linux_user, -I/home/sergei/e8/code/foo-E8/user, -I/home/sergei/e8/code/foo-E8/3rdparty/ccan, -I/home/sergei/e8/code/foo-E8/3rdparty, -I/home/sergei/e8/code/foo-E8/3rdparty/jansson/.build/src, -O0, user/system_offload/system_offload.c, -DTRACE_INTROSPECT, -include, traces/clang.h, -Wno-expansion-to-defined, -Wno-inconsistent-missing-override, -xc, -resource-dir=/home/sergei/src/cquery/clang_resource_dir

Other clang-based tools I use (rtags and ycmd) eat this file without problems. I've also tried compiling file directly with clang and it worked.

Is it possible to get some more information from clang about these AST parsing errors?

BTW. Other smaller open-source projects I've tried work without any problem.

Completion fills in parameter declarations in parentheses

When I use code completion for any function/method it fills in all parameter declarations inside the parentheses. Is this intended behaviour or a bug? If this is intended behaviour, could you add an option to disable this behaviour (and just complete with empty parentheses)?

a

I can take a look myself if you can give me a pointer to the file(s) where changes would have to be made.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.