Code intelligence overview

Code intelligence provides advanced code navigation and cross-references for your code on Sourcegraph, your code host, and your code review tools:

Code intelligence works out of the box with all of the most popular programming language extensions using our search-based basic code intelligence.

There are two ways to get more precise code intelligence:

Code intelligence is provided by Sourcegraph extensions.

By spinning up Sourcegraph, you can get code intelligence:

  • On the Sourcegraph web interface
  • On code files on your code host, via our integrations
  • On diffs in your code review tool, via our integrations
  • Via the Sourcegraph API (for programmatic access)

Getting started

Code intelligence features

Hover tooltips with documentation and type signatures

Hover tooltips allow you to quickly glance at the type signature and accompanying documentation of a symbol definition without having to context switch to another source file (which may or may not be available while browsing code).

Go to definition

When you select ‘Go to definition’ from the hover tooltip, you will be navigated directly to the definition of the symbol.

Find references

When you select ‘Find references’ from the hover tooltip, a panel will be shown at the bottom of the page that lists all of the references found for both precise (LSIF or language server) and basic results (from search heuristics). This panel will separate references by repository, and you can optionally group them by file.

We use Ctags to index the symbols of a repository on-demand. These symbols are used to implement symbol search, which will match declarations instead of plain-text.

Symbol sidebar

We use Ctags to index the symbols of a repository on-demand. These symbols are also used for the symbol sidebar, which categorizes declarations by type (variable, function, interface, etc). Clicking on a symbol in the sidebar jumps you to the line where it is defined.

Code intelligence in action

Code intelligence adds context to your development workflows. The example below shows how code reviews are improved using code intelligence on a pull request in GitHub.

GitHub pull request and file integration (using a language server)