pub trait Language: Send + Sync {
// Required methods
fn id(&self) -> LanguageId;
fn extensions(&self) -> &'static [&'static str];
fn grammar(&self) -> Language;
// Provided methods
fn resolver(&self) -> Option<Arc<dyn BindingResolver>> { ... }
fn grammar_abi(&self) -> usize { ... }
}Expand description
Re-exported so consumers can supply languages without depending on lanekeep-lang directly.
A language lanekeep can parse.
Send + Sync because the walker runs files across rayon workers, and every worker needs
the grammar.
Binding resolution — the light semantic layer behind the import-resolution host functions — is deliberately not a method here yet. Its signature depends on the tree and file context types, which do not exist. Adding a method to a trait with no external implementors is cheap; committing to a half-designed signature is not.
Required Methods§
Sourcefn id(&self) -> LanguageId
fn id(&self) -> LanguageId
Stable identifier, as written in a rule’s language field.
Sourcefn extensions(&self) -> &'static [&'static str]
fn extensions(&self) -> &'static [&'static str]
Extensions this language claims, without the leading dot, lowercase.
Two languages must not claim the same extension; the registry rejects that at registration rather than picking a winner.
Provided Methods§
Sourcefn resolver(&self) -> Option<Arc<dyn BindingResolver>>
fn resolver(&self) -> Option<Arc<dyn BindingResolver>>
Identifier resolution for this language, when it has any.
Returns None for a language with no resolver yet, which is honest rather than a
placeholder: a rule asking about bindings in such a language gets nothing back
instead of a confidently wrong answer.
Sourcefn grammar_abi(&self) -> usize
fn grammar_abi(&self) -> usize
The grammar’s ABI version.
This is a cache key input. A grammar bump changes node shapes and therefore query results, so an entry computed under a different ABI is not a valid entry — it would serve results derived from a tree that no longer exists.
Read from the grammar rather than written down, or it stops tracking the thing it exists to track the first time someone forgets to update it. Note that bundled grammars do not share an ABI — TypeScript and JavaScript currently differ — which is why this is per-language rather than one global constant.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".