Skip to content

chore: ensure auto fixes are applied #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 19, 2025
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
13 changes: 11 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,21 @@ jobs:
uses: biomejs/setup-biome@v2
with:
version: latest

- name: Run Lints
run: |
cargo sqlx prepare --check --workspace
cargo clippy
cargo clippy --fix
cargo run -p rules_check
biome lint
biome lint --write

- name: Check for changes
run: |
if [[ $(git status --porcelain) ]]; then
git status
git diff
exit 1
fi

test:
name: Test
Expand Down
6 changes: 3 additions & 3 deletions crates/pgt_completions/benches/sanitization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn sql_and_pos(sql: &str) -> (String, usize) {
fn get_tree(sql: &str) -> tree_sitter::Tree {
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_sql::language()).unwrap();
parser.parse(sql.to_string(), None).unwrap()
parser.parse(sql, None).unwrap()
}

fn to_params<'a>(
Expand All @@ -25,9 +25,9 @@ fn to_params<'a>(
let pos: u32 = pos.try_into().unwrap();
CompletionParams {
position: TextSize::new(pos),
schema: &cache,
schema: cache,
text,
tree: tree,
tree,
}
}

Expand Down
3 changes: 1 addition & 2 deletions crates/pgt_completions/src/providers/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ mod tests {
let has_column_in_first_four = |col: &'static str| {
first_four
.iter()
.find(|compl_item| compl_item.label.as_str() == col)
.is_some()
.any(|compl_item| compl_item.label.as_str() == col)
};

assert!(
Expand Down
2 changes: 1 addition & 1 deletion crates/pgt_completions/src/providers/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn complete_schemas(ctx: &CompletionContext, builder: &mut CompletionBuilder
let available_schemas = &ctx.schema_cache.schemas;

for schema in available_schemas {
let relevance = CompletionRelevanceData::Schema(&schema);
let relevance = CompletionRelevanceData::Schema(schema);

let item = CompletionItem {
label: schema.name.clone(),
Expand Down
8 changes: 4 additions & 4 deletions crates/pgt_completions/src/sanitization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) struct SanitizedCompletionParams<'a> {
}

pub fn benchmark_sanitization(params: CompletionParams) -> String {
let params: SanitizedCompletionParams = params.try_into().unwrap();
let params: SanitizedCompletionParams = params.into();
params.text
}

Expand Down Expand Up @@ -212,7 +212,7 @@ mod tests {
.set_language(tree_sitter_sql::language())
.expect("Error loading sql language");

let mut tree = parser.parse(input.to_string(), None).unwrap();
let mut tree = parser.parse(input, None).unwrap();

// select | from users; <-- just right, one space after select token, one space before from
assert!(cursor_inbetween_nodes(&mut tree, TextSize::new(7)));
Expand All @@ -236,7 +236,7 @@ mod tests {
.set_language(tree_sitter_sql::language())
.expect("Error loading sql language");

let mut tree = parser.parse(input.to_string(), None).unwrap();
let mut tree = parser.parse(input, None).unwrap();

// select * from| <-- still on previous token
assert!(!cursor_prepared_to_write_token_after_last_node(
Expand Down Expand Up @@ -274,7 +274,7 @@ mod tests {
.set_language(tree_sitter_sql::language())
.expect("Error loading sql language");

let mut tree = parser.parse(input.to_string(), None).unwrap();
let mut tree = parser.parse(input, None).unwrap();

// select * from ;| <-- it's after the statement
assert!(!cursor_before_semicolon(&mut tree, TextSize::new(19)));
Expand Down
28 changes: 8 additions & 20 deletions crates/pgt_workspace/src/features/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ impl IntoIterator for CompletionsResult {
}
}

pub(crate) fn get_statement_for_completions<'a>(
doc: &'a ParsedDocument,
pub(crate) fn get_statement_for_completions(
doc: &ParsedDocument,
position: TextSize,
) -> Option<(StatementId, TextRange, String, Arc<tree_sitter::Tree>)> {
let count = doc.count();
Expand Down Expand Up @@ -89,7 +89,7 @@ mod tests {
(
ParsedDocument::new(
PgTPath::new("test.sql"),
sql.replace(CURSOR_POSITION, "").into(),
sql.replace(CURSOR_POSITION, ""),
5,
),
TextSize::new(pos),
Expand Down Expand Up @@ -119,14 +119,11 @@ mod tests {

#[test]
fn does_not_break_when_no_statements_exist() {
let sql = format!("{}", CURSOR_POSITION);
let sql = CURSOR_POSITION.to_string();

let (doc, position) = get_doc_and_pos(sql.as_str());

assert!(matches!(
get_statement_for_completions(&doc, position),
None
));
assert!(get_statement_for_completions(&doc, position).is_none());
}

#[test]
Expand All @@ -138,10 +135,7 @@ mod tests {
// make sure these are parsed as two
assert_eq!(doc.count(), 2);

assert!(matches!(
get_statement_for_completions(&doc, position),
None
));
assert!(get_statement_for_completions(&doc, position).is_none());
}

#[test]
Expand Down Expand Up @@ -174,10 +168,7 @@ mod tests {

let (doc, position) = get_doc_and_pos(sql.as_str());

assert!(matches!(
get_statement_for_completions(&doc, position),
None
));
assert!(get_statement_for_completions(&doc, position).is_none());
}

#[test]
Expand All @@ -186,9 +177,6 @@ mod tests {

let (doc, position) = get_doc_and_pos(sql.as_str());

assert!(matches!(
get_statement_for_completions(&doc, position),
None
));
assert!(get_statement_for_completions(&doc, position).is_none());
}
}
Loading