This project‘s Git repository may be accessed using many other client programs and plug-ins. See your client’s documentation for more information.

Visual Studio Code and cquery

VSCode and cquery provide good code navigation capabilities. It offers “go to definition” as well as “find all references” for C++ symbols and works quite well. This section describes how to get a basic setup on a *nix system.

Install VSCode

Install VSCode in your preferred way. We will assume that you can run VSCode from the commandline via the command code.

Install cquery

Clone cquery from cquery in a directory of your choice. We use CQUERY_DIR=“$HOME/cquery” in this guide.

git clone https://github.com/cquery-project/cquery $CQUERY_DIR
cd $CQUERY_DIR
git submodule update --init
./waf configure build

If anything goes wrong, be sure to check out cquery's getting started guide.

You can use git pull && git submodule update to update cquery at a later time (don't forget to rebuild via ./waf configure build).

Install and configure cquery-plugin for VSCode

Install the cquery extension from the marketplace in VSCode. Open VSCode in your v8 checkout

cd v8
code .

Go to settings in VSCode, for example, via shortcut <CTRL+,>. Add the following to your workspace configuration, thereby replaceing YOURUSERNAME and YOURV8CHECKOUTDIR appropriately.

"settings": {
    "cquery.launch.command": "/home/YOURUSERNAME/cquery/build/release/bin/cquery",
    "cquery.cacheDirectory": "/home/YOURUSERNAME/YOURV8CHECKOUTDIR/.vscode/cquery_cached_index/",
    "cquery.completion.include.blacklist": [".*/.vscache/.*", "/tmp.*", "build/.*"],
    [...]
}

Provide compile_commands.json to cquery

The last step is to generate a compile_commands.json to cquery. This file will contain the specific compiler command lines used to build V8 to cquery. Run the following command in the V8 checkout:

ninja -C out.gn/x64.release -t compdb cxx cc > compile_commands.json

This needs to be re-executed from time to time to teach cquery about new source files. In particular, you should always re-run the command after a BUILD.gn was changed.

Useful Settings

The auto-closing of parenthesis in VisualStudioCode is not working too well. It can be disabled with

"editor.autoClosingBrackets": false

in the user settings.

The following exclusion masks help avoid unwanted results when using search (CTRL+SHIFT+F):

    "files.exclude": {
        "**/.vscode": true,    // this is a default value
    },
    "search.exclude": {
        "**/out*": true,    // this is a default value
        "**/build*": true    // this is a default value
    },