---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/code-navigation.md
  - href: en/sourcecraft/operations/code-navigation.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Navigating and searching by code in SourceCraft
description: This guide describes how to navigate and search by code in SourceCraft.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


# Navigating and searching by code in SourceCraft

<!-- source: en/_includes/sourcecraft/code-navigation-supported-syntax.md -->
{% note info %}

File structure output, declaration search, and element occurrence search are supported for C, C++, C#, Go, Java, JavaScript, Kotlin, PHP, Python, TypeScript, the Protocol Buffers data description language, and the `.sourcecraft/ci.yaml` [CI/CD configuration file](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#ci-cd-configuration).

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/code-navigation-supported-syntax.md -->

<!-- source: en/_includes/sourcecraft/code-navigation-description.md -->
You can easily understand code structure and dependencies with SourceCraft code navigation. The solution links declarations of named entities to their usages: for any named entity, you can view its declaration and jump directly to the corresponding line in the source code.

You need no setup to activate code navigation: SourceCraft will automatically index your code for all supported programming languages.

This feature is available both in code browsing mode and when reviewing pull requests.

<iframe width="640" height="360" src="https://runtime.strm.yandex.ru/player/video/vplvlyx6usuy2ivx7kdm?autoplay=0&mute=0" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" frameborder="0" scrolling="no"></iframe>

<br>

#|
||
SourceCraft provides the following code navigation capabilities:
* [Text-based code search across the repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md#search-code-in-repo)
* [File structure navigation](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md#get-structure)
* [Viewing declaration info](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md#declaration-info)
* [Jumping from a usage to its declaration](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md#search-by-declaration)
* [Search by usage](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md#search-by-usage)
||
|#

You can check whether navigation is available via the [indicator](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-navigation.md#indicator).
<!-- endsource: en/_includes/sourcecraft/code-navigation-description.md -->

## Text search by code in a repository {#search-code-in-repo}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select a repository.
1. In the left-hand panel, click ![image](../../_assets/console-icons/magnifier.svg) **Search**.
1. In the field that opens, enter the text you want to search for. You will be presented a list of all the files and lines this text is used in.
1. For a code preview, click on the line of interest.
1. To go to the place of use, double-click the line of interest.

![code-search](../../_assets/sourcecraft/code-search.png)

## Code navigation availability indicator {#indicator}

The ![image](../../_assets/console-icons/compass.svg) indicator in the file info line tells you that code navigation is available for this file. The indicator can have these two colors:

* Green, which means the navigation functionality is ready for use.
* Orange, which means code navigation indexes are being built and will be ready soon.

If there is no indicator, no code navigation is available for this file.

## File structure navigation {#get-structure}

1. Select the file you want to view.
1. In the top-right corner, click ![image](../../_assets/console-icons/hierarchy.svg) **File structure**. The file structure panel will open on the right.
1. Click the declaration of interest to navigate to it.

![file-structure](../../_assets/sourcecraft/file-structure.png)

## Quick view of declaration info {#declaration-info}

1. Select the file you want to view.
1. Hover over the named entity in code whose declaration you want to find. 

   {% note tip %}

   Entities that you can navigate by code are marked with a gray frame on hover.
   
   {% endnote %}

   You will see the declaration info in a pop-up window:
   * Entity type
   * Signature
   * File path
   * Declaration documentation

1. If SourceCraft fails to figure out which declaration is meant, a list will be displayed. Go through the listed items for detailed info on the declaration of interest.

## Viewing full declaration info on click {#declaration-info-full}

1. Select the file you want to view.
1. Click the named entity whose declaration you want to find.
1. A sidebar will open with a preview of the declaration code and a list of its uses.
1. If SourceCraft fails to figure out which declaration is meant, a list will be displayed. To see a code preview for the declaration of interest, switch between the list items.

## Navigating to a declaration from a use {#search-by-declaration}

1. Select the file you want to view.
1. Hover over the named entity whose declaration you want to find. If there are several declarations, select the one you need from the list.
1. To go to the file and line containing the named entity's declaration, click ![image](../../_assets/console-icons/arrow-shape-turn-up-right.svg) **Go to declaration**.

![go-to-declaration](../../_assets/sourcecraft/go-to-declaration.png)

{% note tip %}

You can also jump to the file and line containing the named entity's declaration by placing the cursor on the named entity and using the following keyboard shortcut: **Ctrl** + **B** in Windows/Linux or **Command** + **B** in macOS.

{% endnote %}

## Searching for uses {#search-by-usage}

1. Select the file you want to view.
1. Hover over the named entity in code whose uses you want to find. The declaration info will appear in a pop-up window.
1. Click ![image](../../_assets/console-icons/magnifier.svg) **Find usages**. This will open a panel on the right with all the named entity's uses.

    {% note tip %}

    You can also find the uses by placing the cursor on the named entity and using the following keyboard shortcut: **Alt** + **F7** in Windows/Linux or **Option** + **F7** in macOS.

    {% endnote %}

1. To see a code preview containing the use you selected from the list, click the relevant line.
1. To navigate to the use, double-click the relevant line.

![code-search](../../_assets/sourcecraft/find-usages.png)

#### Useful links {#see-also}

* [SourceCraft resource relationships](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md)
* [Editing code in SourceCraft Code Assistant](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-edit.md)
