11use pgls_treesitter:: WrappingClause ;
22
3- type NodeIdentification = ( Option < String > , String ) ;
4-
5- #[ allow( unused) ]
63#[ derive( Debug ) ]
74pub ( crate ) enum HoveredNode {
85 Schema ( String ) ,
9- Table ( NodeIdentification ) ,
10- Function ( NodeIdentification ) ,
6+ Table ( ( Option < String > , String ) ) ,
7+ Function ( ( Option < String > , String ) ) ,
118 Column ( ( Option < String > , Option < String > , String ) ) ,
12- Policy ( NodeIdentification ) ,
13- Trigger ( NodeIdentification ) ,
149 Role ( String ) ,
15- PostgresType ( NodeIdentification ) ,
10+ PostgresType ( ( Option < String > , String ) ) ,
11+
12+ #[ allow( unused) ]
13+ Trigger ( ( Option < String > , String ) ) ,
14+ #[ allow( dead_code) ]
15+ Policy ( ( Option < String > , String ) ) ,
1616}
1717
1818impl HoveredNode {
@@ -27,20 +27,20 @@ impl HoveredNode {
2727
2828 match under_cursor. kind ( ) {
2929 "column_identifier" => Some ( HoveredNode :: Column ( (
30- ctx. identifier_qualifiers . 0 . clone ( ) ,
31- ctx. identifier_qualifiers . 1 . clone ( ) ,
30+ ctx. head_qualifier_sanitized ( ) ,
31+ ctx. tail_qualifier_sanitized ( ) ,
3232 node_content,
3333 ) ) ) ,
3434 "function_identifier" => Some ( HoveredNode :: Function ( (
35- ctx. identifier_qualifiers . 1 . clone ( ) ,
35+ ctx. tail_qualifier_sanitized ( ) ,
3636 node_content,
3737 ) ) ) ,
3838 "policy_identifier" => Some ( HoveredNode :: Policy ( (
39- ctx. identifier_qualifiers . 1 . clone ( ) ,
39+ ctx. tail_qualifier_sanitized ( ) ,
4040 node_content,
4141 ) ) ) ,
4242 "table_identifier" => Some ( HoveredNode :: Table ( (
43- ctx. identifier_qualifiers . 1 . clone ( ) ,
43+ ctx. tail_qualifier_sanitized ( ) ,
4444 node_content,
4545 ) ) ) ,
4646
@@ -58,7 +58,7 @@ impl HoveredNode {
5858 }
5959
6060 Some ( HoveredNode :: Table ( (
61- ctx. identifier_qualifiers . 1 . clone ( ) ,
61+ ctx. tail_qualifier_sanitized ( ) ,
6262 node_content,
6363 ) ) )
6464 }
@@ -75,7 +75,7 @@ impl HoveredNode {
7575 } ) =>
7676 {
7777 Some ( HoveredNode :: Table ( (
78- ctx. identifier_qualifiers . 1 . clone ( ) ,
78+ ctx. tail_qualifier_sanitized ( ) ,
7979 node_content,
8080 ) ) )
8181 }
@@ -85,8 +85,8 @@ impl HoveredNode {
8585 || ctx. matches_ancestor_history ( & [ "term" , "object_reference" ] ) =>
8686 {
8787 Some ( HoveredNode :: Column ( (
88- ctx. identifier_qualifiers . 0 . clone ( ) ,
89- ctx. identifier_qualifiers . 1 . clone ( ) ,
88+ ctx. head_qualifier_sanitized ( ) ,
89+ ctx. tail_qualifier_sanitized ( ) ,
9090 node_content,
9191 ) ) )
9292 }
@@ -95,7 +95,7 @@ impl HoveredNode {
9595 if ctx. matches_ancestor_history ( & [ "invocation" , "function_reference" ] ) =>
9696 {
9797 Some ( HoveredNode :: Function ( (
98- ctx. identifier_qualifiers . 1 . clone ( ) ,
98+ ctx. tail_qualifier_sanitized ( ) ,
9999 node_content,
100100 ) ) )
101101 }
@@ -109,14 +109,15 @@ impl HoveredNode {
109109 {
110110 Some ( HoveredNode :: Role ( node_content) )
111111 }
112+ "grant_role" | "policy_role" => Some ( HoveredNode :: Role ( node_content) ) ,
112113
113114 "any_identifier"
114115 if (
115116 // hover over custom type in `create table` or `returns`
116117 ( ctx. matches_ancestor_history ( & [ "type" , "object_reference" ] )
117118 && ctx. node_under_cursor_is_within_field_name ( & [ "custom_type" ] ) )
118119
119- // hover over type in `select` clause etc…
120+ // hover over type in `select` clause etc…
120121 || ( ctx
121122 . matches_ancestor_history ( & [ "field_selection" , "composite_reference" , "object_reference" ] )
122123 && ctx. node_under_cursor_is_within_field_name ( & [ "object_reference_1of1" , "object_reference_2of2" ] ) ) )
@@ -129,16 +130,16 @@ impl HoveredNode {
129130 . is_none ( ) =>
130131 {
131132 Some ( HoveredNode :: PostgresType ( (
132- ctx. identifier_qualifiers . 1 . clone ( ) ,
133+ ctx. tail_qualifier_sanitized ( ) ,
133134 node_content,
134135 ) ) )
135136 }
136137
137138 // quoted columns
138139 "literal" if ctx. matches_ancestor_history ( & [ "select_expression" , "term" ] ) => {
139140 Some ( HoveredNode :: Column ( (
140- ctx. identifier_qualifiers . 0 . clone ( ) ,
141- ctx. identifier_qualifiers . 1 . clone ( ) ,
141+ ctx. head_qualifier_sanitized ( ) ,
142+ ctx. tail_qualifier_sanitized ( ) ,
142143 node_content,
143144 ) ) )
144145 }
0 commit comments