Add tree included ranges getter
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
fb5fbdd787
commit
1848d0bc36
4 changed files with 21 additions and 0 deletions
|
|
@ -345,6 +345,9 @@ extern "C" {
|
|||
#[doc = " Get the language that was used to parse the syntax tree."]
|
||||
pub fn ts_tree_language(arg1: *const TSTree) -> *const TSLanguage;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn ts_tree_included_ranges(arg1: *const TSTree, length: *mut u32) -> *mut TSRange;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Edit the syntax tree to keep it in sync with source code that has been"]
|
||||
#[doc = " edited."]
|
||||
|
|
|
|||
|
|
@ -763,6 +763,15 @@ impl Tree {
|
|||
util::CBufferIter::new(ptr, count as usize).map(|r| r.into())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn included_ranges(&self) -> Vec<Range> {
|
||||
let mut count = 0u32;
|
||||
unsafe {
|
||||
let ptr = ffi::ts_tree_included_ranges(self.0.as_ptr(), &mut count as *mut u32);
|
||||
let ranges = Vec::from_raw_parts(ptr, count as usize, count as usize);
|
||||
ranges.into_iter().map(|range| range.into()).collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Tree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue