Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-syntax/src/ropey.rs')
| -rw-r--r-- | helix-syntax/src/ropey.rs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/helix-syntax/src/ropey.rs b/helix-syntax/src/ropey.rs index 650fcfb9..8b137891 100644 --- a/helix-syntax/src/ropey.rs +++ b/helix-syntax/src/ropey.rs @@ -1,29 +1 @@ -// glue code for using TS with ropey, this should be put behind a feature flag -// in the future (and potentially be partially removed) -use ropey::RopeSlice; -use tree_sitter::{Node, TextProvider}; - -// Adapter to convert rope chunks to bytes -pub struct ChunksBytes<'a> { - chunks: ropey::iter::Chunks<'a>, -} -impl<'a> Iterator for ChunksBytes<'a> { - type Item = &'a [u8]; - fn next(&mut self) -> Option<Self::Item> { - self.chunks.next().map(str::as_bytes) - } -} - -pub struct RopeProvider<'a>(pub RopeSlice<'a>); - -impl<'a> TextProvider<&'a [u8]> for RopeProvider<'a> { - type I = ChunksBytes<'a>; - - fn text(&mut self, node: Node) -> Self::I { - let fragment = self.0.byte_slice(node.start_byte()..node.end_byte()); - ChunksBytes { - chunks: fragment.chunks(), - } - } -} |