Unship precise code navigation (#52258)
Co-authored-by: Felicity Chapman <felicitymay@github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Co-authored-by: Melanie Yarbrough <11952755+myarb@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a8a4fcf1af
commit
eac1b74c39
@@ -19,45 +19,13 @@ Code navigation helps you to read, navigate, and understand code by showing and
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
Code navigation uses the open source [`tree-sitter`](https://github.com/tree-sitter/tree-sitter) library. The following languages and navigation strategies are supported.
|
Code navigation uses the open source [`tree-sitter`](https://github.com/tree-sitter/tree-sitter) library. The following languages support code navigation.
|
||||||
|
|
||||||
{% rowheaders %}
|
{% data reusables.search.code-nav-supported-languages %}
|
||||||
|
|
||||||
| Language | Search-based code navigation | Precise code navigation |
|
You do not need to configure anything in your repository to enable code navigation. We will automatically extract code navigation information for these supported languages in all repositories.
|
||||||
|------------------|:--------------------------------------------:|:--------------------------------------------:|
|
|
||||||
| Bash | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| C | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| C# | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| C++ | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| CodeQL | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Elixir | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Go | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| JSX | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Java | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| JavaScript | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Lua | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| PHP | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Protocol Buffers | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Python | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} |
|
|
||||||
| R | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Ruby | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Rust | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Scala | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Starlark | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| Swift | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Not supported" %} |
|
|
||||||
| TypeScript | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} |
|
|
||||||
|
|
||||||
{% endrowheaders %}
|
{% data variables.product.prodname_dotcom %} has developed a code navigation approach based on the open source [`tree-sitter`](https://github.com/tree-sitter/tree-sitter) library that searches all definitions and references across a repository to find entities with a given name.
|
||||||
|
|
||||||
You do not need to configure anything in your repository to enable code navigation. We will automatically extract search-based and precise code navigation information for these supported languages in all repositories and you can switch between the two supported code navigation approaches if your programming language is supported by both.
|
|
||||||
|
|
||||||
{% data variables.product.prodname_dotcom %} has developed two code navigation approaches based on the open source [`tree-sitter`](https://github.com/tree-sitter/tree-sitter) and [`stack-graphs`](https://github.com/github/stack-graphs) library:
|
|
||||||
* Search-based - searches all definitions and references across a repository to find entities with a given name
|
|
||||||
* Precise - resolves definitions and references based on the set of classes, functions, and imported definitions at a given point in your code
|
|
||||||
|
|
||||||
To learn more about these approaches, see "[Precise and search-based navigation](#precise-and-search-based-navigation)."
|
|
||||||
|
|
||||||
Future releases will add _precise code navigation_ for more languages, which is a code navigation approach that can give more accurate results.
|
|
||||||
|
|
||||||
{% ifversion code-view-ui %}You can use keyboard shortcuts to navigate within a code file. For more information, see "[AUTOTITLE](/get-started/accessibility/keyboard-shortcuts#navigating-within-code-files)."{% endif %}
|
{% ifversion code-view-ui %}You can use keyboard shortcuts to navigate within a code file. For more information, see "[AUTOTITLE](/get-started/accessibility/keyboard-shortcuts#navigating-within-code-files)."{% endif %}
|
||||||
|
|
||||||
@@ -95,22 +63,6 @@ You can find all references for a function or method within the same repository
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Precise and search-based navigation
|
|
||||||
|
|
||||||
Certain languages supported by {% data variables.product.prodname_dotcom %} have access to _precise code navigation_, which uses an algorithm (based on the open source [`stack-graphs`](https://github.com/github/stack-graphs) library) that resolves definitions and references based on the set of classes, functions, and imported definitions that are visible at any given point in your code. Other languages use _search-based code navigation_, which searches all definitions and references across a repository to find entities with a given name. Both strategies are effective at finding results and both make sure to avoid inappropriate results such as comments, but precise code navigation can give more accurate results, especially when a repository contains multiple methods or functions with the same name.
|
|
||||||
|
|
||||||
If you don't see the results you expect from a precise code navigation query, you can click on the "search-based" link in the displayed popover to perform search-based navigation.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
If your precise results appear inaccurate, you can file a support request.
|
|
||||||
|
|
||||||
## Cross-repository precise code navigation
|
|
||||||
|
|
||||||
Cross-repo code navigation is available for languages that are supported by precise code navigation and the dependency graph. For more information, see "[AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph)." With cross-repo code navigation, you can jump to the definition of functions or variables defined in dependencies imported by your project if that dependency is a repository hosted by {% data variables.product.prodname_dotcom %}. Cross-repo code navigation does not support find-all-references requests at this time.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Troubleshooting code navigation
|
## Troubleshooting code navigation
|
||||||
|
|
||||||
If code navigation is enabled for you but you don't see links to the definitions of functions and methods:
|
If code navigation is enabled for you but you don't see links to the definitions of functions and methods:
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ Code search is integrated with features in the search interface on {% data varia
|
|||||||
|
|
||||||
{% data variables.product.prodname_dotcom %} code search provides code navigation for supported languages. This includes jumping to the definition of and finding references for programming language constructs like classes, structs, functions, and methods. See "[AUTOTITLE](/repositories/working-with-files/using-files/navigating-code-on-github)."
|
{% data variables.product.prodname_dotcom %} code search provides code navigation for supported languages. This includes jumping to the definition of and finding references for programming language constructs like classes, structs, functions, and methods. See "[AUTOTITLE](/repositories/working-with-files/using-files/navigating-code-on-github)."
|
||||||
|
|
||||||
Supported languages for code navigation include:
|
|
||||||
|
|
||||||
{% data reusables.search.code-nav-supported-languages %}
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
We have indexed many public repositories for code search, and continue to index more. Additionally, the private repositories of {% data variables.product.prodname_dotcom %} users are indexed and searchable by those that already have access to those private repositories on {% data variables.product.prodname_dotcom %}. However, very large repositories may not be indexed at this time, and not all code is indexed.
|
We have indexed many public repositories for code search, and continue to index more. Additionally, the private repositories of {% data variables.product.prodname_dotcom %} users are indexed and searchable by those that already have access to those private repositories on {% data variables.product.prodname_dotcom %}. However, very large repositories may not be indexed at this time, and not all code is indexed.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
| Python {% ifversion fpt or ghec %}| {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} <br>precise| {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Unsupported" %} |{% elsif ghes %}| {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Unsupported" %} |{% endif %}
|
| Python {% ifversion fpt or ghec %}| {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Unsupported" %} |{% elsif ghes %}| {% octicon "check" aria-label="Supported" %} | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %}<br>pip | {% octicon "check" aria-label="Supported" %} | {% octicon "x" aria-label="Unsupported" %} |{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user