Module ast_grep_core::source
source · Expand description
This module defines the Doc
and Content
traits to abstract away source code encoding issues.
ast-grep supports three kinds of encoding: utf-8 for CLI, utf-16 for nodeJS napi and Vec<char>
for wasm.
Different encoding will produce different tree-sitter Node’s range and position.
The Content
trait is defined to abstract different encoding.
It is used as associated type bound Source
in the Doc
trait.
Its associated type Underlying
represents the underlying type of the content, e.g. Vec<u8>
, Vec<u16>
.
Doc
is a trait that defines a document that can be parsed by Tree-sitter.
It has a Source
associated type bounded by Content
that represents the source code of the document,
and a Lang
associated type that represents the language of the document.
Structs§
Enums§
- Represents tree-sitter related error