1use crate::schema::Schema;
2use async_trait::async_trait;
3use tower_lsp::lsp_types::{CompletionItem, Diagnostic, Hover, Location, Position};
4
5#[async_trait]
8pub trait Dialect: Send + Sync {
9 fn name(&self) -> &str;
11
12 async fn parse(&self, sql: &str, schema: Option<&Schema>) -> Vec<Diagnostic>;
14
15 async fn completion(
17 &self,
18 sql: &str,
19 position: Position,
20 schema: Option<&Schema>,
21 ) -> Vec<CompletionItem>;
22
23 async fn hover(&self, sql: &str, position: Position, schema: Option<&Schema>) -> Option<Hover>;
25
26 async fn goto_definition(
28 &self,
29 sql: &str,
30 position: Position,
31 schema: Option<&Schema>,
32 ) -> Option<Location>;
33
34 async fn references(
36 &self,
37 sql: &str,
38 position: Position,
39 schema: Option<&Schema>,
40 ) -> Vec<Location>;
41
42 async fn format(&self, sql: &str) -> String;
44
45 async fn validate(&self, sql: &str, schema: Option<&Schema>) -> Vec<Diagnostic>;
47}