You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/repositories/working-with-files/using-files/navigating-code-on-github.md
+39-11Lines changed: 39 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,16 +15,34 @@ topics:
15
15
16
16
## About navigating code on {% data variables.product.prodname_dotcom %}
17
17
18
-
Code navigation uses the open source library [`tree-sitter`](https://github.com/tree-sitter/tree-sitter). The following languages are supported:
19
-
- C#
20
-
- CodeQL
21
-
- Go
22
-
- Java
23
-
- JavaScript
24
-
- PHP
25
-
- Python
26
-
- Ruby
27
-
- TypeScript
18
+
Code navigation helps you to read, navigate, and understand code by showing and linking definitions of a named entity corresponding to a reference to that entity, as well as references corresponding to an entity's definition.
Code navigation uses the open source [`tree-sitter`](https://github.com/tree-sitter/tree-sitter) library. The following languages and navigation strategies are supported:
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.
38
+
39
+
{% 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:
40
+
- search-based - searches all definitions and references across a repository to find entities with a given name
41
+
- precise - resolves definitions and references based on the set of classes, functions, and imported definitions at a given point in your code
42
+
43
+
To learn more about these approaches, see "[Precise and search-based navigation](#precise-and-search-based-navigation)."
44
+
45
+
Future releases will add *precise code navigation* for more languages, which is a code navigation approach that can give more accurate results.
28
46
29
47
## Jumping to the definition of a function or method
30
48
@@ -38,11 +56,21 @@ You can find all references for a function or method within the same repository
38
56
39
57

40
58
59
+
## Precise and search-based navigation
60
+
61
+
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.
62
+
63
+
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.
0 commit comments