Skip to content

Commit c7d8c68

Browse files
merged but not working
2 parents e87eb38 + a1f1818 commit c7d8c68

32 files changed

+653
-268
lines changed

.sqlx/query-b0163e58e9c646e3af524174081b74ab7e7938e9516ea21513265c49d304b6ea.json renamed to .sqlx/query-1cc58ddce2b52b5d6f6519cde339f258bce50342c2d5cce036dba4f9062cf811.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

Lines changed: 10 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ biome_js_syntax = "0.5.7"
2323
biome_rowan = "0.5.7"
2424
biome_string_case = "0.5.8"
2525
bpaf = { version = "0.9.15", features = ["derive"] }
26+
criterion = "0.5"
2627
crossbeam = "0.8.4"
2728
enumflags2 = "0.7.11"
2829
ignore = "0.4.23"

crates/pgt_completions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sqlx.workspace = true
3131
tokio = { version = "1.41.1", features = ["full"] }
3232

3333
[dev-dependencies]
34-
criterion = "0.5.1"
34+
criterion.workspace = true
3535
pgt_test_utils.workspace = true
3636

3737
[lib]

crates/pgt_hover/src/hovered_node.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ impl HoveredNode {
2525
pub(crate) fn get(ctx: &pgt_treesitter::context::TreesitterContext) -> Option<Self> {
2626
let node_content = ctx.get_node_under_cursor_content()?;
2727

28+
if looks_like_sql_param(node_content.as_str()) {
29+
return None;
30+
}
31+
2832
let under_cursor = ctx.node_under_cursor.as_ref()?;
2933

3034
match under_cursor.kind() {
@@ -147,3 +151,10 @@ impl HoveredNode {
147151
}
148152
}
149153
}
154+
155+
fn looks_like_sql_param(content: &str) -> bool {
156+
(content.starts_with("$") && !content.starts_with("$$"))
157+
|| (content.starts_with(":") && !content.starts_with("::"))
158+
|| (content.starts_with("@"))
159+
|| content.starts_with("?")
160+
}

crates/pgt_hover/tests/hover_integration_tests.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,44 @@ async fn hover_type_in_select_clause(test_db: PgPool) {
560560

561561
test_hover_at_cursor("hover_type_in_select_clause", query, Some(setup), &test_db).await;
562562
}
563+
564+
#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")]
565+
async fn no_hover_results_over_params(test_db: PgPool) {
566+
let setup = r#"
567+
create table users (
568+
id serial primary key,
569+
name text
570+
);
571+
"#;
572+
573+
test_db.execute(setup).await.unwrap();
574+
575+
{
576+
let query = format!(
577+
"select * from users where name = $n{}ame;",
578+
QueryWithCursorPosition::cursor_marker()
579+
);
580+
test_hover_at_cursor("dollar-param", query, None, &test_db).await;
581+
}
582+
{
583+
let query = format!(
584+
"select * from users where name = :n{}ame;",
585+
QueryWithCursorPosition::cursor_marker()
586+
);
587+
test_hover_at_cursor("colon-param", query, None, &test_db).await;
588+
}
589+
{
590+
let query = format!(
591+
"select * from users where name = @n{}ame;",
592+
QueryWithCursorPosition::cursor_marker()
593+
);
594+
test_hover_at_cursor("at-param", query, None, &test_db).await;
595+
}
596+
{
597+
let query = format!(
598+
"select * from users where name = ?n{}ame;",
599+
QueryWithCursorPosition::cursor_marker()
600+
);
601+
test_hover_at_cursor("questionmark-param", query, None, &test_db).await;
602+
}
603+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: crates/pgt_hover/tests/hover_integration_tests.rs
3+
expression: snapshot
4+
---
5+
# Input
6+
```sql
7+
select * from users where name = @name;
8+
↑ hovered here
9+
```
10+
11+
# Hover Results
12+
No hover information found.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: crates/pgt_hover/tests/hover_integration_tests.rs
3+
expression: snapshot
4+
---
5+
# Input
6+
```sql
7+
select * from users where name = :name;
8+
↑ hovered here
9+
```
10+
11+
# Hover Results
12+
No hover information found.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: crates/pgt_hover/tests/hover_integration_tests.rs
3+
expression: snapshot
4+
---
5+
# Input
6+
```sql
7+
select * from users where name = $name;
8+
↑ hovered here
9+
```
10+
11+
# Hover Results
12+
No hover information found.

0 commit comments

Comments
 (0)