Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate ast_grep_language

Crate ast_grep_language 

Source
Expand description

This module defines the supported programming languages for ast-grep.

It provides a set of customized languages with expando_char / pre_process_pattern, and a set of stub languages without preprocessing. A rule of thumb: if your language does not accept identifiers like $VAR. You need use impl_lang_expando! macro and a standalone file for testing. Otherwise, you can define it as a stub language using impl_lang!. To see the full list of languages, visit <https://ast-grep.github.io/reference/languages.html>

use ast_grep_language::{LanguageExt, SupportLang};

let lang: SupportLang = "rs".parse().unwrap();
let src = "fn foo() {}";
let root = lang.ast_grep(src);
let found = root.root().find_all("fn $FNAME() {}").next().unwrap();
assert_eq!(found.start_pos().line(), 0);
assert_eq!(found.text(), "fn foo() {}");

Structs§

Bash
C
CSharp
Cpp
Css
Dart
Elixir
Go
Haskell
Hcl
Html
Java
JavaScript
Json
Kotlin
Lua
Markdown
Nix
Php
Python
Ruby
Rust
Scala
Solidity
Swift
Tsx
TypeScript
Yaml

Enums§

SupportLang
Represents all built-in languages.
SupportLangErr

Traits§

Alias
Language
Trait to abstract ts-language usage in ast-grep, which includes:
LanguageExt
tree-sitter specific language trait

Functions§

config_file_type