Skip to content

Commit 10bd0db

Browse files
authored
syntax: rename top level Item enum to Stmt (#483)
working on ungrammar and this is more descriptive, rust-analyzer uses Item, but all top level things in postgres are statements
1 parent af45c68 commit 10bd0db

27 files changed

+81
-81
lines changed

crates/squawk_linter/src/rules/adding_field_with_default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn adding_field_with_default(ctx: &mut Linter, parse: &Parse<SourceFi
5858
let file = parse.tree();
5959
// TODO: use match_ast! like in #api_walkthrough
6060
for item in file.items() {
61-
if let ast::Item::AlterTable(alter_table) = item {
61+
if let ast::Stmt::AlterTable(alter_table) = item {
6262
for action in alter_table.actions() {
6363
if let ast::AlterTableAction::AddColumn(add_column) = action {
6464
for constraint in add_column.constraints() {

crates/squawk_linter/src/rules/adding_foreign_key_constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn adding_foreign_key_constraint(ctx: &mut Linter, parse: &Parse<Sour
1111
let file = parse.tree();
1212
// TODO: use match_ast! like in #api_walkthrough
1313
for item in file.items() {
14-
if let ast::Item::AlterTable(alter_table) = item {
14+
if let ast::Stmt::AlterTable(alter_table) = item {
1515
for action in alter_table.actions() {
1616
match action {
1717
ast::AlterTableAction::AddConstraint(add_constraint) => {

crates/squawk_linter/src/rules/adding_not_null_field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn adding_not_null_field(ctx: &mut Linter, parse: &Parse<SourceFile>)
1111
}
1212
let file = parse.tree();
1313
for item in file.items() {
14-
if let ast::Item::AlterTable(alter_table) = item {
14+
if let ast::Stmt::AlterTable(alter_table) = item {
1515
for action in alter_table.actions() {
1616
if let ast::AlterTableAction::AlterColumn(alter_column) = action {
1717
let Some(option) = alter_column.option() else {

crates/squawk_linter/src/rules/adding_primary_key_constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) fn adding_primary_key_constraint(ctx: &mut Linter, parse: &Parse<Sour
1010
let help = "Add the `PRIMARY KEY` constraint `USING` an index.";
1111
let file = parse.tree();
1212
for item in file.items() {
13-
if let ast::Item::AlterTable(alter_table) = item {
13+
if let ast::Stmt::AlterTable(alter_table) = item {
1414
for action in alter_table.actions() {
1515
match action {
1616
ast::AlterTableAction::AddConstraint(add_constraint) => {

crates/squawk_linter/src/rules/adding_required_field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{Linter, Rule, Violation};
88
pub(crate) fn adding_required_field(ctx: &mut Linter, parse: &Parse<SourceFile>) {
99
let file = parse.tree();
1010
for item in file.items() {
11-
if let ast::Item::AlterTable(alter_table) = item {
11+
if let ast::Stmt::AlterTable(alter_table) = item {
1212
for action in alter_table.actions() {
1313
if let ast::AlterTableAction::AddColumn(add_column) = action {
1414
if has_generated_constrait(add_column.constraints()) {

crates/squawk_linter/src/rules/ban_alter_domain_with_add_constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{Linter, Rule, Violation};
88
pub(crate) fn ban_alter_domain_with_add_constraint(ctx: &mut Linter, parse: &Parse<SourceFile>) {
99
let file = parse.tree();
1010
for item in file.items() {
11-
if let ast::Item::AlterDomain(alter_domain) = item {
11+
if let ast::Stmt::AlterDomain(alter_domain) = item {
1212
let actions = alter_domain.actions();
1313
for action in actions {
1414
if let ast::AlterDomainAction::AddConstraint(add_constraint) = action {

crates/squawk_linter/src/rules/ban_concurrent_index_creation_in_transaction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ pub(crate) fn ban_concurrent_index_creation_in_transaction(
1616
for item in file.items() {
1717
stmt_count += 1;
1818
match item {
19-
ast::Item::Begin(_) => {
19+
ast::Stmt::Begin(_) => {
2020
in_transaction = true;
2121
}
22-
ast::Item::Commit(_) => {
22+
ast::Stmt::Commit(_) => {
2323
in_transaction = false;
2424
}
25-
ast::Item::CreateIndex(create_index) => {
25+
ast::Stmt::CreateIndex(create_index) => {
2626
if in_transaction {
2727
if let Some(concurrently) = create_index.concurrently_token() {
2828
errors.push(Violation::new(

crates/squawk_linter/src/rules/ban_create_domain_with_constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{Linter, Rule, Violation};
99
pub(crate) fn ban_create_domain_with_constraint(ctx: &mut Linter, parse: &Parse<SourceFile>) {
1010
let file = parse.tree();
1111
for item in file.items() {
12-
if let ast::Item::CreateDomain(domain) = item {
12+
if let ast::Stmt::CreateDomain(domain) = item {
1313
let range =
1414
domain
1515
.constraints()

crates/squawk_linter/src/rules/ban_drop_column.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{Linter, Rule, Violation};
88
pub(crate) fn ban_drop_column(ctx: &mut Linter, parse: &Parse<SourceFile>) {
99
let file = parse.tree();
1010
for item in file.items() {
11-
if let ast::Item::AlterTable(alter_table) = item {
11+
if let ast::Stmt::AlterTable(alter_table) = item {
1212
for action in alter_table.actions() {
1313
if let ast::AlterTableAction::DropColumn(drop_column) = action {
1414
ctx.report(Violation::new(

crates/squawk_linter/src/rules/ban_drop_database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{Linter, Rule, Violation};
99
pub(crate) fn ban_drop_database(ctx: &mut Linter, parse: &Parse<SourceFile>) {
1010
let file = parse.tree();
1111
for item in file.items() {
12-
if let ast::Item::DropDatabase(drop_database) = item {
12+
if let ast::Stmt::DropDatabase(drop_database) = item {
1313
ctx.report(Violation::new(
1414
Rule::BanDropDatabase,
1515
"Dropping a database may break existing clients.".into(),

0 commit comments

Comments
 (0)