- 
                Notifications
    
You must be signed in to change notification settings  - Fork 76
 
Syntactic indexing public doc #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            59 changes: 59 additions & 0 deletions
          
          59 
        
  docs/code-search/code-navigation/syntactic_code_navigation.mdx
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Syntactic Code Navigation | ||
| 
     | 
||
| <TierCallout> | ||
| Supported on [Enterprise](/pricing/enterprise) plans. | ||
| <user> | ||
| This feature is currently in Beta and enabled by default for Cloud customers | ||
| </user> | ||
| </TierCallout> | ||
| 
     | 
||
| Syntactic code navigation is a zero configuration feature that improves code navigation for certain languages in the absence of | ||
| [Precise code navigation](./precise_code_navigation) set up. It works by periodically indexing repositories for which it is [enabled](#enabling-syntactic-code-navigation), using high level syntax analysis heuristics. | ||
| 
     | 
||
| This mechanism is more robust than search-based navigation, but less powerful than Precise code navigation. | ||
| When syntactic indexing data is available for a given file and repository, it will be selected over search-based navigation automatically, | ||
| but only if Precise data is not available. To summarize, the order of priorities is as follows: | ||
| 
     | 
||
| - Precise data | ||
| - Syntactic, if no precise data available | ||
| - Search-based, if no syntactic available | ||
| 
     | 
||
| ## Enabling Syntactic code navigation | ||
| 
     | 
||
| First, enable the experimental feature flag in Site config: | ||
| 
     | 
||
| ```json | ||
| "experimentalFeatures.codeintelSyntacticIndexing.enabled": true | ||
| ``` | ||
| 
     | 
||
| Next, you need to ensure that syntactic indexing is enabled in a code graph configuration policy. Note that for cloud customers this feature is enabled by default for all repositories, as part of | ||
| automatically managed policy called `[Sourcegraph Managed] Head of default branch policy`. | ||
| 
     | 
||
| For all other deployments, you will need to create a HEAD policy with "Syntactic indexing" enabled: | ||
| 
     | 
||
|  | ||
| 
     | 
||
| Syntactic indexing can only be enabled if the policy type is set to HEAD – only indexing the tip of default branch on each repository. You may choose to apply this policy only to selected repositories, although the recommendation is to enable it instance-wide. | ||
| 
     | 
||
| ## Supported languages | ||
| 
     | 
||
| Syntactic code navigation requires language-specific implementations, and we currently support the following languages: | ||
| 
     | 
||
| - [Java](https://www.java.com/en/) | ||
| - [Go](https://go.dev/) | ||
| - [Scala](https://scala-lang.org) | ||
| - [C#](https://learn.microsoft.com/en-us/dotnet/csharp/) | ||
| - [C++](https://isocpp.org/) | ||
| 
     | 
||
| We are constantly looking to expand the list of supported languages, with Python, Typescript/Javascript, and C planned. | ||
| If you are interested in syntactic indexing for these or any other languages, please contact your Sourcegraph account representative. | ||
| 
     | 
||
| ## Comparison with Precise and Search-based | ||
| 
     | 
||
| Syntactic code navigation falls between Precise and Search-based code navigation both in terms of quality of navigation, | ||
| and in terms of effort to maintain for different languages: | ||
| 
     | 
||
|  | ||
| 
     | 
||
| As the indexing does not involve build tools or actual compilers, it can be performed in isolated environment, with no network access | ||
| and no configuration, unlike Precise. | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.