Skip to content

Commit ca93d5b

Browse files
in progress…
1 parent 54ed210 commit ca93d5b

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
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(|n| {
8282
n.prev_sibling()
83-
.is_some_and(|p| (p.kind() == "all_fields") && n.kind() == "identifier")
83+
.is_some_and(|p| (p.kind() == "all_fields") && n.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 & 28 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,20 +99,9 @@ impl HoveredNode {
9799
}
98100
}
99101

100-
"identifier"
101-
if ctx.matches_one_of_ancestors(&[
102-
"alter_role",
103-
"policy_to_role",
104-
"role_specification",
105-
]) || ctx.before_cursor_matches_kind(&["keyword_revoke"]) =>
106-
{
107-
Some(HoveredNode::Role(NodeIdentification::Name(node_content)))
108-
}
109-
"grant_role" | "policy_role" => {
110-
Some(HoveredNode::Role(NodeIdentification::Name(node_content)))
111-
}
102+
"role_identifier" => Some(HoveredNode::Role(NodeIdentification::Name(node_content))),
112103

113-
"identifier"
104+
"any_identifier"
114105
if (
115106
// hover over custom type in `create table` or `returns`
116107
(ctx.matches_ancestor_history(&["type", "object_reference"])
@@ -145,17 +136,6 @@ impl HoveredNode {
145136
Some(HoveredNode::Column(NodeIdentification::Name(node_content)))
146137
}
147138

148-
"grant_table" => {
149-
if let Some(schema) = ctx.schema_or_alias_name.as_ref() {
150-
Some(HoveredNode::Table(NodeIdentification::SchemaAndName((
151-
schema.clone(),
152-
node_content,
153-
))))
154-
} else {
155-
Some(HoveredNode::Table(NodeIdentification::Name(node_content)))
156-
}
157-
}
158-
159139
_ => None,
160140
}
161141
}

0 commit comments

Comments
 (0)