pub struct InjectedRegion {
pub parent_start_byte: usize,
pub language: Language,
pub tree: Tree,
pub text: String,
}Expand description
An injected parse region — a sub-tree parsed with a different language.
For example, a PL/pgSQL function body inside a CREATE FUNCTION statement is parsed with the plpgsql grammar, and SQL expressions within PL/pgSQL are injected back with the postgres grammar.
Fields§
§parent_start_byte: usizeByte offset of this region within the parent document.
language: LanguageThe language of the injected region.
tree: TreeThe parse tree for the injected content.
text: StringThe source text of the injected region.
Implementations§
Source§impl InjectedRegion
impl InjectedRegion
Sourcepub fn to_parent_byte(&self, local_byte: usize) -> usize
pub fn to_parent_byte(&self, local_byte: usize) -> usize
Convert a byte offset within this injected region to the parent document offset.
Sourcepub fn parent_position(&self, source: &str) -> (usize, usize)
pub fn parent_position(&self, source: &str) -> (usize, usize)
Compute the (line, column) of this region’s start within the parent document.
Sourcepub fn to_local_byte(&self, parent_byte: usize) -> Option<usize>
pub fn to_local_byte(&self, parent_byte: usize) -> Option<usize>
Convert a parent document byte offset to a local offset within this region. Returns None if the parent offset is outside this region.
Trait Implementations§
Auto Trait Implementations§
impl Forget for InjectedRegion
impl Freeze for InjectedRegion
impl Move for InjectedRegion
impl RefUnwindSafe for InjectedRegion
impl Send for InjectedRegion
impl Sync for InjectedRegion
impl Unpin for InjectedRegion
impl UnsafeUnpin for InjectedRegion
impl UnwindSafe for InjectedRegion
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