Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/pgt_completions/src/relevance/filtering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ impl CompletionFilter<'_> {
// No autocompletions if there are two identifiers without a separator.
if ctx.node_under_cursor.as_ref().is_some_and(|node| {
node.prev_sibling().is_some_and(|p| {
(p.kind() == "identifier" || p.kind() == "object_reference")
&& node.kind() == "identifier"
(p.kind() == "any_identifier" || p.kind() == "object_reference")
&& node.kind() == "any_identifier"
})
}) {
return None;
}

// no completions if we're right after an asterisk:
// `select * {}`
if ctx.node_under_cursor.as_ref().is_some_and(|node| {
node.prev_sibling()
.is_some_and(|p| (p.kind() == "all_fields") && node.kind() == "identifier")
if ctx.node_under_cursor.as_ref().is_some_and(|n| {
n.prev_sibling()
.is_some_and(|p| (p.kind() == "all_fields") && n.kind() == "any_identifier")
}) {
return None;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ impl CompletionFilter<'_> {
WrappingClause::RevokeStatement | WrappingClause::GrantStatement => {
ctx.matches_ancestor_history(&["role_specification"])
|| ctx.node_under_cursor.as_ref().is_some_and(|k| {
k.kind() == "identifier"
k.kind() == "any_identifier"
&& ctx.before_cursor_matches_kind(&[
"keyword_grant",
"keyword_revoke",
Expand Down
36 changes: 8 additions & 28 deletions crates/pgt_hover/src/hovered_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl HoveredNode {
let under_cursor = ctx.node_under_cursor.as_ref()?;

match under_cursor.kind() {
"identifier"
"any_identifier"
if ctx.matches_ancestor_history(&["relation", "object_reference"])
|| ctx
.matches_ancestor_history(&["grantable_on_table", "object_reference"]) =>
Expand All @@ -52,7 +52,7 @@ impl HoveredNode {
}
}

"identifier"
"any_identifier"
if ctx.matches_ancestor_history(&["object_reference"])
&& ctx.wrapping_clause_type.as_ref().is_some_and(|clause| {
matches!(
Expand All @@ -73,7 +73,7 @@ impl HoveredNode {
}
}

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

"identifier" if ctx.matches_ancestor_history(&["invocation", "object_reference"]) => {
"any_identifier"
if ctx.matches_ancestor_history(&["invocation", "object_reference"]) =>
{
if let Some(schema) = ctx.schema_or_alias_name.as_ref() {
Some(HoveredNode::Function(NodeIdentification::SchemaAndName((
schema.clone(),
Expand All @@ -97,20 +99,9 @@ impl HoveredNode {
}
}

"identifier"
if ctx.matches_one_of_ancestors(&[
"alter_role",
"policy_to_role",
"role_specification",
]) || ctx.before_cursor_matches_kind(&["keyword_revoke"]) =>
{
Some(HoveredNode::Role(NodeIdentification::Name(node_content)))
}
"grant_role" | "policy_role" => {
Some(HoveredNode::Role(NodeIdentification::Name(node_content)))
}
"role_identifier" => Some(HoveredNode::Role(NodeIdentification::Name(node_content))),

"identifier"
"any_identifier"
if (
// hover over custom type in `create table` or `returns`
(ctx.matches_ancestor_history(&["type", "object_reference"])
Expand Down Expand Up @@ -145,17 +136,6 @@ impl HoveredNode {
Some(HoveredNode::Column(NodeIdentification::Name(node_content)))
}

"grant_table" => {
if let Some(schema) = ctx.schema_or_alias_name.as_ref() {
Some(HoveredNode::Table(NodeIdentification::SchemaAndName((
schema.clone(),
node_content,
))))
} else {
Some(HoveredNode::Table(NodeIdentification::Name(node_content)))
}
}

_ => None,
}
}
Expand Down
Loading
Loading