@@ -631,75 +631,6 @@ impl<'a> TreesitterContext<'a> {
631631 . current ( )
632632 . ancestors
633633 . matches_history ( expected_ancestors)
634-
635- // self.node_under_cursor.as_ref().is_some_and(|node| {
636- // let mut current = Some(*node);
637-
638- // for &expected_kind in expected_ancestors.iter().rev() {
639- // current = current.and_then(|n| n.parent());
640-
641- // match current {
642- // Some(ancestor) if ancestor.kind() == expected_kind => continue,
643- // _ => return false,
644- // }
645- // }
646-
647- // true
648- // })
649- }
650-
651- /// Verifies if the node has one of the named direct ancestors.
652- pub fn matches_one_of_ancestors ( & self , expected_ancestors : & [ & ' static str ] ) -> bool {
653- self . node_under_cursor . as_ref ( ) . is_some_and ( |node| {
654- node. parent ( )
655- . is_some_and ( |p| expected_ancestors. contains ( & p. kind ( ) ) )
656- } )
657- }
658-
659- /// Checks whether the Node under the cursor is the nth child of the parent.
660- ///
661- /// ```
662- /// /*
663- /// * Given `select * from "a|uth"."users";`
664- /// * The node under the cursor is "auth".
665- /// *
666- /// * [...] redacted
667- /// * from [9..28] 'from "auth"."users"'
668- /// * keyword_from [9..13] 'from'
669- /// * relation [14..28] '"auth"."users"'
670- /// * object_reference [14..28] '"auth"."users"'
671- /// * any_identifier [14..20] '"auth"'
672- /// * . [20..21] '.'
673- /// * any_identifier [21..28] '"users"'
674- /// */
675- ///
676- /// if node_under_cursor_is_nth_child(1) {
677- /// node_type = "schema";
678- /// } else if node_under_cursor_is_nth_child(3) {
679- /// node_type = "table";
680- /// }
681- /// ```
682- pub fn node_under_cursor_is_nth_child ( & self , nth : usize ) -> bool {
683- self . node_under_cursor . as_ref ( ) . is_some_and ( |node| {
684- let mut cursor = node. walk ( ) ;
685- node. parent ( ) . is_some_and ( |p| {
686- p. children ( & mut cursor)
687- . nth ( nth - 1 )
688- . is_some_and ( |n| n. id ( ) == node. id ( ) )
689- } )
690- } )
691- }
692-
693- /// Returns the number of siblings of the node under the cursor.
694- pub fn num_siblings ( & self ) -> usize {
695- self . node_under_cursor
696- . as_ref ( )
697- . map ( |node| {
698- // if there's no parent, we're on the top of the tree,
699- // where we have 0 siblings.
700- node. parent ( ) . map ( |p| p. child_count ( ) - 1 ) . unwrap_or ( 0 )
701- } )
702- . unwrap_or ( 0 )
703634 }
704635
705636 /// Returns true if the node under the cursor matches the field_name OR has a parent that matches the field_name.
@@ -708,37 +639,6 @@ impl<'a> TreesitterContext<'a> {
708639 . current ( )
709640 . ancestors
710641 . is_within_one_of_fields ( names)
711- // self.node_under_cursor
712- // .as_ref()
713- // .map(|node| {
714- // // It might seem weird that we have to check for the field_name from the parent,
715- // // but TreeSitter wants it this way, since nodes often can only be named in
716- // // the context of their parents.
717- // let root_node = self.tree.root_node();
718- // let mut cursor = node.walk();
719- // let mut parent = node.parent();
720-
721- // while let Some(p) = parent {
722- // if p == root_node {
723- // break;
724- // }
725-
726- // for name in names {
727- // if p.children_by_field_name(name, &mut cursor).any(|c| {
728- // let r = c.range();
729- // // if the parent range contains the node range, the node is of the field_name.
730- // r.start_byte <= node.start_byte() && r.end_byte >= node.end_byte()
731- // }) {
732- // return true;
733- // }
734- // }
735-
736- // parent = p.parent();
737- // }
738-
739- // false
740- // })
741- // .unwrap_or(false)
742642 }
743643
744644 pub fn get_mentioned_relations ( & self , key : & Option < String > ) -> Option < & HashSet < String > > {
0 commit comments