Skip to content
Merged
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: 12 additions & 0 deletions crates/squawk_ide/src/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@ pub(crate) fn classify_name_ref(name_ref: &ast::NameRef) -> Option<NameRefClass>
|| ast::GeneratedConstraint::can_cast(ancestor.kind())
|| ast::NotNullConstraint::can_cast(ancestor.kind())
{
if in_function_name {
return Some(NameRefClass::FunctionCall);
}
return Some(NameRefClass::ConstraintColumn);
}
if in_column_list
Expand All @@ -513,6 +516,9 @@ pub(crate) fn classify_name_ref(name_ref: &ast::NameRef) -> Option<NameRefClass>
|| in_constraint_where_clause)
&& ast::ExcludeConstraint::can_cast(ancestor.kind())
{
if in_function_name {
return Some(NameRefClass::FunctionCall);
}
return Some(NameRefClass::ConstraintColumn);
}
if ast::LikeClause::can_cast(ancestor.kind()) {
Expand Down Expand Up @@ -541,6 +547,9 @@ pub(crate) fn classify_name_ref(name_ref: &ast::NameRef) -> Option<NameRefClass>
}
if ast::CreateIndex::can_cast(ancestor.kind()) {
if in_partition_item {
if in_function_name {
return Some(NameRefClass::FunctionCall);
}
return Some(NameRefClass::CreateIndexColumn);
}
return Some(NameRefClass::Table);
Expand All @@ -562,6 +571,9 @@ pub(crate) fn classify_name_ref(name_ref: &ast::NameRef) -> Option<NameRefClass>
return Some(NameRefClass::FunctionCall);
}
if in_partition_item && ast::CreateTableLike::can_cast(ancestor.kind()) {
if in_function_name {
return Some(NameRefClass::FunctionCall);
}
return Some(NameRefClass::ConstraintColumn);
}
if is_special_fn(ancestor.kind()) {
Expand Down
79 changes: 79 additions & 0 deletions crates/squawk_ide/src/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,85 @@ create table t (
");
}

#[test]
fn goto_generated_column_function_call() {
assert_snapshot!(goto("
create function pg_catalog.lower(text) returns text
language internal;

create table articles (
id serial primary key,
title text not null,
body text not null,
title_lower text generated always as (
lower$0(title)
) stored
);
"), @r"
╭▸
2 │ create function pg_catalog.lower(text) returns text
│ ───── 2. destination
10 │ lower(title)
╰╴ ─ 1. source
");
}

#[test]
fn goto_index_expr_function_call() {
assert_snapshot!(goto("
create function lower(text) returns text language internal;
create table articles (
id serial primary key,
title text not null
);
create index on articles (lower$0(title));
"), @r"
╭▸
2 │ create function lower(text) returns text language internal;
│ ───── 2. destination
7 │ create index on articles (lower(title));
╰╴ ─ 1. source
");
}

#[test]
fn goto_exclude_constraint_expr_function_call() {
assert_snapshot!(goto("
create function lower(text) returns text language internal;
create table articles (
title text not null,
exclude using btree (lower$0(title) with =)
);
"), @r"
╭▸
2 │ create function lower(text) returns text language internal;
│ ───── 2. destination
5 │ exclude using btree (lower(title) with =)
╰╴ ─ 1. source
");
}

#[test]
fn goto_partition_by_expr_function_call() {
assert_snapshot!(goto("
create function lower(text) returns text language internal;
create table articles (
id serial primary key,
title text not null
) partition by range (lower$0(title));
"), @r"
╭▸
2 │ create function lower(text) returns text language internal;
│ ───── 2. destination
6 │ ) partition by range (lower(title));
╰╴ ─ 1. source
");
}

#[test]
fn goto_table_check_constraint_column() {
assert_snapshot!(goto("
Expand Down
Loading