Skip to content

Commit be8ca7b

Browse files
committed
fix: keep strings and comments intact when re-indenting expression macro bodies
The dedent that removes the formatting SELECT from an expression macro or scalar function body tracked quotes on its own: it knew only doubled quotes as escapes and `--` as a comment. On Snowflake, a multi-line string after a backslash-escaped quote lost indentation inside the string on every run, changing its value. An apostrophe in a `//` comment opened a phantom string, the lines inside a block comment lost two spaces per run, and a block comment kept on the SELECT line set the body's indent. The dedent now reads the formatted SQL with the dialect's own lexical rules: a line that starts inside a string or comment keeps its text, and the body's indent comes from its first line of code. The DuckShop edge-case macro now opens with a block comment.
1 parent 1e9f04c commit be8ca7b

10 files changed

Lines changed: 139 additions & 77 deletions

File tree

‎benchmarks/duckshop/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function, a hook-created JavaScript function, 192 unit tests and 4 scenarios, in
133133
| Ordering through arrays | an unordered `ARRAY_AGG` ranked under `LIMIT` by position, by name, through `IFF` and over `UNION ALL`, with fixtures whose pick does not depend on element order; order-free reads (`ARRAY_SIZE`, `ARRAY_CONTAINS`, `ARRAYS_OVERLAP`, `ARRAY_DISTINCT` of `ARRAY_CAT`, `FLATTEN` values through a CTE); `SELECT DISTINCT` over arrays repeated in different orders; `ARRAY_APPEND`, `ARRAY_INTERSECTION`, `ARRAY_SLICE` with negative bounds, `TO_ARRAY` and bracket array literals |
134134
| VARIANT comparisons | `ARRAY_MAX`, `ARRAY_MIN` and `ARRAY_REVERSE` over arrays mixing numbers, strings, booleans, JSON nulls and integers past 2^53; `MAX` across kinds and non-ASCII strings; `=` and `EQUAL_NULL` for `1`, `"1"` and `1.0`, reordered keys, JSON null and DATE or TIMESTAMP values held in a `VARIANT` against their text; `MIN_BY` and `MAX_BY` of `VARIANT` values; `PARTITION BY`, `SELECT DISTINCT` and `ARRAY_AGG(DISTINCT)` over `VARIANT`; JSON nulls in `ARRAY_REMOVE`, `ARRAY_DISTINCT` and `ARRAYS_OVERLAP`; decimals with trailing zeros in `ARRAY_CONTAINS` and `ARRAY_POSITION`; `OBJECT_CONSTRUCT(* EXCLUDE ("note"))` |
135135
| Dates and times | `TRY_TO_TIMESTAMP_NTZ` and its siblings over free text; epoch milliseconds as numbers and text; daylight-saving gaps and overlaps; fractional offsets; nanosecond truncation and epoch parts after 2242; pre-1970 text with sub-microsecond digits; date-part normalisation; month ends and leap days; week numbering across a year; sentinel timestamps; `TRY_TO_DATE` with numeric and month-name formats over unpadded fields, two-digit years, ISO `T` and `Z`, trailing letters, a long s, mixed separators and runs of spaces; text read as `TIMESTAMP_TZ` and `TIMESTAMP_LTZ` with `T`, `Z`, `+00:00`, `+0000`, `+09:00` and `-05:30`, back as the UTC instant, date, year and day start, and compared with text, `TIMESTAMP_NTZ` and `DATE`; `FIRST_VALUE` of a zoned value as a `DATE`; `DATEADD` and `TIMEADD` on `TIME(3)` and the type they return; `DATEDIFF` across units; `TIME(9)`, `FF3` and bare `FF` formats truncating; `DATE`, `TO_TIME`, `TRY_TO_TIMESTAMP` and `TO_TIMESTAMP_LTZ` of clock text, and `CURRENT_DATE` and `SYSDATE` read only for facts that hold on any day |
136-
| Ordering, numbers and text | NULL ordering under `DESC`; ties in ordered aggregates, `MAX_BY`, `MODE` and `ANY_VALUE`; default window frames; `UNION ALL BY NAME`; `ROUND` half-way values, decimal division, `MOD` and 38-digit amounts; integers past 2^53 against `FLOAT`; regular expressions and backslash escapes, and a scoped SQL macro collapsing whitespace whose body holds a comment; `LIKE ... ESCAPE` and `ILIKE ANY`; `SPLIT_PART` and `SUBSTR` before the start; `NOT IN` with a NULL; names in many scripts; `JOIN ... USING` between `NUMBER(18,0)`, `NUMBER(38,0)` and text keys, with the types of the merged and qualified keys; NULL arithmetic and the types of NULL, decimal and exponent literals, `COUNT`, `ROW_NUMBER`, `%` and `NULLIF`; `MEDIAN` at scales 0 to 15; `DIV0` by literal zeros; `MODE`, `MEDIAN` and `COUNT_IF` over no rows; aggregates inside window functions and `QUALIFY`; `ROLLUP` totals; `TRUNC` of `FLOAT`; infinity words in other scripts; `CASE` without `ELSE` and `DECODE` over text; regular expressions with a `?` after a lazy quantifier, classes opening with `]`, empty matches and `.` against a carriage return; case-insensitive matches outside ASCII; `ILIKE` with a long s; `JAROWINKLER_SIMILARITY` of accented names in both cases; Base64 text with line feeds; `STARTSWITH`, `ENDSWITH`, `SUBSTRING`, `POSITION` with `IN` and with a comma, `CHARINDEX`, `CHR`, `REGEXP_SUBSTR_ALL`, `::STRING` and `CAST ... AS STRING`; `HEX_ENCODE`, `HEX_DECODE_STRING`, `TRY_HEX_DECODE_STRING` and `TRY_BASE64_DECODE_BINARY`; a comment attached to a text literal; `FLOOR` with and without a scale, `BITAND`, `ZEROIFNULL`, `::BIGINT` and `::DOUBLE`; `IS NOT DISTINCT FROM` and `EQUAL_NULL`; a comma join after an explicit join; `HASH_AGG` read in two row orders |
136+
| Ordering, numbers and text | NULL ordering under `DESC`; ties in ordered aggregates, `MAX_BY`, `MODE` and `ANY_VALUE`; default window frames; `UNION ALL BY NAME`; `ROUND` half-way values, decimal division, `MOD` and 38-digit amounts; integers past 2^53 against `FLOAT`; regular expressions and backslash escapes, and a scoped SQL macro collapsing whitespace whose body opens with a block comment and holds a line comment; `LIKE ... ESCAPE` and `ILIKE ANY`; `SPLIT_PART` and `SUBSTR` before the start; `NOT IN` with a NULL; names in many scripts; `JOIN ... USING` between `NUMBER(18,0)`, `NUMBER(38,0)` and text keys, with the types of the merged and qualified keys; NULL arithmetic and the types of NULL, decimal and exponent literals, `COUNT`, `ROW_NUMBER`, `%` and `NULLIF`; `MEDIAN` at scales 0 to 15; `DIV0` by literal zeros; `MODE`, `MEDIAN` and `COUNT_IF` over no rows; aggregates inside window functions and `QUALIFY`; `ROLLUP` totals; `TRUNC` of `FLOAT`; infinity words in other scripts; `CASE` without `ELSE` and `DECODE` over text; regular expressions with a `?` after a lazy quantifier, classes opening with `]`, empty matches and `.` against a carriage return; case-insensitive matches outside ASCII; `ILIKE` with a long s; `JAROWINKLER_SIMILARITY` of accented names in both cases; Base64 text with line feeds; `STARTSWITH`, `ENDSWITH`, `SUBSTRING`, `POSITION` with `IN` and with a comma, `CHARINDEX`, `CHR`, `REGEXP_SUBSTR_ALL`, `::STRING` and `CAST ... AS STRING`; `HEX_ENCODE`, `HEX_DECODE_STRING`, `TRY_HEX_DECODE_STRING` and `TRY_BASE64_DECODE_BINARY`; a comment attached to a text literal; `FLOOR` with and without a scale, `BITAND`, `ZEROIFNULL`, `::BIGINT` and `::DOUBLE`; `IS NOT DISTINCT FROM` and `EQUAL_NULL`; a comma join after an explicit join; `HASH_AGG` read in two row orders |
137137
| Lineage and analysis | clauses whose columns decide rows without being output (`WHERE`, `QUALIFY`, `GROUP BY` by position and `ALL`, `ORDER BY` under `LIMIT`, `EXISTS`, a `FLATTEN` input, `ROLLUP` by position, `EXCEPT` under `LIMIT`); `RIGHT JOIN ... USING`, `NATURAL JOIN`, a `USING` key under a later outer join, and unmatched `ASOF JOIN` rows; `CONNECT BY` beside a column named `level`; a recursive CTE without `RECURSIVE` whose columns shift per iteration; `LAST_DAY` with a date part; positional columns and the names Snowflake gives unaliased expressions; `TEXT(5)` and widened `COUNT` contracts; `LAG` and `LEAD` with one, two and three arguments; a comma-joined `LATERAL` whose nested derived table reads the left item; relations aliased `first` and `last`, one without `AS`, the words of Snowflake's read-order clauses; untyped and typed `FILTER` lambdas over `ARRAY_AGG` in a grouped query; column expression ranges in compiled SQL that SQL and Python macros, a variable and cursor bounds rewrote, and columns qualified by their reference call, whose ranges are dropped |
138138
| Python functions | volatile tokens and numbers from a column, a constant and no argument, and `DIV0` of a volatile call beside look-alike names, checked by assertions that hold for any values; a handler answering NULL input without `STRICT`; Python `None` as JSON null, and datetimes, Decimals and integers past 2^53 handed to `VARIANT` and `FLOAT` results |
139139
| Scenarios and lifecycle | typed values across model boundaries; `VARIANT` expected output; a star under a lower-case contract and a quoted camelCase export; a snapshot keyed and compared on quoted camelCase columns; a cursor-window incremental model over far-apart fixture loads; a change log merged across two loads, checked against a full rebuild, and a keyed cursor `delete_insert` copy of it whose rows move out of the window between loads |

