Code Intelligence

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated

Code Intelligence adds code navigation features common to interactive development environments (IDE), including:

  • Type signatures and symbol documentation.
  • Go-to definition.

Code Intelligence is built into GitLab and powered by LSIF (Language Server Index Format), a file format for precomputed code intelligence data. GitLab processes one LSIF file per project, and Code Intelligence does not support different LSIF files per branch. Follow epic #4212, Code intelligence enhancements for progress on upcoming enhancements.

note
You can automate this feature in your applications by using Auto DevOps.

Configuration

Enable code intelligence for a project by adding a GitLab CI/CD job to the project’s .gitlab-ci.yml which generates the LSIF artifact:

code_navigation:
  image: sourcegraph/lsif-go:v1
  allow_failure: true # recommended
  script:
    - lsif-go
  artifacts:
    reports:
      lsif: dump.lsif

The generated LSIF file size might be limited by the artifact application limits (ci_max_artifact_size_lsif), default to 100 MB (configurable by an instance administrator).

After the job succeeds, code intelligence data can be viewed while browsing the code:

Code intelligence

Find references

To find where a particular object is being used, you can see links to specific lines of code under the References tab:

Find references

Language support

Generating an LSIF file requires a language server indexer implementation for the relevant language. View a complete list of available LSIF indexers on their website and refer to their documentation to see how to generate an LSIF file for your specific language.