pub enum LANG {
Show 25 variants
Javascript,
Mozjs,
Java,
Go,
Kotlin,
Lua,
Rust,
Tcl,
Irules,
C,
Cpp,
Mozcpp,
Objc,
Csharp,
Elixir,
Python,
Tsx,
Typescript,
Bash,
Ccomment,
Preproc,
Perl,
Php,
Ruby,
Groovy,
}Expand description
The list of supported languages.
Every variant is always defined regardless of the Cargo
feature set: per-language features only gate the grammar
crate references, never the enum surface itself. Disabled
variants surface at runtime as
crate::MetricsError::LanguageDisabled from every entry
point that returns a Result.
Variants§
Javascript
The JavaScript language (upstream tree-sitter-javascript grammar; the default for .js / .mjs / .cjs / .jsx)
Mozjs
The Mozilla/SpiderMonkey JavaScript dialect (vendored tree-sitter-mozjs fork; opt-in, owns the .jsm module extension)
Java
The Java language
Go
The Go language
Kotlin
The Kotlin language
Lua
The Lua language
Rust
The Rust language
Tcl
The Tcl language
Irules
The Irules language
C
The C language (upstream tree-sitter-c grammar). Owns .c and the c emacs mode since #721. C++ headers stay on LANG::Cpp (.h is asymmetric: a C++ header through the C grammar ERROR-cascades on class / template, while a C header through the C++ grammar only trips on C++-keyword identifiers).
Cpp
The C/C++ language (upstream tree-sitter-cpp grammar; the default for .cpp / .cc / .h and the rest of the C-family extensions). C moved to LANG::C (.c) in #721; the Mozilla/Gecko dialect moved to opt-in LANG::Mozcpp in #720. Objective-C (.m) moved to LANG::Objc in #724; .mm Objective-C++ stays here because the C++ grammar handles the C++ half (the ObjC glue still ERROR-cascades).
Mozcpp
The Mozilla/Gecko C++ dialect (vendored tree-sitter-mozcpp fork: upstream tree-sitter-cpp plus the MOZ_* / QM_TRY_* / alone-macro overlay; opt-in, owns no file extensions — select it explicitly with --language mozcpp, a manifest, or the API).
Objc
The Objective-C language (upstream tree-sitter-objc grammar). Owns .m and the objc / objective-c emacs modes since #724. Objective-C++ (.mm) stays on LANG::Cpp: the ObjC grammar parses C but not the C++ half of a .mm file, and C++ is the larger surface, so Cpp degrades more gracefully there (the same trade-off #721 used for .h).
Csharp
The C# language
Elixir
The Elixir language
Python
The Python language
Tsx
The Tsx language incorporates the JSX syntax inside TypeScript
Typescript
The TypeScript language
Bash
The Bash language
Ccomment
The Ccomment language is a variant of the C language focused on comments
Preproc
The PreProc language is a variant of the C/C++ language focused on macros
Perl
The Perl language
Php
The Php language
Ruby
The Ruby language
Groovy
The Groovy language
Implementations§
Source§impl LANG
impl LANG
Sourcepub fn into_enum_iter() -> impl Iterator<Item = LANG>
pub fn into_enum_iter() -> impl Iterator<Item = LANG>
Return an iterator over the supported languages.
§Examples
use big_code_analysis::LANG;
for lang in LANG::into_enum_iter() {
println!("{:?}", lang);
}Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Returns the name of a language as a &str.
§Examples
use big_code_analysis::LANG;
println!("{}", LANG::Rust.name());Sourcepub fn grammar_version(&self) -> &'static str
pub fn grammar_version(&self) -> &'static str
Returns the pinned tree-sitter grammar crate version that
backs this variant (e.g. "0.25.1" for LANG::Bash).
The value mirrors the =X.Y.Z pin in the workspace
Cargo.toml and is independent of the per-language Cargo
feature: it is returned even for a variant whose feature is
disabled in the current build (a build-time constant, no
grammar crate reference). A drift test in src/langs.rs
asserts every value here matches the manifest pin.
§Grammars vs. forks
For languages backed by an upstream crates.io grammar
(bash, rust, python, typescript, …) this is the
exact upstream grammar version, so a consumer migrating
matchers off py-tree-sitter can line node-kind vocabularies
up against the same pin. For the vendored big-code-analysis
forks (mozcpp, mozjs, tcl, ccomment, preproc,
kotlin) the value is the fork crate’s version
(published as bca-tree-sitter-* / tree-sitter-kotlin-ng),
not an upstream tree-sitter grammar semver — there is no
upstream release to compare against.
This is part of the value-not-stable surface: the returned version changes whenever the grammar pin is bumped.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Reports whether this variant’s grammar crate is compiled into the current build.
Returns false for variants whose per-language Cargo
feature is disabled; calling
Self::tree_sitter_language, crate::analyze,
or any other dispatcher with such a variant will
return crate::MetricsError::LanguageDisabled.
Sourcepub fn tree_sitter_language(&self) -> Result<Language, MetricsError>
pub fn tree_sitter_language(&self) -> Result<Language, MetricsError>
Returns the tree_sitter::Language grammar used by
this variant.
Useful when feeding a caller-built
tree_sitter::Parser into the
crate::Ast::from_tree_sitter entry point — the
language returned here is the one the metric walker
expects for kind_id matching, so the trees agree
structurally.
This method is part of the value-not-stable surface:
the underlying tree-sitter-* grammar pin may bump
in any minor release, which can change Language
equality on the caller side.
§Errors
Returns crate::MetricsError::LanguageDisabled when
the variant’s per-language Cargo feature is not
enabled in the current build (see the [features]
table in the root Cargo.toml).
§Examples
use big_code_analysis::LANG;
let _lang = LANG::Rust.tree_sitter_language().expect("rust feature enabled");Source§impl LANG
impl LANG
Sourcepub fn extensions(&self) -> &'static [&'static str]
pub fn extensions(&self) -> &'static [&'static str]
Returns the file extensions recognised for this language.
The returned list is the same one consulted by
get_from_ext and crate::get_language_for_file.
Helper variants without user-facing files (Ccomment,
Preproc) return an empty slice.
§Examples
use big_code_analysis::LANG;
assert!(LANG::Rust.extensions().contains(&"rs"));Trait Implementations§
impl Copy for LANG
Source§impl Display for LANG
Renders the language’s canonical lowercase slug, identical to
LANG::name.
impl Display for LANG
Renders the language’s canonical lowercase slug, identical to
LANG::name.
Every variant has a distinct slug, so Display is injective
and a Display → FromStr round-trip
returns the original variant (see the round-trip test in
src/langs.rs). The slug is the single canonical identifier
used across every surface (CLI JSON, web /metrics, the
Python bindings): it contains no punctuation and is always a
valid FromStr lookup token.
impl Eq for LANG
Source§impl FromStr for LANG
Parses a LANG from its Display
spelling (the canonical lowercase LANG::name slug, e.g.
"rust", "cpp", "csharp", "tsx").
impl FromStr for LANG
Parses a LANG from its Display
spelling (the canonical lowercase LANG::name slug, e.g.
"rust", "cpp", "csharp", "tsx").
Matching is case-sensitive and exact, mirroring
Metric’s FromStr: only the canonical
lowercase slug is accepted. File extensions and emacs modes
are deliberately not accepted here — use
get_from_ext /
get_from_emacs_mode for those.
Every variant has a distinct slug, so this is the exact
inverse of Display: the round-trip
LANG::from_str(&lang.to_string()) returns the original
variant for every LANG.
impl StructuralPartialEq for LANG
Auto Trait Implementations§
impl Freeze for LANG
impl RefUnwindSafe for LANG
impl Send for LANG
impl Sync for LANG
impl Unpin for LANG
impl UnsafeUnpin for LANG
impl UnwindSafe for LANG
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.