pub enum SupportLang {
Show 26 variants
Bash,
C,
Cpp,
CSharp,
Css,
Elixir,
Go,
Haskell,
Hcl,
Html,
Java,
JavaScript,
Json,
Kotlin,
Lua,
Nix,
Php,
Python,
Ruby,
Rust,
Scala,
Solidity,
Swift,
Tsx,
TypeScript,
Yaml,
}Expand description
Runtime language selection enum supporting all built-in languages.
Provides a unified interface for working with any supported language at runtime. Each variant corresponds to a specific programming language implementation.
§Language Detection
ⓘ
use thread_language::SupportLang;
use std::path::Path;
// Detect from file extension
let lang = SupportLang::from_path("main.rs").unwrap();
assert_eq!(lang, SupportLang::Rust);
// Parse from string
let lang: SupportLang = "javascript".parse().unwrap();
assert_eq!(lang, SupportLang::JavaScript);§Usage with AST Analysis
ⓘ
use thread_language::SupportLang;
use thread_ast_engine::{Language, LanguageExt};
let lang = SupportLang::Rust;
let tree = lang.ast_grep("fn main() {}");
let pattern = lang.build_pattern(&pattern_builder).unwrap();Variants§
Bash
C
Cpp
CSharp
Css
Elixir
Go
Haskell
Hcl
Html
Java
JavaScript
Json
Kotlin
Lua
Nix
Php
Python
Ruby
Rust
Scala
Solidity
Swift
Tsx
TypeScript
Yaml
Implementations§
Source§impl SupportLang
impl SupportLang
pub const fn all_langs() -> &'static [SupportLang]
pub fn file_types(&self) -> Types
Trait Implementations§
Source§impl Clone for SupportLang
impl Clone for SupportLang
Source§fn clone(&self) -> SupportLang
fn clone(&self) -> SupportLang
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SupportLang
impl Debug for SupportLang
Source§impl<'de> Deserialize<'de> for SupportLang
Available on crate features all-parsers or napi-compatible or css-napi or html-napi or javascript-napi or typescript-napi or tsx-napi or bash or c or cpp or csharp or css or elixir or go or haskell or hcl or html or java or javascript or json or kotlin or lua or nix or php or python or ruby or rust or scala or solidity or swift or tsx or typescript or yaml only.
impl<'de> Deserialize<'de> for SupportLang
Available on crate features
all-parsers or napi-compatible or css-napi or html-napi or javascript-napi or typescript-napi or tsx-napi or bash or c or cpp or csharp or css or elixir or go or haskell or hcl or html or java or javascript or json or kotlin or lua or nix or php or python or ruby or rust or scala or solidity or swift or tsx or typescript or yaml only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for SupportLang
impl Display for SupportLang
Source§impl From<Bash> for SupportLang
impl From<Bash> for SupportLang
Source§impl From<C> for SupportLang
impl From<C> for SupportLang
Source§impl From<CSharp> for SupportLang
impl From<CSharp> for SupportLang
Source§impl From<Cpp> for SupportLang
impl From<Cpp> for SupportLang
Source§impl From<Css> for SupportLang
impl From<Css> for SupportLang
Source§impl From<Elixir> for SupportLang
impl From<Elixir> for SupportLang
Source§impl From<Go> for SupportLang
impl From<Go> for SupportLang
Source§impl From<Haskell> for SupportLang
impl From<Haskell> for SupportLang
Source§impl From<Hcl> for SupportLang
impl From<Hcl> for SupportLang
Source§impl From<Html> for SupportLang
impl From<Html> for SupportLang
Source§impl From<Java> for SupportLang
impl From<Java> for SupportLang
Source§impl From<JavaScript> for SupportLang
impl From<JavaScript> for SupportLang
Source§fn from(_: JavaScript) -> Self
fn from(_: JavaScript) -> Self
Converts to this type from the input type.
Source§impl From<Json> for SupportLang
impl From<Json> for SupportLang
Source§impl From<Kotlin> for SupportLang
impl From<Kotlin> for SupportLang
Source§impl From<Lua> for SupportLang
impl From<Lua> for SupportLang
Source§impl From<Nix> for SupportLang
impl From<Nix> for SupportLang
Source§impl From<Php> for SupportLang
impl From<Php> for SupportLang
Source§impl From<Python> for SupportLang
impl From<Python> for SupportLang
Source§impl From<Ruby> for SupportLang
impl From<Ruby> for SupportLang
Source§impl From<Rust> for SupportLang
impl From<Rust> for SupportLang
Source§impl From<Scala> for SupportLang
impl From<Scala> for SupportLang
Source§impl From<Solidity> for SupportLang
impl From<Solidity> for SupportLang
Source§impl From<Swift> for SupportLang
impl From<Swift> for SupportLang
Source§impl From<Tsx> for SupportLang
impl From<Tsx> for SupportLang
Source§impl From<TypeScript> for SupportLang
impl From<TypeScript> for SupportLang
Source§fn from(_: TypeScript) -> Self
fn from(_: TypeScript) -> Self
Converts to this type from the input type.
Source§impl From<Yaml> for SupportLang
impl From<Yaml> for SupportLang
Source§impl FromStr for SupportLang
Implements the language names and aliases.
impl FromStr for SupportLang
Implements the language names and aliases.
Source§impl Hash for SupportLang
impl Hash for SupportLang
Source§impl Language for SupportLang
Available on crate feature matching and (crate features all-parsers or napi-environment or napi-compatible or bash or c or cpp or csharp or css or elixir or go or haskell or hcl or html or java or javascript or json or kotlin or lua or nix or php or python or ruby or rust or scala or solidity or swift or tsx or typescript or yaml) only.
impl Language for SupportLang
Available on crate feature
matching and (crate features all-parsers or napi-environment or napi-compatible or bash or c or cpp or csharp or css or elixir or go or haskell or hcl or html or java or javascript or json or kotlin or lua or nix or php or python or ruby or rust or scala or solidity or swift or tsx or typescript or yaml) only.fn kind_to_id(&self, kind: &str) -> u16
fn field_to_id(&self, field: &str) -> Option<u16>
Source§fn meta_var_char(&self) -> char
fn meta_var_char(&self) -> char
Configure meta variable special character
By default $ is the metavar char, but in PHP it can be #
Source§fn expando_char(&self) -> char
fn expando_char(&self) -> char
Some language does not accept $ as the leading char for identifiers.
We need to change $ to other char at run-time to make parser happy, thus the name expando.
By default this is the same as
meta_var char so replacement is done at runtime.Source§fn extract_meta_var(&self, source: &str) -> Option<MetaVariable>
fn extract_meta_var(&self, source: &str) -> Option<MetaVariable>
extract
MetaVariable from a given source string
At runtime we need to use expand_charfn build_pattern( &self, builder: &PatternBuilder<'_>, ) -> Result<Pattern, PatternError>
Source§impl LanguageExt for SupportLang
Available on crate feature matching and (crate features all-parsers or napi-compatible or css-napi or html-napi or javascript-napi or typescript-napi or tsx-napi or bash or c or cpp or csharp or css or elixir or go or haskell or hcl or html or java or javascript or json or kotlin or lua or nix or php or python or ruby or rust or scala or solidity or swift or tsx or typescript or yaml) only.
impl LanguageExt for SupportLang
Available on crate feature
matching and (crate features all-parsers or napi-compatible or css-napi or html-napi or javascript-napi or typescript-napi or tsx-napi or bash or c or cpp or csharp or css or elixir or go or haskell or hcl or html or java or javascript or json or kotlin or lua or nix or php or python or ruby or rust or scala or solidity or swift or tsx or typescript or yaml) only.Source§fn get_ts_language(&self) -> TSLanguage
fn get_ts_language(&self) -> TSLanguage
Get the tree-sitter language object for parsing. Read more
Source§fn injectable_languages(&self) -> Option<&'static [&'static str]>
fn injectable_languages(&self) -> Option<&'static [&'static str]>
List of languages that can be injected into this language. Read more
Source§impl PartialEq for SupportLang
impl PartialEq for SupportLang
Source§impl Serialize for SupportLang
impl Serialize for SupportLang
impl Copy for SupportLang
impl Eq for SupportLang
impl StructuralPartialEq for SupportLang
Auto Trait Implementations§
impl Freeze for SupportLang
impl RefUnwindSafe for SupportLang
impl Send for SupportLang
impl Sync for SupportLang
impl Unpin for SupportLang
impl UnsafeUnpin for SupportLang
impl UnwindSafe for SupportLang
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
Mutably borrows from an owned value. Read more