use crate::ast::Statement;

pub fn statement_kind(stmt: &Statement) -> &'static str {
    match stmt {
        Statement::Dml(s) => match s {
            crate::ast::DmlStatement::Select(_) => "SELECT",
            crate::ast::DmlStatement::Insert(_) => "INSERT",
            crate::ast::DmlStatement::Update(_) => "UPDATE",
            crate::ast::DmlStatement::Delete(_) => "DELETE",
            crate::ast::DmlStatement::Merge(_) => "MERGE",
            crate::ast::DmlStatement::SelectAssign(_) => "SELECT_ASSIGN",
            crate::ast::DmlStatement::SetOp(_) => "QUERY",
            crate::ast::DmlStatement::BulkInsert(_) => "BULK_INSERT",
            crate::ast::DmlStatement::InsertBulk(_) => "INSERT_BULK",
        },
        Statement::Ddl(s) => match s {
            crate::ast::DdlStatement::CreateTable(_) => "CREATE_TABLE",
            crate::ast::DdlStatement::DropView(_) => "DROP_VIEW",
            crate::ast::DdlStatement::AlterTable(_) => "ALTER_TABLE",
            crate::ast::DdlStatement::DropTable(_) => "DROP_TABLE",
            crate::ast::DdlStatement::CreateSchema(_) => "CREATE_SCHEMA",
            crate::ast::DdlStatement::DropSchema(_) => "DROP_SCHEMA",
            crate::ast::DdlStatement::CreateIndex(_) => "CREATE_INDEX",
            crate::ast::DdlStatement::DropIndex(_) => "DROP_INDEX",
            crate::ast::DdlStatement::TruncateTable(_) => "TRUNCATE_TABLE",
            crate::ast::DdlStatement::CreateType(_) => "CREATE_TYPE",
            crate::ast::DdlStatement::DropType(_) => "DROP_TYPE",
            crate::ast::DdlStatement::DropProcedure(_) => "DROP_PROCEDURE",
            crate::ast::DdlStatement::DropFunction(_) => "DROP_FUNCTION",
            crate::ast::DdlStatement::DropTrigger(_) => "DROP_TRIGGER",
            crate::ast::DdlStatement::CreateSynonym(_) => "CREATE_SYNONYM",
            crate::ast::DdlStatement::DropSynonym(_) => "DROP_SYNONYM",
            crate::ast::DdlStatement::CreateSequence(_) => "CREATE_SEQUENCE",
            crate::ast::DdlStatement::DropSequence(_) => "DROP_SEQUENCE",
        },
        Statement::Procedural(s) => match s {
            crate::ast::ProceduralStatement::Set(_) => "SET",
            crate::ast::ProceduralStatement::Declare(_) => "DECLARE",
            crate::ast::ProceduralStatement::Return(_) => "RETURN",
            crate::ast::ProceduralStatement::Print(_) => "PRINT",
            crate::ast::ProceduralStatement::Raiserror(_) => "RAISERROR",
            crate::ast::ProceduralStatement::Throw(_) => "THROW",
            crate::ast::ProceduralStatement::BeginEnd(_) => "BEGIN_END",
            crate::ast::ProceduralStatement::If(_) => "IF",
            crate::ast::ProceduralStatement::While(_) => "WHILE",
            crate::ast::ProceduralStatement::TryCatch(_) => "TRY_CATCH",
            crate::ast::ProceduralStatement::ExecDynamic(_) => "EXEC_DYNAMIC",
            crate::ast::ProceduralStatement::ExecProcedure(_) => "EXEC_PROCEDURE",
            crate::ast::ProceduralStatement::SpExecuteSql(_) => "SP_EXECUTESQL",
            crate::ast::ProceduralStatement::DeclareCursor(_) => "DECLARE_CURSOR",
            crate::ast::ProceduralStatement::DeclareTableVar(_) => "DECLARE_TABLE_VARIABLE",
            crate::ast::ProceduralStatement::CreateProcedure(_) => "CREATE_PROCEDURE",
            crate::ast::ProceduralStatement::CreateFunction(_) => "CREATE_FUNCTION",
            crate::ast::ProceduralStatement::CreateView(_) => "CREATE_VIEW",
            crate::ast::ProceduralStatement::CreateTrigger(_) => "CREATE_TRIGGER",
            crate::ast::ProceduralStatement::Break => "BREAK",
            crate::ast::ProceduralStatement::Continue => "CONTINUE",
            crate::ast::ProceduralStatement::SetOption(_) => "SET_OPTION",
        },
        Statement::Cursor(s) => match s {
            crate::ast::CursorStatement::OpenCursor(_) => "OPEN_CURSOR",
            crate::ast::CursorStatement::FetchCursor(_) => "FETCH_CURSOR",
            crate::ast::CursorStatement::CloseCursor(_) => "CLOSE_CURSOR",
            crate::ast::CursorStatement::DeallocateCursor(_) => "DEALLOCATE_CURSOR",
        },
        Statement::Session(s) => match s {
            crate::ast::SessionStatement::SetOption(_) => "SET_OPTION",
            crate::ast::SessionStatement::SetIdentityInsert(_) => "SET_IDENTITY_INSERT",
            crate::ast::SessionStatement::SetTransactionIsolationLevel(_) => "SET_ISOLATION_LEVEL",
            crate::ast::SessionStatement::UseDatabase(_) => "USE_DATABASE",
            crate::ast::SessionStatement::SetContextInfo(_) => "SET_CONTEXT_INFO",
        },
        Statement::Transaction(_) => match stmt {
            Statement::Transaction(crate::ast::TransactionStatement::Begin(_)) => "BEGIN_TRAN",
            Statement::Transaction(crate::ast::TransactionStatement::Commit(_)) => "COMMIT",
            Statement::Transaction(crate::ast::TransactionStatement::Rollback(_)) => "ROLLBACK",
            Statement::Transaction(crate::ast::TransactionStatement::Save(_)) => "SAVE_TRAN",
            _ => unreachable!(),
        },
        Statement::WithCte(_) => "QUERY",
    }
}
