1use std::sync::Arc;
2
3use sqruff_lib_core::errors::SQLFluffUserError;
4use sqruff_lib_core::templaters::base::TemplatedFile;
5
6use crate::cli::formatters::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;
26
27pub static RAW_TEMPLATER: RawTemplater = RawTemplater;
28pub static PLACEHOLDER_TEMPLATER: PlaceholderTemplater = PlaceholderTemplater;
29#[cfg(feature = "python")]
30pub static PYTHON_TEMPLATER: PythonTemplater = PythonTemplater;
31#[cfg(feature = "python")]
32pub static JINJA_TEMPLATER: JinjaTemplater = JinjaTemplater;
33#[cfg(feature = "python")]
34pub static DBT_TEMPLATER: dbt::DBTTemplater = dbt::DBTTemplater;
35
36#[cfg(feature = "python")]
38pub static TEMPLATERS: [&'static dyn Templater; 5] = [
39 &RAW_TEMPLATER,
40 &PLACEHOLDER_TEMPLATER,
41 &PYTHON_TEMPLATER,
42 &JINJA_TEMPLATER,
43 &DBT_TEMPLATER,
44];
45
46#[cfg(not(feature = "python"))]
47pub static TEMPLATERS: [&'static dyn Templater; 2] = [&RAW_TEMPLATER, &PLACEHOLDER_TEMPLATER];
48
49pub trait Templater: Send + Sync {
50 fn name(&self) -> &'static str;
52
53 fn description(&self) -> &'static str;
55
56 fn process(
58 &self,
59 in_str: &str,
60 f_name: &str,
61 config: &FluffConfig,
62 formatter: &Option<Arc<dyn Formatter>>,
63 ) -> Result<TemplatedFile, SQLFluffUserError>;
64}