Skip to main content

Language

Trait Language 

Source
pub trait Language: Send + Sync {
Show 22 methods // Required methods fn name(&self) -> &'static str; fn extensions(&self) -> &'static [&'static str]; fn grammar_name(&self) -> &'static str; // Provided methods fn as_symbols(&self) -> Option<&dyn LanguageSymbols> { ... } fn extract_docstring( &self, _node: &Node<'_>, _content: &str, ) -> Option<String> { ... } fn extract_attributes( &self, _node: &Node<'_>, _content: &str, ) -> Vec<String> { ... } fn extract_implements( &self, _node: &Node<'_>, _content: &str, ) -> ImplementsInfo { ... } fn build_signature(&self, node: &Node<'_>, content: &str) -> String { ... } fn refine_kind( &self, node: &Node<'_>, _content: &str, tag_kind: SymbolKind, ) -> SymbolKind { ... } fn extract_imports(&self, _node: &Node<'_>, _content: &str) -> Vec<Import> { ... } fn format_import(&self, _import: &Import, _names: Option<&[&str]>) -> String { ... } fn signature_suffix(&self) -> &'static str { ... } fn get_visibility(&self, _node: &Node<'_>, _content: &str) -> Visibility { ... } fn is_test_symbol(&self, _symbol: &Symbol) -> bool { ... } fn test_file_globs(&self) -> &'static [&'static str] { ... } fn as_embedded(&self) -> Option<&dyn LanguageEmbedded> { ... } fn container_body<'a>(&self, _node: &'a Node<'a>) -> Option<Node<'a>> { ... } fn body_has_docstring(&self, _body: &Node<'_>, _content: &str) -> bool { ... } fn analyze_container_body( &self, _body_node: &Node<'_>, _content: &str, _inner_indent: &str, ) -> Option<ContainerBody> { ... } fn extract_module_doc(&self, _src: &str) -> Option<String> { ... } fn module_resolver(&self) -> Option<&dyn ModuleResolver> { ... } fn node_name<'a>( &self, node: &Node<'_>, content: &'a str, ) -> Option<&'a str> { ... }
}
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”)

Provided Methods§

Source

fn as_symbols(&self) -> Option<&dyn LanguageSymbols>

Capability query: returns Some(self) if this language has code symbols (functions, classes, types, etc.). Returns None for config/data languages. Implement LanguageSymbols and override this to opt in.

Source

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

Extract the docstring for a definition node. Called by generic extraction for every tagged symbol. Returns None if this language has no docstring convention or the node has no docstring.

Source

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

Extract attributes/annotations/decorators attached to a definition node. Called by generic extraction for every tagged symbol. Returns empty vec if this language has no attribute convention.

Source

fn extract_implements(&self, _node: &Node<'_>, _content: &str) -> ImplementsInfo

Extract interfaces/traits/superclasses that a container node implements/extends. Called by generic extraction for container nodes only.

Source

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

Build the display signature for a definition node. Default: first line of the node’s source text (trimmed). Override for languages where first-line is incomplete (e.g. Rust, Go, Java).

Source

fn refine_kind( &self, node: &Node<'_>, _content: &str, tag_kind: SymbolKind, ) -> SymbolKind

Refine the symbol kind for a tagged node. Called after tag classification assigns an initial kind (e.g. definition.classClass). Languages can override this to return a more specific kind based on the node’s concrete type. Default: return tag_kind unchanged.

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 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 get_visibility(&self, _node: &Node<'_>, _content: &str) -> Visibility

Get visibility of a node.

This is a genuine interface method (not just an impl helper): normalize-deps calls it externally during export detection to decide which tagged nodes are public. The alternative — calling extract_function/container/type() and inspecting symbol.visibility — would be correct but unnecessarily heavy (computes signature, docstring, etc. just to check one field).

Source

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

Check if a symbol is a test (for filtering).

Source

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

Glob patterns (relative, using ** wildcards) that identify dedicated test files. Used to build a GlobSet for fast batch matching. Return &[] for languages with no dedicated test files (e.g. those using only inline tests).

Source

fn as_embedded(&self) -> Option<&dyn LanguageEmbedded>

Capability query: returns Some(self) if this language can contain embedded blocks in another language (e.g., JS in Vue, CSS in HTML). Returns None for most languages. Implement LanguageEmbedded and override this to opt in.

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 analyze_container_body( &self, _body_node: &Node<'_>, _content: &str, _inner_indent: &str, ) -> Option<ContainerBody>

Analyze a container body node and return the editable byte range. body_node is the node returned by container_body. Returns None if this language doesn’t support container body editing.

Source

fn extract_module_doc(&self, _src: &str) -> Option<String>

Extract the module-level doc comment from raw file source.

Called when viewing a file (not a specific symbol) to populate ViewReport.summary. Returns None if this language has no module-doc convention or the file has none.

Conventions by language:

  • Rust: leading //! inner-doc comment lines
  • Python: first statement is a string literal ("""...""")
  • Go: line comment(s) immediately before package foo
  • JavaScript/TypeScript: leading /** ... */ block comment at top of file
  • Ruby: leading # comment block (ignoring # frozen_string_literal lines)
Source

fn module_resolver(&self) -> Option<&dyn ModuleResolver>

Return the module resolver for this language, if it has one.

Languages with a module system (Rust, TypeScript, Python, Go, etc.) implement this to enable cross-file name resolution. Languages without a module system (Bash, GLSL, etc.) return None.

Source

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

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

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