Skip to main content

LANG

Enum LANG 

Source
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

Source

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);
}
Source

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());
Source

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.

Source

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.

Source

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

Source

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§

Source§

impl Clone for LANG

Source§

fn clone(&self) -> LANG

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LANG

Source§

impl Debug for LANG

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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 DisplayFromStr 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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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").

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.

Source§

type Err = ParseLangError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for LANG

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LANG

Source§

fn eq(&self, other: &LANG) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.