Skip to content

Commit d82f7b3

Browse files
ok
1 parent 2aa5c9f commit d82f7b3

File tree

4 files changed

+159
-133
lines changed

4 files changed

+159
-133
lines changed

crates/pgt_completions/src/relevance/filtering.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ impl CompletionFilter<'_> {
6969
// No autocompletions if there are two identifiers without a separator.
7070
if ctx.node_under_cursor.as_ref().is_some_and(|node| {
7171
node.prev_sibling().is_some_and(|p| {
72-
(p.kind() == "identifier" || p.kind() == "object_reference")
73-
&& node.kind() == "identifier"
72+
(p.kind() == "any_identifier" || p.kind() == "object_reference")
73+
&& node.kind() == "any_identifier"
7474
})
7575
}) {
7676
return None;
@@ -80,7 +80,7 @@ impl CompletionFilter<'_> {
8080
// `select * {}`
8181
if ctx.node_under_cursor.as_ref().is_some_and(|node| {
8282
node.prev_sibling()
83-
.is_some_and(|p| (p.kind() == "all_fields") && node.kind() == "identifier")
83+
.is_some_and(|p| (p.kind() == "all_fields") && node.kind() == "any_identifier")
8484
}) {
8585
return None;
8686
}
@@ -254,7 +254,7 @@ impl CompletionFilter<'_> {
254254
WrappingClause::RevokeStatement | WrappingClause::GrantStatement => {
255255
ctx.matches_ancestor_history(&["role_specification"])
256256
|| ctx.node_under_cursor.as_ref().is_some_and(|k| {
257-
k.kind() == "identifier"
257+
k.kind() == "any_identifier"
258258
&& ctx.before_cursor_matches_kind(&[
259259
"keyword_grant",
260260
"keyword_revoke",

crates/pgt_hover/src/hovered_node.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl HoveredNode {
3232
let under_cursor = ctx.node_under_cursor.as_ref()?;
3333

3434
match under_cursor.kind() {
35-
"identifier"
35+
"any_identifier"
3636
if ctx.matches_ancestor_history(&["relation", "object_reference"])
3737
|| ctx
3838
.matches_ancestor_history(&["grantable_on_table", "object_reference"]) =>
@@ -52,7 +52,7 @@ impl HoveredNode {
5252
}
5353
}
5454

55-
"identifier"
55+
"any_identifier"
5656
if ctx.matches_ancestor_history(&["object_reference"])
5757
&& ctx.wrapping_clause_type.as_ref().is_some_and(|clause| {
5858
matches!(
@@ -73,7 +73,7 @@ impl HoveredNode {
7373
}
7474
}
7575

76-
"identifier" if ctx.matches_ancestor_history(&["field"]) => {
76+
"any_identifier" if ctx.matches_ancestor_history(&["field"]) => {
7777
if let Some(table_or_alias) = ctx.schema_or_alias_name.as_ref() {
7878
Some(HoveredNode::Column(NodeIdentification::SchemaAndName((
7979
table_or_alias.clone(),
@@ -84,7 +84,9 @@ impl HoveredNode {
8484
}
8585
}
8686

87-
"identifier" if ctx.matches_ancestor_history(&["invocation", "object_reference"]) => {
87+
"any_identifier"
88+
if ctx.matches_ancestor_history(&["invocation", "object_reference"]) =>
89+
{
8890
if let Some(schema) = ctx.schema_or_alias_name.as_ref() {
8991
Some(HoveredNode::Function(NodeIdentification::SchemaAndName((
9092
schema.clone(),
@@ -97,7 +99,7 @@ impl HoveredNode {
9799
}
98100
}
99101

100-
"identifier"
102+
"any_identifier"
101103
if ctx.matches_one_of_ancestors(&[
102104
"alter_role",
103105
"policy_to_role",
@@ -110,7 +112,7 @@ impl HoveredNode {
110112
Some(HoveredNode::Role(NodeIdentification::Name(node_content)))
111113
}
112114

113-
"identifier"
115+
"any_identifier"
114116
if (
115117
// hover over custom type in `create table` or `returns`
116118
(ctx.matches_ancestor_history(&["type", "object_reference"])

crates/pgt_treesitter/src/context/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl<'a> TreesitterContext<'a> {
620620
/// Verifies whether the node_under_cursor has the passed in ancestors in the right order.
621621
/// Note that you need to pass in the ancestors in the order as they would appear in the tree:
622622
///
623-
/// If the tree shows `relation > object_reference > identifier` and the "identifier" is a leaf node,
623+
/// If the tree shows `relation > object_reference > identifier` and the "any_identifier" is a leaf node,
624624
/// you need to pass `&["relation", "object_reference"]`.
625625
pub fn matches_ancestor_history(&self, expected_ancestors: &[&'static str]) -> bool {
626626
self.node_under_cursor.as_ref().is_some_and(|node| {
@@ -642,7 +642,7 @@ impl<'a> TreesitterContext<'a> {
642642
/// Verifies whether the node_under_cursor has the passed in ancestors in the right order.
643643
/// Note that you need to pass in the ancestors in the order as they would appear in the tree:
644644
///
645-
/// If the tree shows `relation > object_reference > identifier` and the "identifier" is a leaf node,
645+
/// If the tree shows `relation > object_reference > identifier` and the "any_identifier" is a leaf node,
646646
/// you need to pass `&["relation", "object_reference"]`.
647647
pub fn matches_one_of_ancestors(&self, expected_ancestors: &[&'static str]) -> bool {
648648
self.node_under_cursor.as_ref().is_some_and(|node| {
@@ -1138,7 +1138,7 @@ mod tests {
11381138
identifier [40..43] '@id'
11391139
@ [40..41] '@'
11401140
1141-
You can see that the '@' is a child of the "identifier" but has a range smaller than its parent's.
1141+
You can see that the '@' is a child of the "any_identifier" but has a range smaller than its parent's.
11421142
This would crash our context parsing because, at position 42, we weren't at the leaf node but also couldn't
11431143
go to a child on that position.
11441144
*/

0 commit comments

Comments
 (0)