1use std::sync::Arc;
2
3use sqruff_lib_core::errors::SQLFluffUserError;
4use sqruff_lib_core::templaters::TemplatedFile;
5
6use crate::Formatter;
7use crate::core::config::FluffConfig;
8use crate::templaters::placeholder::PlaceholderTemplater;
9use crate::templaters::raw::RawTemplater;
10
11#[cfg(feature = "python")]
12use crate::templaters::jinja::JinjaTemplater;
13#[cfg(feature = "python")]
14use crate::templaters::python::PythonTemplater;
15
16#[cfg(feature = "python")]
17pub mod dbt;
18#[cfg(feature = "python")]
19pub mod jinja;
20pub mod placeholder;
21#[cfg(feature = "python")]
22pub mod python;
23#[cfg(feature = "python")]
24pub mod python_shared;
25pub mod raw;
26pub mod types;
27
28pub use types::{PlaceholderStyle, TemplaterKind};
29
30pub static RAW_TEMPLATER: RawTemplater = RawTemplater;
31pub static PLACEHOLDER_TEMPLATER: PlaceholderTemplater = PlaceholderTemplater;
32#[cfg(feature = "python")]
33pub static PYTHON_TEMPLATER: PythonTemplater = PythonTemplater;
34#[cfg(feature = "python")]
35pub static JINJA_TEMPLATER: JinjaTemplater = JinjaTemplater;
36#[cfg(feature = "python")]
37pub static DBT_TEMPLATER: dbt::DBTTemplater = dbt::DBTTemplater;
38
39#[cfg(feature = "python")]
41pub static TEMPLATERS: [&'static dyn Templater; 5] = [
42 &RAW_TEMPLATER,
43 &PLACEHOLDER_TEMPLATER,
44 &PYTHON_TEMPLATER,
45 &JINJA_TEMPLATER,
46 &DBT_TEMPLATER,
47];
48
49#[cfg(not(feature = "python"))]
50pub static TEMPLATERS: [&'static dyn Templater; 2] = [&RAW_TEMPLATER, &PLACEHOLDER_TEMPLATER];
51
52#[derive(Debug, Clone, Copy, PartialEq, Eq)]
54pub enum ProcessingMode {
55 Parallel,
58 Sequential,
61 Batch,
65}
66
67pub trait Templater: Send + Sync {
68 fn name(&self) -> &'static str;
70
71 fn description(&self) -> &'static str;
73
74 fn processing_mode(&self) -> ProcessingMode;
76
77 fn process(
86 &self,
87 files: &[(&str, &str)],
88 config: &FluffConfig,
89 formatter: &Option<Arc<dyn Formatter>>,
90 ) -> Vec<Result<TemplatedFile, SQLFluffUserError>>;
91}