diff --git a/cli/src/tests/properties_test.rs b/cli/src/tests/properties_test.rs index 401ba66f..f25b902c 100644 --- a/cli/src/tests/properties_test.rs +++ b/cli/src/tests/properties_test.rs @@ -40,7 +40,7 @@ fn test_walk_with_properties_with_nth_child() { parser.set_language(language).unwrap(); let tree = parser.parse(source_code, None).unwrap(); - let mut cursor = tree.walk_with_properties(&property_sheet, source_code); + let mut cursor = tree.walk_with_properties(&property_sheet, source_code.as_bytes()); assert_eq!(cursor.node().kind(), "program"); assert!(cursor.goto_first_child()); assert_eq!(cursor.node().kind(), "expression_statement"); @@ -98,7 +98,7 @@ fn test_walk_with_properties_with_regexes() { parser.set_language(language).unwrap(); let tree = parser.parse(source_code, None).unwrap(); - let mut cursor = tree.walk_with_properties(&property_sheet, source_code); + let mut cursor = tree.walk_with_properties(&property_sheet, source_code.as_bytes()); assert_eq!(cursor.node().kind(), "program"); assert!(cursor.goto_first_child()); assert_eq!(cursor.node().kind(), "lexical_declaration"); diff --git a/lib/binding/lib.rs b/lib/binding/lib.rs index 6c79f896..efc00978 100644 --- a/lib/binding/lib.rs +++ b/lib/binding/lib.rs @@ -123,7 +123,7 @@ pub struct TreePropertyCursor<'a, P> { state_stack: Vec, child_index_stack: Vec, property_sheet: &'a PropertySheet

, - source: &'a str, + source: &'a [u8], } impl Language { @@ -355,7 +355,7 @@ impl Tree { pub fn walk_with_properties<'a, P>( &'a self, property_sheet: &'a PropertySheet

, - source: &'a str, + source: &'a [u8], ) -> TreePropertyCursor<'a, P> { TreePropertyCursor::new(self, property_sheet, source) } @@ -613,7 +613,7 @@ impl<'a> Drop for TreeCursor<'a> { } impl<'a, P> TreePropertyCursor<'a, P> { - fn new(tree: &'a Tree, property_sheet: &'a PropertySheet

, source: &'a str) -> Self { + fn new(tree: &'a Tree, property_sheet: &'a PropertySheet

, source: &'a [u8]) -> Self { let mut result = Self { cursor: tree.root_node().walk(), child_index_stack: vec![0], @@ -690,7 +690,7 @@ impl<'a, P> TreePropertyCursor<'a, P> { for transition in transitions.iter() { if let Some(text_regex_index) = transition.text_regex_index { let node = self.cursor.node(); - let text = &self.source.as_bytes()[node.start_byte()..node.end_byte()]; + let text = &self.source[node.start_byte()..node.end_byte()]; if let Ok(text) = str::from_utf8(text) { if !self.property_sheet.text_regexes[text_regex_index].is_match(text) { continue;