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
3 changes: 2 additions & 1 deletion crates/squawk_ide/src/code_actions/add_explicit_alias.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};
use squawk_syntax::quote::quote_column_alias;

Expand Down Expand Up @@ -35,7 +36,7 @@ pub(super) fn add_explicit_alias(

actions.push(CodeAction {
title: "Add explicit alias".to_owned(),
edits: vec![squawk_linter::Edit::insert(replacement, expr_end)],
edits: vec![Edit::insert(replacement, expr_end)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
3 changes: 2 additions & 1 deletion crates/squawk_ide/src/code_actions/add_schema.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use super::{ActionKind, CodeAction};
Expand Down Expand Up @@ -45,7 +46,7 @@ pub(super) fn add_schema(

actions.push(CodeAction {
title: "Add schema".to_owned(),
edits: vec![squawk_linter::Edit::insert(replacement, position)],
edits: vec![Edit::insert(replacement, position)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
3 changes: 2 additions & 1 deletion crates/squawk_ide/src/code_actions/quote_identifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -35,7 +36,7 @@ pub(super) fn quote_identifier(

actions.push(CodeAction {
title: "Quote identifier".to_owned(),
edits: vec![squawk_linter::Edit::replace(text_range, quoted)],
edits: vec![Edit::replace(text_range, quoted)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
5 changes: 2 additions & 3 deletions crates/squawk_ide/src/code_actions/remove_redundant_alias.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::{TextRange, TextSize};
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{column_name::ColumnName, db::File, offsets::token_from_offset, symbols::Name};
Expand Down Expand Up @@ -30,9 +31,7 @@ pub(super) fn remove_redundant_alias(

actions.push(CodeAction {
title: "Remove redundant alias".to_owned(),
edits: vec![squawk_linter::Edit::delete(TextRange::new(
expr_end, alias_end,
))],
edits: vec![Edit::delete(TextRange::new(expr_end, alias_end))],
kind: ActionKind::QuickFix,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::{SyntaxKind, ast::AstNode};

use crate::db::{File, parse};
Expand All @@ -21,10 +22,7 @@ pub(super) fn rewrite_as_dollar_quoted_string(
let replacement = string_to_dollar_quoted(string.text())?;
actions.push(CodeAction {
title: "Rewrite as dollar-quoted string".to_owned(),
edits: vec![squawk_linter::Edit::replace(
string.text_range(),
replacement,
)],
edits: vec![Edit::replace(string.text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::{SyntaxKind, ast::AstNode};

use crate::db::{File, parse};
Expand All @@ -21,10 +22,7 @@ pub(super) fn rewrite_as_regular_string(
let replacement = dollar_quoted_to_string(dollar_string.text())?;
actions.push(CodeAction {
title: "Rewrite as regular string".to_owned(),
edits: vec![squawk_linter::Edit::replace(
dollar_string.text_range(),
replacement,
)],
edits: vec![Edit::replace(dollar_string.text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::AstNode;

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -45,7 +46,7 @@ pub(super) fn rewrite_between_as_binary_expression(

actions.push(CodeAction {
title: "Rewrite as binary expression".to_owned(),
edits: vec![squawk_linter::Edit::replace(
edits: vec![Edit::replace(
between_expr.syntax().text_range(),
replacement,
)],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -29,10 +30,7 @@ pub(super) fn rewrite_cast_to_double_colon(

actions.push(CodeAction {
title: "Rewrite as cast operator `::`".to_owned(),
edits: vec![squawk_linter::Edit::replace(
cast_expr.syntax().text_range(),
replacement,
)],
edits: vec![Edit::replace(cast_expr.syntax().text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -29,10 +30,7 @@ pub(super) fn rewrite_double_colon_to_cast(

actions.push(CodeAction {
title: "Rewrite as cast function `cast()`".to_owned(),
edits: vec![squawk_linter::Edit::replace(
cast_expr.syntax().text_range(),
replacement,
)],
edits: vec![Edit::replace(cast_expr.syntax().text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
3 changes: 2 additions & 1 deletion crates/squawk_ide/src/code_actions/rewrite_from.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand All @@ -23,7 +24,7 @@ pub(super) fn rewrite_from(

actions.push(CodeAction {
title: "Insert leading `select *`".to_owned(),
edits: vec![squawk_linter::Edit::insert(
edits: vec![Edit::insert(
"select * ".to_owned(),
select.syntax().text_range().start(),
)],
Expand Down
5 changes: 3 additions & 2 deletions crates/squawk_ide/src/code_actions/rewrite_leading_from.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::{TextRange, TextSize};
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::{
SyntaxKind,
ast::{self, AstNode},
Expand Down Expand Up @@ -38,8 +39,8 @@ pub(super) fn rewrite_leading_from(
actions.push(CodeAction {
title: "Swap `from` and `select` clauses".to_owned(),
edits: vec![
squawk_linter::Edit::delete(select_with_ws),
squawk_linter::Edit::insert(
Edit::delete(select_with_ws),
Edit::insert(
format!("{} ", select_text),
from_clause.syntax().text_range().start(),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand All @@ -23,10 +24,7 @@ pub(super) fn rewrite_not_equals_operator(

actions.push(CodeAction {
title: title.to_owned(),
edits: vec![squawk_linter::Edit::replace(
op_token.text_range(),
replacement.to_owned(),
)],
edits: vec![Edit::replace(op_token.text_range(), replacement.to_owned())],
kind: ActionKind::RefactorRewrite,
});

Expand Down
6 changes: 2 additions & 4 deletions crates/squawk_ide/src/code_actions/rewrite_select_as_table.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -34,10 +35,7 @@ pub(super) fn rewrite_select_as_table(

actions.push(CodeAction {
title: "Rewrite as `table`".to_owned(),
edits: vec![squawk_linter::Edit::replace(
select.syntax().text_range(),
replacement,
)],
edits: vec![Edit::replace(select.syntax().text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::{TextRange, TextSize};
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{
Expand Down Expand Up @@ -61,7 +62,7 @@ pub(super) fn rewrite_select_as_values(

actions.push(CodeAction {
title: "Rewrite as `values`".to_owned(),
edits: vec![squawk_linter::Edit::replace(select_range, values_stmt)],
edits: vec![Edit::replace(select_range, values_stmt)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
6 changes: 2 additions & 4 deletions crates/squawk_ide/src/code_actions/rewrite_table_as_select.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand All @@ -21,10 +22,7 @@ pub(super) fn rewrite_table_as_select(

actions.push(CodeAction {
title: "Rewrite as `select`".to_owned(),
edits: vec![squawk_linter::Edit::replace(
table.syntax().text_range(),
replacement,
)],
edits: vec![Edit::replace(table.syntax().text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
6 changes: 2 additions & 4 deletions crates/squawk_ide/src/code_actions/rewrite_timestamp_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rowan::TextSize;
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -34,10 +35,7 @@ pub(super) fn rewrite_timestamp_type(

actions.push(CodeAction {
title: format!("Rewrite as `{replacement}`"),
edits: vec![squawk_linter::Edit::replace(
time_type.syntax().text_range(),
replacement,
)],
edits: vec![Edit::replace(time_type.syntax().text_range(), replacement)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use itertools::Itertools;
use rowan::{TextRange, TextSize};
use salsa::Database as Db;
use squawk_linter::Edit;
use squawk_syntax::ast::{self, AstNode};

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -51,7 +52,7 @@ pub(super) fn rewrite_values_as_select(

actions.push(CodeAction {
title: "Rewrite as `select`".to_owned(),
edits: vec![squawk_linter::Edit::replace(values_range, select_stmt)],
edits: vec![Edit::replace(values_range, select_stmt)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
6 changes: 2 additions & 4 deletions crates/squawk_ide/src/code_actions/unquote_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rowan::TextSize;
use salsa::Database as Db;
use squawk_syntax::ast::{self, AstNode};

use squawk_linter::Edit;
use squawk_syntax::quote::unquote_ident;

use crate::{db::File, offsets::token_from_offset};
Expand Down Expand Up @@ -29,10 +30,7 @@ pub(super) fn unquote_identifier(

actions.push(CodeAction {
title: "Unquote identifier".to_owned(),
edits: vec![squawk_linter::Edit::replace(
name_node.text_range(),
unquoted,
)],
edits: vec![Edit::replace(name_node.text_range(), unquoted)],
kind: ActionKind::RefactorRewrite,
});

Expand Down
Loading