Skip to main content

Crate tree_sitter_language_pack

Crate tree_sitter_language_pack 

Source
Expand description

§tree-sitter-language-pack

Pre-compiled tree-sitter grammars for 305 programming languages with a unified API for parsing, analysis, and intelligent code chunking.

§Quick Start

use tree_sitter_language_pack::{ProcessConfig, available_languages, has_language, process};

// Check available languages
let langs = available_languages();
assert!(has_language("python"));

// Process source code
let config = ProcessConfig::new("python").all();
let result = process("def hello(): pass", &config).unwrap();
println!("Language: {}", result.language);
println!("Functions: {}", result.structure.len());

§Modules

  • registry - Thread-safe language registry for parser lookup
  • [intel] - Source code intelligence extraction (structure, imports, exports, etc.)
  • [parse] - Low-level tree-sitter parsing utilities
  • [node] - Tree node traversal and information extraction
  • [query] - Tree-sitter query execution
  • [text_splitter] - Syntax-aware code chunking
  • process_config - Configuration for the process pipeline
  • pack_config - Configuration for the language pack (cache dir, languages to download)
  • error - Error types

Re-exports§

pub use error::Error;
pub use pack_config::PackConfig;
pub use process_config::ProcessConfig;
pub use registry::LanguageRegistry;
pub use download::DownloadManager;

Modules§

download
error
pack_config
process_config
registry

Structs§

CaptureResult
A single captured node within a match.
ChunkContext
Metadata for a single chunk of source code.
CodeChunk
A chunk of source code with rich metadata.
CommentInfo
A comment extracted from source code.
Diagnostic
A diagnostic (syntax error, missing node, etc.) from parsing.
DocSection
A section within a docstring (e.g., Args, Returns, Raises).
DocstringInfo
A docstring extracted from source code.
ExportInfo
An export statement extracted from source code.
ExtractionConfig
Configuration for an extraction run against a single language.
ExtractionPattern
Defines a single extraction pattern and its configuration.
ExtractionResult
Complete extraction results for all patterns.
FileMetrics
Aggregate metrics for a source file.
ImportInfo
An import statement extracted from source code.
Language
An opaque object that defines how to parse a particular language. The code for each Language is generated by the Tree-sitter CLI.
MatchResult
A single query match containing one or more captures.
NodeInfo
Lightweight snapshot of a tree-sitter node’s properties.
Parser
A stateful object that this is used to produce a Tree based on some source code.
PatternResult
Results for a single named pattern.
PatternValidation
Validation information for a single pattern.
ProcessResult
Complete analysis result from processing a source file.
QueryMatch
A single match from a tree-sitter query, with captured nodes.
Span
Byte and line/column range in source code.
StructureItem
A structural item (function, class, struct, etc.) in source code.
SymbolInfo
A symbol (variable, function, type, etc.) extracted from source code.
Tree
A tree that represents the syntactic structure of a source code file.
ValidationResult
Validation results for an entire extraction config.

Enums§

CaptureOutput
Controls what data is captured for each query match.
CommentKind
The kind of a comment found in source code.
DiagnosticSeverity
Severity level of a diagnostic produced during parsing.
DocstringFormat
The format of a docstring extracted from source code.
ExportKind
The kind of an export statement found in source code.
StructureKind
The kind of structural item found in source code.
SymbolKind
The kind of a symbol definition found in source code.

Functions§

available_languages
List all available language names (sorted, deduplicated, includes aliases).
cache_dir
Return the effective cache directory path.
clean_cache
Delete all cached parser shared libraries.
configure
Apply download configuration without downloading anything.
detect_language_from_content
Detect language name from file content using the shebang line (#!).
detect_language_from_extension
Detect language name from a file extension (without leading dot).
detect_language_from_path
Detect language name from a file path.
download
Download specific languages to the local cache.
download_all
Download all available languages from the remote manifest.
downloaded_languages
Return languages that are already downloaded and cached locally.
extract_patterns
Run extraction patterns against source code.
find_nodes_by_type
Find all nodes matching the given type name, returning their NodeInfo.
get_highlights_query
Get the highlights query for a language, if bundled.
get_injections_query
Get the injections query for a language, if bundled.
get_language
Get a tree-sitter Language by name using the global registry.
get_locals_query
Get the locals query for a language, if bundled.
get_parser
Get a tree-sitter Parser pre-configured for the given language.
has_language
Check if a language is available by name or alias.
init
Initialize the language pack with the given configuration.
language_count
Return the number of available languages.
manifest_languages
Return all language names available in the remote manifest (305).
named_children_info
Get NodeInfo for all named children of the root node.
parse_string
Parse source code with the named language, returning the syntax tree.
process
Process source code and extract file intelligence using the global registry.
root_node_info
Get a NodeInfo snapshot of the root node.
run_query
Execute a tree-sitter query pattern against a parsed tree.
tree_contains_node_type
Check whether any node in the tree matches the given type name.
tree_error_count
Count the number of ERROR and MISSING nodes in the tree.
tree_has_error_nodes
Check whether the tree contains any ERROR or MISSING nodes.
tree_to_sexp
Return the S-expression representation of the entire tree.
validate_extraction
Validate extraction patterns without running them.