Skip to main content

Language

Trait Language 

Source
pub trait Language: Send + Sync {
Show 48 methods // Required methods fn name(&self) -> &'static str; fn extensions(&self) -> &'static [&'static str]; fn grammar_name(&self) -> &'static str; fn has_symbols(&self) -> bool; fn container_kinds(&self) -> &'static [&'static str]; fn function_kinds(&self) -> &'static [&'static str]; fn type_kinds(&self) -> &'static [&'static str]; fn import_kinds(&self) -> &'static [&'static str]; fn public_symbol_kinds(&self) -> &'static [&'static str]; fn visibility_mechanism(&self) -> VisibilityMechanism; fn extract_function( &self, node: &Node<'_>, content: &str, in_container: bool, ) -> Option<Symbol>; fn extract_container( &self, node: &Node<'_>, content: &str, ) -> Option<Symbol>; fn extract_type(&self, node: &Node<'_>, content: &str) -> Option<Symbol>; fn extract_docstring( &self, node: &Node<'_>, content: &str, ) -> Option<String>; fn extract_attributes(&self, node: &Node<'_>, content: &str) -> Vec<String>; fn extract_imports(&self, node: &Node<'_>, content: &str) -> Vec<Import>; fn format_import(&self, import: &Import, names: Option<&[&str]>) -> String; fn extract_public_symbols( &self, node: &Node<'_>, content: &str, ) -> Vec<Export>; fn scope_creating_kinds(&self) -> &'static [&'static str]; fn control_flow_kinds(&self) -> &'static [&'static str]; fn complexity_nodes(&self) -> &'static [&'static str]; fn nesting_nodes(&self) -> &'static [&'static str]; fn signature_suffix(&self) -> &'static str; fn is_public(&self, node: &Node<'_>, content: &str) -> bool; fn get_visibility(&self, node: &Node<'_>, content: &str) -> Visibility; fn is_test_symbol(&self, symbol: &Symbol) -> bool; fn embedded_content( &self, node: &Node<'_>, content: &str, ) -> Option<EmbeddedBlock>; fn container_body<'a>(&self, node: &'a Node<'a>) -> Option<Node<'a>>; fn body_has_docstring(&self, body: &Node<'_>, content: &str) -> bool; fn node_name<'a>( &self, node: &Node<'_>, content: &'a str, ) -> Option<&'a str>; fn file_path_to_module_name(&self, path: &Path) -> Option<String>; fn module_name_to_paths(&self, module: &str) -> Vec<String>; fn lang_key(&self) -> &'static str; fn resolve_local_import( &self, import_name: &str, current_file: &Path, project_root: &Path, ) -> Option<PathBuf>; fn resolve_external_import( &self, import_name: &str, project_root: &Path, ) -> Option<ResolvedPackage>; fn is_stdlib_import(&self, import_name: &str, project_root: &Path) -> bool; fn get_version(&self, project_root: &Path) -> Option<String>; fn find_package_cache(&self, project_root: &Path) -> Option<PathBuf>; fn indexable_extensions(&self) -> &'static [&'static str]; fn find_stdlib(&self, project_root: &Path) -> Option<PathBuf>; fn should_skip_package_entry(&self, name: &str, is_dir: bool) -> bool; fn package_module_name(&self, entry_name: &str) -> String; fn package_sources(&self, project_root: &Path) -> Vec<PackageSource>; fn discover_packages( &self, source: &PackageSource, ) -> Vec<(String, PathBuf)>; fn find_package_entry(&self, path: &Path) -> Option<PathBuf>; // Provided methods fn discover_flat_packages( &self, source_path: &Path, ) -> Vec<(String, PathBuf)> { ... } fn discover_recursive_packages( &self, base_path: &Path, current_path: &Path, ) -> Vec<(String, PathBuf)> { ... } fn discover_npm_scoped_packages( &self, source_path: &Path, ) -> Vec<(String, PathBuf)> { ... }
}
Expand description

Unified language support trait.

Each language implements this trait to provide:

  • Node kind classification
  • Symbol extraction (functions, classes, types)
  • Import/export parsing
  • Complexity analysis nodes
  • Visibility detection
  • Edit support (container bodies, docstrings)

Required Methods§

Source

fn name(&self) -> &'static str

Display name for this language (e.g., “Python”, “C++”)

Source

fn extensions(&self) -> &'static [&'static str]

File extensions this language handles (e.g., [“py”, “pyi”, “pyw”])

Source

fn grammar_name(&self) -> &'static str

Grammar name for arborium (e.g., “python”, “rust”)

Source

fn has_symbols(&self) -> bool

Whether this language has code symbols (functions, classes, etc.)

Source

fn container_kinds(&self) -> &'static [&'static str]

Container nodes that can hold methods (class, impl, module)

Source

fn function_kinds(&self) -> &'static [&'static str]

Function/method definition nodes

Source

fn type_kinds(&self) -> &'static [&'static str]

Type definition nodes (struct, enum, interface, type alias)

Source

fn import_kinds(&self) -> &'static [&'static str]

Import statement nodes

Source

fn public_symbol_kinds(&self) -> &'static [&'static str]

