mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 04:45:19 +00:00
Some checks are pending
Publish to ghcr / build (linux/amd64, blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Publish to ghcr / build (linux/arm64, blacksmith-8vcpu-ubuntu-2204-arm) (push) Waiting to run
Publish to ghcr / merge (push) Blocked by required conditions
Update Roadmap Released / update (push) Waiting to run
44 lines
2.3 KiB
Text
44 lines
2.3 KiB
Text
---
|
|
title: Code navigation
|
|
sidebarTitle: Code navigation
|
|
---
|
|
|
|
import SearchContextSchema from '/snippets/schemas/v3/searchContext.schema.mdx'
|
|
import LicenseKeyRequired from '/snippets/license-key-required.mdx'
|
|
|
|
<LicenseKeyRequired />
|
|
|
|
**Code navigation** allows you to jump between symbol definition and references when viewing source files in Sourcebot. This feature is enabled **automatically** when a valid license key is present and works with all popular programming languages.
|
|
|
|
|
|
<video src="https://framerusercontent.com/assets/B9ZxrlsUeO9NJyzkKyvVV2KSU4.mp4" className="w-full aspect-video" controls></video>
|
|
|
|
## Features
|
|
|
|
| Feature | Description |
|
|
|:--------|:------------|
|
|
| **Hover popover** | Hovering over a symbol reveals the symbol's definition signature as a inline preview. |
|
|
| **Go to definition** | Clicking the "go to definition" button in the popover or clicking the symbol name navigates to the symbol's definition. |
|
|
| **Find references** | Clicking the "find all references" button in the popover lists all references in the explore panel. |
|
|
| **Explore panel** | Lists all references and definitions for the symbol selected in the popover. |
|
|
| **Cross-repository navigation** | You can search across all repositories by clicking the globe icon in the explore panel. By default, references and definitions are scoped to the repository where the symbol is being resolved. |
|
|
|
|
## How does it work?
|
|
|
|
Code navigation is **search-based**, meaning it uses the same code search engine and [query language](/docs/features/search/syntax-reference) to estimate a symbol's references and definitions. We refer to these estimations as "search heuristics". We have two search heuristics to enable the following operations:
|
|
|
|
### Find references
|
|
Given a `symbolName`, along with information about the file the symbol is contained within (`git_revision`, and `language`), runs the following search:
|
|
|
|
```bash
|
|
\\b{symbolName}\\b rev:{git_revision} lang:{language} case:yes
|
|
```
|
|
|
|
### Find definitions
|
|
Given a `symbolName`, along with information about the file the symbol is contained within (`git_revision`, and `language`), runs the following search:
|
|
|
|
```bash
|
|
sym:\\b{symbolName}\\b rev:{git_revision} lang:{language}
|
|
```
|
|
|
|
Note that the `sym:` prefix is used to filter the search by symbol definitions. These are created at index time by [universal ctags](https://ctags.io/).
|