Skip to content

Commit f8ca407

Browse files
readied
1 parent 799f52d commit f8ca407

File tree

3 files changed

+22
-39
lines changed

3 files changed

+22
-39
lines changed

crates/pgls_completions/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ tokio = { version = "1.41.1", features = ["full"] }
3232

3333
[dev-dependencies]
3434
criterion.workspace = true
35+
indoc = "2.0.7"
36+
insta.workspace = true
3537
pgls_test_utils.workspace = true
36-
insta.workspace = true
37-
regex = "1.12.2"
38-
indoc = "2.0.7"
38+
regex = "1.12.2"
3939

4040

4141
[lib]

crates/pgls_completions/src/providers/columns.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,12 @@ fn get_completion_text(ctx: &TreesitterContext, col: &Column) -> CompletionText
5252
mod tests {
5353
use indoc::indoc;
5454

55-
use sqlx::{Executor, PgPool};
55+
use sqlx::PgPool;
5656

57-
use crate::{
58-
CompletionItemKind, complete,
59-
test_helper::{
60-
CompletionAssertion, TestCompletionsCase, TestCompletionsSuite,
61-
assert_complete_results, get_test_deps, get_test_params,
62-
},
63-
};
57+
use crate::test_helper::{TestCompletionsCase, TestCompletionsSuite};
6458

6559
use pgls_test_utils::QueryWithCursorPosition;
6660

67-
struct TestCase {
68-
query: String,
69-
}
70-
71-
impl TestCase {
72-
fn get_input_query(&self) -> QueryWithCursorPosition {
73-
let strs: Vec<&str> = self.query.split_whitespace().collect();
74-
strs.join(" ").as_str().into()
75-
}
76-
}
77-
7861
#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")]
7962
async fn handles_nested_queries(pool: PgPool) {
8063
let setup = r#"

crates/pgls_completions/src/test_helper.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl TestCompletionsCase {
303303
let part_without_parens = if starts_with_paren || ends_with_paren {
304304
// we only want to sanitize when the token either starts or ends; that helps
305305
// catch end tokens like `('something');`
306-
part_without_comments.replace('(', "").replace(')', "")
306+
part_without_comments.replace(['(', ')'], "")
307307
} else {
308308
part_without_comments.to_string()
309309
};
@@ -313,7 +313,7 @@ impl TestCompletionsCase {
313313

314314
let part_without_quotes = part_without_parens.replace('"', "");
315315

316-
if pre_sql.len() > 0 {
316+
if !pre_sql.is_empty() {
317317
let query = format!(
318318
"{}{}{}{}{}",
319319
pre_sql,
@@ -326,7 +326,7 @@ impl TestCompletionsCase {
326326
self.completions_snapshot(
327327
query.into(),
328328
&mut snapshot_result,
329-
&schema_cache,
329+
schema_cache,
330330
parser,
331331
comment,
332332
)
@@ -346,7 +346,7 @@ impl TestCompletionsCase {
346346
self.completions_snapshot(
347347
query1.into(),
348348
&mut snapshot_result,
349-
&schema_cache,
349+
schema_cache,
350350
parser,
351351
comment,
352352
)
@@ -363,13 +363,13 @@ impl TestCompletionsCase {
363363
self.completions_snapshot(
364364
query2.into(),
365365
&mut snapshot_result,
366-
&schema_cache,
366+
schema_cache,
367367
parser,
368368
comment,
369369
)
370370
.await;
371371

372-
pre_sql.push_str("(");
372+
pre_sql.push('(');
373373
should_close_with_paren = true;
374374
}
375375

@@ -387,7 +387,7 @@ impl TestCompletionsCase {
387387
self.completions_snapshot(
388388
query1.into(),
389389
&mut snapshot_result,
390-
&schema_cache,
390+
schema_cache,
391391
parser,
392392
comment,
393393
)
@@ -405,7 +405,7 @@ impl TestCompletionsCase {
405405
self.completions_snapshot(
406406
query2.into(),
407407
&mut snapshot_result,
408-
&schema_cache,
408+
schema_cache,
409409
parser,
410410
comment,
411411
)
@@ -432,7 +432,7 @@ impl TestCompletionsCase {
432432
self.completions_snapshot(
433433
query.into(),
434434
&mut snapshot_result,
435-
&schema_cache,
435+
schema_cache,
436436
parser,
437437
if comment_indicator
438438
.is_some_and(|txt| og_part.starts_with(txt.as_str()))
@@ -461,7 +461,7 @@ impl TestCompletionsCase {
461461
self.completions_snapshot(
462462
query.into(),
463463
&mut snapshot_result,
464-
&schema_cache,
464+
schema_cache,
465465
parser,
466466
None,
467467
)
@@ -471,27 +471,27 @@ impl TestCompletionsCase {
471471
pre_sql.push_str(&part_without_parens);
472472

473473
if dot_idx < dot_count {
474-
pre_sql.push_str(".");
474+
pre_sql.push('.');
475475
}
476476

477477
if ends_with_paren {
478478
should_close_with_paren = false;
479-
pre_sql.push_str(")");
479+
pre_sql.push(')');
480480
}
481481
}
482482

483483
if whitespace_idx < whitespace_count {
484484
// note: we're sanitizing the white_space of typed SQL to simple spaces.
485-
pre_sql.push_str(" ");
485+
pre_sql.push(' ');
486486
}
487487
}
488488

489-
pre_sql.push_str("\n");
489+
pre_sql.push('\n');
490490
}
491491

492492
ChunkToType::WithoutCompletions(sql) => {
493493
pre_sql.push_str(sql.as_str());
494-
pre_sql.push_str("\n");
494+
pre_sql.push('\n');
495495
}
496496
}
497497
}
@@ -526,12 +526,12 @@ impl TestCompletionsCase {
526526
let diff = pos - sql.len();
527527

528528
sql.push_str(&" ".repeat(diff));
529-
sql.push_str("|");
529+
sql.push('|');
530530
}
531531
writeln!(writer, "{sql}").unwrap();
532532

533533
if let Some(c) = comment {
534-
writeln!(writer, "**{}**", c).unwrap();
534+
writeln!(writer, "**{c}**").unwrap();
535535
}
536536

537537
if !items.is_empty() {

0 commit comments

Comments
 (0)