‎benchmarks/duckshop/project/models/staging/edge_cases/_sqlbuild/_macros/sql/collapse_whitespace.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ MACRO (
44
returns VARCHAR,
55
);
66

7+
/* Spaces, tabs and line breaks all count as whitespace,
8+
so a value pasted from a spreadsheet collapses too */
79
REGEXP_REPLACE(
810
@text_value,
911
-- Each run of spaces, tabs and line breaks becomes one space

‎crates/sqlbuild-rules/src/lint_text/_helpers/format_bodies.rs‎

Lines changed: 52 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use sqlbuild_attachments::ceremonial_select::main::omitted_select_offset::omitte
88
use sqlbuild_attachments::ceremonial_select::models::OmittedSelect;
99
use sqlbuild_core::text::main::python_isspace::python_isspace;
1010
use sqlbuild_core::text::main::python_splitlines::python_splitlines;
11+
use sqlbuild_sqltext::sql_scan::main::dialect_non_code_ranges::dialect_non_code_ranges;
1112
use sqlbuild_sqltext::sql_scan::models::LexicalSyntax;
1213

1314
use crate::dsl_headers::main::declares_table_returns::declares_table_returns;
@@ -17,16 +18,18 @@ use crate::dsl_headers::main::sql_body_ranges::sql_body_ranges;
1718
use crate::dsl_headers::models::HeaderSpan;
1819
use crate::lint_text::_helpers::sites::compiled;
1920
use crate::lint_text::constants::{
20-
DECLARATION_GROUP_DIRECTORY, DECLINED_WITHOUT_REASON, DOLLAR_QUOTE, EXPRESSION_SELECT_PREFIX,
21-
FIXTURE_HEADER_KINDS, FORMAT_API_VERSION, FUNCTION_HEADER_KIND, GLOBAL_NAMED_ROOTS,
22-
GROUPED_NAMED_ROLES, LINE_COMMENT_PREFIX, LINTED_EXPRESSION_ALIAS, MACRO_HEADER_KIND,
23-
MAX_FUNCTION_CALL_DEPTH, MOVED_EXPRESSION_ALIAS, MOVED_OMITTED_SELECT,
24-
OMITTED_CEREMONIAL_SELECT_SQL, OMITTED_SELECT_SUFFIX_PATTERN, STRING_QUOTES,
21+
BLOCK_COMMENT_OPENER, DECLARATION_GROUP_DIRECTORY, DECLINED_WITHOUT_REASON,
22+
EXPRESSION_SELECT_PREFIX, FIXTURE_HEADER_KINDS, FORMAT_API_VERSION, FUNCTION_HEADER_KIND,
23+
GLOBAL_NAMED_ROOTS, GROUPED_NAMED_ROLES, LINE_COMMENT_PREFIX, LINTED_EXPRESSION_ALIAS,
24+
MACRO_HEADER_KIND, MAX_FUNCTION_CALL_DEPTH, MOVED_EXPRESSION_ALIAS, MOVED_OMITTED_SELECT,
25+
OMITTED_CEREMONIAL_SELECT_SQL, OMITTED_SELECT_SUFFIX_PATTERN,
2526
};
2627
use crate::lint_text::errors::LintTextError;
2728
use crate::lint_text::main::neutralize_interpolation::neutralize_interpolation;
2829
use crate::lint_text::main::restore_interpolation::restore_interpolation;
29-
use crate::lint_text::models::{FormatFault, FormatFile, InterpolationSite, PreparedBody};
30+
use crate::lint_text::models::{
31+
FormatFault, FormatFile, FormatRun, InterpolationSite, PreparedBody,
32+
};
3033
use sqlclean::sql_lint::models::{FormatRequest, FormatResponse};
3134

3235
static OMITTED_SELECT_SUFFIX: LazyLock<Result<Regex, regex::Error>> =
@@ -260,6 +263,7 @@ fn printed_width(text: &str) -> usize {
260263
pub(crate) fn formatted_body(
261264
prepared: &PreparedBody,
262265
response: &FormatResponse,
266+
syntax: &LexicalSyntax,
263267
) -> Result<Option<String>, String> {
264268
if !response.formatted {
265269
return Err(response
@@ -287,7 +291,7 @@ pub(crate) fn formatted_body(
287291
let Some(alias) = pattern.find(sql) else {
288292
return Err(MOVED_EXPRESSION_ALIAS.to_string());
289293
};
290-
unwrapped = unwrapped_expression(&sql[..alias.start()])
294+
unwrapped = unwrapped_expression(&sql[..alias.start()], syntax)
291295
.ok_or_else(|| MOVED_EXPRESSION_ALIAS.to_string())?;
292296
sql = &unwrapped;
293297
changed = true;
@@ -305,13 +309,13 @@ pub(crate) fn splice_file(
305309
index: usize,
306310
contents: &str,
307311
bodies: &[PreparedBody],
308-
responses: &[FormatResponse],
312+
run: &FormatRun<'_>,
309313
) -> (Option<String>, Vec<FormatFault>) {
310314
let original: Vec<char> = contents.chars().collect();
311315
let mut updated: Vec<char> = original.clone();
312316
let mut faults: Vec<FormatFault> = Vec::new();
313317
for body in bodies.iter().rev() {
314-
match formatted_body(body, &responses[body.request]) {
318+
match formatted_body(body, &run.responses[body.request], run.syntax) {
315319
Ok(Some(replacement)) => {
316320
let _ = updated.splice(body.start..body.end, replacement.chars());
317321
}
@@ -324,86 +328,67 @@ pub(crate) fn splice_file(
324328
.count()
325329
+ 1,
326330
reason,
327-
unavailable: responses[body.request].unavailable.is_some(),
331+
unavailable: run.responses[body.request].unavailable.is_some(),
328332
}),
329333
}
330334
}
331335
let formatted: Option<String> = (updated != original).then(|| updated.into_iter().collect());
332336
(formatted, faults)
333337
}
334338

335-
/// The expression of a formatted one-item `SELECT`, dedented, or `None` if it is not one.
336-
pub(crate) fn unwrapped_expression(formatted: &str) -> Option<String> {
339+
/// The expression of a formatted one-item `SELECT`, dedented except inside comments and strings.
340+
pub(crate) fn unwrapped_expression(formatted: &str, syntax: &LexicalSyntax) -> Option<String> {
337341
let trimmed: &str = formatted.trim_start();
338342
let keyword: &str = trimmed.get(..EXPRESSION_SELECT_PREFIX.trim_end().len())?;
339343
if !keyword.eq_ignore_ascii_case(EXPRESSION_SELECT_PREFIX.trim_end()) {
340344
return None;
341345
}
342346
let rest: &str = &trimmed[keyword.len()..];
343-
let lines: Vec<&str> = rest.trim_start_matches([' ', '\t']).lines().collect();
344-
let first: &str = lines.first().copied().unwrap_or_default();
345-
let (first, rest_lines): (&str, &[&str]) = if first.trim().is_empty() {
346-
(
347-
lines.get(1).copied().unwrap_or_default(),
348-
lines.get(2..).unwrap_or_default(),
349-
)
350-
} else {
351-
(first, lines.get(1..).unwrap_or_default())
352-
};
353-
let code: &str = std::iter::once(first)
354-
.chain(rest_lines.iter().copied())
355-
.find(|line| !line.trim_start().starts_with(LINE_COMMENT_PREFIX))
356-
.unwrap_or(first);
347+
let opaque: Vec<(usize, usize)> = dialect_non_code_ranges(rest, syntax);
348+
let mut offset: usize = rest.len() - rest.trim_start_matches([' ', '\t']).len();
349+
let mut lines: Vec<(usize, &str)> = Vec::new();
350+
for line in rest[offset..].split('\n') {
351+
lines.push((offset, line.strip_suffix('\r').unwrap_or(line)));
352+
offset += line.len() + 1;
353+
}
354+
if lines.len() > 1 && lines[0].1.trim().is_empty() {
355+
let _ = lines.remove(0);
356+
}
357+
let (_, first): (usize, &str) = lines[0];
358+
let code: &str = lines
359+
.iter()
360+
.find(|&&(start, line)| {
361+
let lead: usize = start + line.len() - line.trim_start().len();
362+
!line.trim().is_empty() && !in_comment(rest, &opaque, lead, syntax)
363+
})
364+
.map_or(first, |&(_, line)| line);
357365
let indent: usize = code.len() - code.trim_start().len();
366+
let mut ranges = opaque.iter().peekable();
358367
let mut dedented: Vec<&str> = vec![first.trim_start()];
359-
let mut quote: Option<char> = open_quote(None, first);
360-
for line in rest_lines {
361-
if quote.is_some() {
368+
for &(start, line) in &lines[1..] {
369+
while ranges.next_if(|&&(_, end)| end <= start).is_some() {}
370+
if ranges.peek().is_some_and(|&&(open, _)| open < start) {
362371
dedented.push(line);
363372
} else {
364373
let leading: usize = line.len() - line.trim_start().len();
365374
dedented.push(&line[leading.min(indent)..]);
366375
}
367-
quote = open_quote(quote, line);
368376
}
369377
Some(dedented.join("\n").trim_end().to_owned())
370378
}
371379

372-
/// The quote still open after `line`, given the one before it; `$` stands for `$$`, which has no escapes.
373-
fn open_quote(mut quote: Option<char>, line: &str) -> Option<char> {
374-
let mut characters = line.chars().peekable();
375-
let mut previous: Option<char> = None;
376-
while let Some(character) = characters.next() {
377-
let after_word: bool = previous.is_some_and(|before| {
378-
before.is_alphanumeric() || before == '_' || before == DOLLAR_QUOTE
379-
});
380-
previous = Some(character);
381-
if character == DOLLAR_QUOTE
382-
&& (quote == Some(DOLLAR_QUOTE) || (quote.is_none() && !after_word))
383-
&& characters.peek() == Some(&DOLLAR_QUOTE)
384-
{
385-
let _ = characters.next();
386-
quote = if quote.is_some() {
387-
None
388-
} else {
389-
Some(DOLLAR_QUOTE)
390-
};
391-
continue;
392-
}
393-
match quote {
394-
Some(DOLLAR_QUOTE) => {}
395-
Some(open) if character == open => {
396-
if characters.peek() == Some(&open) {
397-
let _ = characters.next();
398-
} else {
399-
quote = None;
400-
}
401-
}
402-
Some(_) => {}
403-
None if STRING_QUOTES.contains(&character) => quote = Some(character),
404-
None if character == '-' && characters.peek() == Some(&'-') => return None,
405-
None => {}
406-
}
407-
}
408-
quote
380+
/// Whether offset `at` of `text` lies in one of its non-code `ranges` that is a comment.
381+
fn in_comment(text: &str, ranges: &[(usize, usize)], at: usize, syntax: &LexicalSyntax) -> bool {
382+
ranges
383+
.iter()
384+
.any(|&(open, end)| open <= at && at < end && is_comment(&text[open..], syntax))
385+
}
386+
387+
/// Whether the non-code text at the start of `text` is a comment rather than quoted text.
388+
fn is_comment(text: &str, syntax: &LexicalSyntax) -> bool {
389+
text.starts_with(BLOCK_COMMENT_OPENER)
390+
|| syntax
391+
.line_comment_prefixes
392+
.iter()
393+
.any(|prefix| text.starts_with(prefix.as_str()))
409394
}

‎crates/sqlbuild-rules/src/lint_text/constants.rs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ pub(crate) const CROSS_KEYWORD: &[u8] = b"cross";
215215
pub(crate) const EXPRESSION_SELECT_PREFIX: &str = "SELECT ";
216216
/// The output name lint and format give an expression body; Snowflake keeps unnamed items as written.
217217
pub(crate) const LINTED_EXPRESSION_ALIAS: &str = "__sqlbuild_macro_expression__";
218-
/// The characters that open a quoted string or identifier in formatted SQL.
219-
pub(crate) const STRING_QUOTES: [char; 3] = ['\'', '"', '`'];
220-
/// Each half of the `$$` that opens and closes a dollar-quoted string in formatted SQL.
221-
pub(crate) const DOLLAR_QUOTE: char = '$';
222218

223219
/// A CTE definition, capturing its `name`.
224220
pub(crate) const CTE_DEFINITION_PATTERN: &str = r#"(?is)(?:\bWITH(?:\s+RECURSIVE)?|,)\s*["`\[]?(?P<name>[A-Za-z_][A-Za-z0-9_]*)["`\]]?(?:\s*\([^)]*\))?\s+AS\s*\("#;

‎crates/sqlbuild-rules/src/lint_text/main/format_sql_bodies.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use crate::lint_text::_helpers::format_bodies::{
66
PendingBody, RequestTable, prepare_file, splice_file,
77
};
88
use crate::lint_text::errors::LintTextError;
9-
use crate::lint_text::models::{FormatFault, FormatFile, FormattedBodies, PreparedBody};
9+
use crate::lint_text::models::{FormatFault, FormatFile, FormatRun, FormattedBodies, PreparedBody};
10+
use sqlbuild_sqltext::sql_scan::main::dialect_lexical_syntax::dialect_lexical_syntax;
11+
use sqlbuild_sqltext::sql_scan::models::LexicalSyntax;
1012
use sqlclean::sql_lint::main::format_requests::format_requests;
1113
use sqlclean::sql_lint::models::FormatResponse;
1214

@@ -31,11 +33,16 @@ pub fn format_sql_bodies(
3133
prepared.push(bodies);
3234
}
3335
let responses: Vec<FormatResponse> = format_requests(table.requests);
36+
let syntax: LexicalSyntax = dialect_lexical_syntax(dialect);
37+
let run: FormatRun<'_> = FormatRun {
38+
responses: &responses,
39+
syntax: &syntax,
40+
};
3441
let spliced: Vec<(Option<String>, Vec<FormatFault>)> = files
3542
.par_iter()
3643
.zip(prepared.par_iter())
3744
.enumerate()
38-
.map(|(index, (file, bodies))| splice_file(index, &file.contents, bodies, &responses))
45+
.map(|(index, (file, bodies))| splice_file(index, &file.contents, bodies, &run))
3946
.collect();
4047
let mut result: FormattedBodies = FormattedBodies::default();
4148
for (index, (formatted, faults)) in spliced.into_iter().enumerate() {

‎crates/sqlbuild-rules/src/lint_text/models.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ pub struct FormattedBodies {
8383
pub faults: Vec<FormatFault>,
8484
}
8585

86+
/// What splicing reads from one formatting run: every response, and the dialect's lexical syntax.
87+
#[derive(Clone, Copy, Debug)]
88+
pub(crate) struct FormatRun<'a> {
89+
pub(crate) responses: &'a [sqlclean::sql_lint::models::FormatResponse],
90+
pub(crate) syntax: &'a sqlbuild_sqltext::sql_scan::models::LexicalSyntax,
91+
}
92+
8693
/// One authored body prepared for batched formatting; offsets are character positions.
8794
#[derive(Clone, Debug, PartialEq, Eq)]
8895
pub(crate) struct PreparedBody {

0 commit comments

Comments
 (0)