AST node kinds that may contain publicly visible symbols. For JS/TS: export_statement nodes. For Go/Java/Python: function/class/type declaration nodes. The extract_public_symbols() method filters by actual visibility.

Source

fn visibility_mechanism(&self) -> VisibilityMechanism

How this language determines symbol visibility

Source

fn extract_function( &self, node: &Node<'_>, content: &str, in_container: bool, ) -> Option<Symbol>

Extract symbol from a function/method node

Source

fn extract_container(&self, node: &Node<'_>, content: &str) -> Option<Symbol>

Extract symbol from a container node (class, impl, module)

Source

fn extract_type(&self, node: &Node<'_>, content: &str) -> Option<Symbol>

Extract symbol from a type definition node

Source

fn extract_docstring(&self, node: &Node<'_>, content: &str) -> Option<String>

Extract docstring/doc comment for a node

Source

fn extract_attributes(&self, node: &Node<'_>, content: &str) -> Vec<String>

Extract attributes/decorators for a node (e.g., #test, @Test)

Source

fn extract_imports(&self, node: &Node<'_>, content: &str) -> Vec<Import>

Extract imports from an import node (may return multiple)

Source

fn format_import(&self, import: &Import, names: Option<&[&str]>) -> String

Format an import as source code. If names is Some, only include those names (for multi-import filtering). If names is None, format the complete import.

Source

fn extract_public_symbols(&self, node: &Node<'_>, content: &str) -> Vec<Export>

Extract public symbols from a node. The node is one of the kinds from public_symbol_kinds(). For JS/TS: extracts exported names from export statements. For Go/Java/Python: checks visibility and returns public symbols.

Source

fn scope_creating_kinds(&self) -> &'static [&'static str]

Nodes that create new variable scopes (for scope analysis) Includes: loops, blocks, comprehensions, lambdas, with statements Note: Functions and containers (from function_kinds/container_kinds) also create scopes

Source

fn control_flow_kinds(&self) -> &'static [&'static str]

Nodes that affect control flow (for CFG analysis) Includes: if, for, while, return, break, continue, try, match

Source

fn complexity_nodes(&self) -> &'static [&'static str]

Nodes that increase cyclomatic complexity

Source

fn nesting_nodes(&self) -> &'static [&'static str]

Nodes that indicate nesting depth

Source

fn signature_suffix(&self) -> &'static str

Suffix to append to signatures for tree-sitter parsing. Function signatures are incomplete code fragments that need closing tokens to parse correctly (e.g., Rust fn foo() needs {}, Lua function foo() needs end). Returns the suffix to append, or empty string if none needed.

Source

fn is_public(&self, node: &Node<'_>, content: &str) -> bool

Check if a node is public/exported

Source

fn get_visibility(&self, node: &Node<'_>, content: &str) -> Visibility

Get visibility of a node

Source

fn is_test_symbol(&self, symbol: &Symbol) -> bool

Check if a symbol is a test (for filtering). Each language must implement this - test conventions are language-specific.

Source

fn embedded_content( &self, node: &Node<'_>, content: &str, ) -> Option<EmbeddedBlock>

Extract embedded content from a node (e.g., JS/CSS in Vue/HTML). Returns None for nodes that don’t contain embedded code in another language.

Source

fn container_body<'a>(&self, node: &'a Node<'a>) -> Option<Node<'a>>

Find the body node of a container (for prepend/append)

Source

fn body_has_docstring(&self, body: &Node<'_>, content: &str) -> bool

Detect if first child of body is a docstring

Source

fn node_name<'a>(&self, node: &Node<'_>, content: &'a str) -> Option<&'a str>

Get the name of a node (typically via “name” field)

Source

fn file_path_to_module_name(&self, path: &Path) -> Option<String>

Convert a file path to a module name for this language. Used to find “importers” - files that import a given file. Returns None for languages without module systems or where not applicable.

Source

fn module_name_to_paths(&self, module: &str) -> Vec<String>

Convert a module name to candidate file paths (inverse of file_path_to_module_name). Returns relative paths that could contain the module. Used for wildcard import resolution (e.g., from foo import *).

Source

fn lang_key(&self) -> &'static str

Language key for package index cache (e.g., “python”, “go”, “js”).

Source

fn resolve_local_import( &self, import_name: &str, current_file: &Path, project_root: &Path, ) -> Option<PathBuf>

Resolve a local import within the project.

Handles project-relative imports (e.g., from . import foo, crate::, ./module, relative includes).

Source

fn resolve_external_import( &self, import_name: &str, project_root: &Path, ) -> Option<ResolvedPackage>

Resolve an external import to its source location.

Returns the path to stdlib or installed packages.

Source

fn is_stdlib_import(&self, import_name: &str, project_root: &Path) -> bool

Check if an import is from the standard library.

Source

fn get_version(&self, project_root: &Path) -> Option<String>

Get the language/runtime version (for package index versioning).

Source

fn find_package_cache(&self, project_root: &Path) -> Option<PathBuf>

Find package cache/installation directory.

Source

fn indexable_extensions(&self) -> &'static [&'static str]

File extensions to index when caching a package.

Source

fn find_stdlib(&self, project_root: &Path) -> Option<PathBuf>

Find standard library directory (if applicable). Returns None for languages without a separate stdlib to index.

Source

fn should_skip_package_entry(&self, name: &str, is_dir: bool) -> bool

Should this entry be skipped when indexing packages? Called for each file/directory in package directories. Use helper functions skip_dotfiles() and has_extension(name, self.indexable_extensions()) for common checks.

Source

fn package_module_name(&self, entry_name: &str) -> String

Get the module/package name from a directory entry name.

Source

fn package_sources(&self, project_root: &Path) -> Vec<PackageSource>

Return package sources to index for this language. Each source describes a directory containing packages.

Source

fn discover_packages(&self, source: &PackageSource) -> Vec<(String, PathBuf)>

Discover packages in a source directory. Returns (package_name, path) pairs for all packages found. Use provided helpers: discover_flat_packages, discover_recursive_packages, discover_npm_scoped_packages.

Source

fn find_package_entry(&self, path: &Path) -> Option<PathBuf>

Find the entry point file for a package path. If path is a file, returns it directly. If path is a directory, looks for language-specific entry points.

Provided Methods§

Source

fn discover_flat_packages(&self, source_path: &Path) -> Vec<(String, PathBuf)>

Discover packages in a flat directory (each entry is a package).

Source

fn discover_recursive_packages( &self, base_path: &Path, current_path: &Path, ) -> Vec<(String, PathBuf)>

Discover packages recursively (each file with matching extension is a package).

Source

fn discover_npm_scoped_packages( &self, source_path: &Path, ) -> Vec<(String, PathBuf)>

Discover packages in npm-scoped directory (handles @scope/package).

Implementors§

Source§

impl Language for Ada

Source§

impl Language for Agda

Source§

impl Language for AsciiDoc

Source§

impl Language for Asm

Source§

impl Language for Awk

Source§

impl Language for Bash

Source§

impl Language for Batch

Source§

impl Language for C

Source§

impl Language for Caddy

Source§

impl Language for Capnp

Source§

impl Language for Clojure

Source§

impl Language for CMake

Source§

impl Language for CommonLisp

Source§

impl Language for Cpp

Source§

impl Language for CSharp

Source§

impl Language for Css

Source§

impl Language for D

Source§

impl Language for Dart

Source§

impl Language for DeviceTree

Source§

impl Language for Diff

Source§

impl Language for Dockerfile

Source§

impl Language for Dot

Source§

impl Language for Elisp

Source§

impl Language for Elixir

Source§

impl Language for Elm

Source§

impl Language for Erlang

Source§

impl Language for Fish

Source§

impl Language for FSharp

Source§

impl Language for Gleam

Source§

impl Language for Glsl

Source§

impl Language for Go

Source§

impl Language for GraphQL

Source§

impl Language for Groovy

Source§

impl Language for Haskell

Source§

impl Language for Hcl

Source§

impl Language for Hlsl

Source§

impl Language for Html

Source§

impl Language for Idris

Source§

impl Language for Ini

Source§

impl Language for Java

Source§

impl Language for JavaScript

Source§

impl Language for Jinja2

Source§

impl Language for Jq

Source§

impl Language for Json

Source§

impl Language for Julia

Source§

impl Language for Kdl

Source§

impl Language for Kotlin

Source§

impl Language for Lean

Source§

impl Language for Lua

Source§

impl Language for Markdown

Source§

impl Language for Matlab

Source§

impl Language for Meson

Source§

impl Language for Nginx

Source§

impl Language for Ninja

Source§

impl Language for Nix

Source§

impl Language for ObjC

Source§

impl Language for OCaml

Source§

impl Language for Perl

Source§

impl Language for Php

Source§

impl Language for PostScript

Source§

impl Language for PowerShell

Source§

impl Language for Prolog

Source§

impl Language for Python

Source§

impl Language for Query

Source§

impl Language for R

Source§

impl Language for ReScript

Source§

impl Language for Ron

Source§

impl Language for Ruby

Source§

impl Language for Rust

Source§

impl Language for Scala

Source§

impl Language for Scheme

Source§

impl Language for Scss

Source§

impl Language for Sparql

Source§

impl Language for Sql

Source§

impl Language for SshConfig

Source§

impl Language for Starlark

Source§

impl Language for Svelte

Source§

impl Language for Swift

Source§

impl Language for TextProto

Source§

impl Language for Thrift

Source§

impl Language for TlaPlus

Source§

impl Language for Toml

Source§

impl Language for Tsx

Source§

impl Language for TypeScript

Source§

impl Language for Typst

Source§

impl Language for Uiua

Source§

impl Language for VB

Source§

impl Language for Verilog

Source§

impl Language for Vhdl

Source§

impl Language for Vim

Source§

impl Language for Vue

Source§

impl Language for Wit

Source§

impl Language for X86Asm

Source§

impl Language for Xml

Source§

impl Language for Yaml

Source§

impl Language for Yuri

Source§

impl Language for Zig

Source§

impl Language for Zsh