refactor(dedup): share TruncateText across Markdown generators
`TruncateText` was copy-pasted verbatim in three Markdown generators
(`SqlServer.QueryBreakdownGenerator`, `SqlServer.SqlStatementGenerator`,
`Expressions.ExpressionGenerator`). Pulled out to a new
`Strata.SqlTools.Markdown.Internal.MarkdownTextHelpers` static class
(internal — no public-API change).
Each call site keeps its own one-line private wrapper for source
readability so existing `TruncateText(...)` calls in the generators
need no edits.
Deliberately *not* unified across the same three files:
- `EscapeMermaidText` (QueryBreakdownGenerator) vs `EscapeMermaidText`
(SqlStatementGenerator) — the QBG version intentionally escapes
`[]{}()` for Mermaid node syntax; the SSG version only escapes
quotes/newlines because it writes into `Note right of DB: ...`
contexts where brackets render fine.
- `EscapeMarkdown` (ExpressionGenerator) — a different escape set
again, targeting Markdown rather than Mermaid.
Also deliberately *not* refactored: `SqlServer.UpdateBreakdown.TryParse`
≡ `SqlServer.ProcedureBreakdown.TryParse` prelude (empty-check +
parser + prefix regex + extract setup/finish clauses). The 30-line
duplication is real, but every extraction shape (tuple return,
`out`-flavored helper, context type) is measurably worse than the
duplicated original. Leaving it.
All 1180 tests stay green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
d4b66838b5
commit
4b5348c53a
@@ -361,13 +361,7 @@ public class ExpressionGenerator : IVisitor<string>
|
||||
}
|
||||
|
||||
private static string TruncateText(string text, int maxLength)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text) || text.Length <= maxLength)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
return string.Concat(text.AsSpan(0, maxLength), "...");
|
||||
}
|
||||
=> Internal.MarkdownTextHelpers.TruncateText(text, maxLength);
|
||||
|
||||
#region IVisitor Implementation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user