debian-mirror-gitlab/doc/user/project/code_intelligence.md

72 lines
2.5 KiB
Markdown
Raw Normal View History

2020-07-28 23:09:34 +05:30
---
2020-10-24 23:57:45 +05:30
stage: Create
2021-04-17 20:07:23 +05:30
group: Code Review
2021-02-22 17:27:13 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2020-07-28 23:09:34 +05:30
type: reference
---
2021-03-11 19:13:27 +05:30
# Code Intelligence **(FREE)**
2020-07-28 23:09:34 +05:30
> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/1576) in GitLab 13.1.
Code Intelligence adds code navigation features common to interactive
development environments (IDE), including:
- Type signatures and symbol documentation.
2020-10-24 23:57:45 +05:30
- Go-to definition.
2020-07-28 23:09:34 +05:30
Code Intelligence is built into GitLab and powered by [LSIF](https://lsif.dev/)
(Language Server Index Format), a file format for precomputed code
intelligence data.
2021-04-17 20:07:23 +05:30
NOTE:
You can automate this feature in your applications by using [Auto DevOps](../../topics/autodevops/index.md).
2020-07-28 23:09:34 +05:30
## Configuration
Enable code intelligence for a project by adding a GitLab CI/CD job to the project's
2021-04-17 20:07:23 +05:30
`.gitlab-ci.yml` which generates the LSIF artifact:
2020-07-28 23:09:34 +05:30
```yaml
code_navigation:
2020-11-24 15:15:51 +05:30
image: sourcegraph/lsif-go:v1
2020-07-28 23:09:34 +05:30
allow_failure: true # recommended
script:
- lsif-go
artifacts:
reports:
lsif: dump.lsif
```
2021-01-29 00:20:46 +05:30
The generated LSIF file size may be limited by
the [artifact application limits (`ci_max_artifact_size_lsif`)](../../administration/instance_limits.md#maximum-file-size-per-type-of-artifact),
default to 100MB (configurable by an instance administrator).
2020-07-28 23:09:34 +05:30
After the job succeeds, code intelligence data can be viewed while browsing the code:
2020-11-24 15:15:51 +05:30
![Code intelligence](img/code_intelligence_v13_4.png)
2020-07-28 23:09:34 +05:30
2020-10-24 23:57:45 +05:30
## Find references
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/217392) in GitLab 13.2.
2020-11-24 15:15:51 +05:30
> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/235735) in GitLab 13.4.
2020-10-24 23:57:45 +05:30
To find where a particular object is being used, you can see links to specific lines of code
under the **References** tab:
![Find references](img/code_intelligence_find_references_v13_3.png)
2020-07-28 23:09:34 +05:30
## Language support
Generating an LSIF file requires a language server indexer implementation for the
relevant language.
| Language | Implementation |
|---|---|
2021-01-03 14:25:43 +05:30
| Go | [`sourcegraph/lsif-go`](https://github.com/sourcegraph/lsif-go) |
| JavaScript | [`sourcegraph/lsif-node`](https://github.com/sourcegraph/lsif-node) |
| TypeScript | [`sourcegraph/lsif-node`](https://github.com/sourcegraph/lsif-node) |
2020-07-28 23:09:34 +05:30
View a complete list of [available LSIF indexers](https://lsif.dev/#implementations-server) on their website and
refer to their documentation to see how to generate an LSIF file for your specific language.