Skip to content

fix(sandbox): declarative engine JSONC, sql.format and sql.parse no longer regex over literals (#1567) - #1678

Merged
ZhuchkaTriplesix merged 3 commits into
devfrom
issue/1567-declarative-engine
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 3 commits into
devfrom
issue/1567-declarative-engine

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1567.

  • _parseJsoncObject uses stripJsonc (string-aware, trailing commas) instead of two regexes, so "https://example.com" survives.
  • sql.format lays out blanks and ; only in code segments (SqlLexicalScanner) and uppercases through formatSqlScript (fix(editor): Format SQL uppercases words inside string literals, quoted identifiers and comments #1566): literals, quoted identifiers and comments are kept as written. No per-call regex compilation.
  • sql.parse skips leading comments (stripLeadingWhitespaceAndLineComments) and takes the first word with one firstMatch.
  • Tests: format with keywords and ; inside literals/comments, uppercaseKeywords:false, parse after comments, JSONC with URL, /* in a string and a trailing comma.

…SQL outside literals, parses past leading comments (#1567)
@github-actions github-actions Bot added bug Something isn't working parser Theme parser epic label: parser core Core library logic and services P3 Low priority / Polish & Enhancements labels Oct 17, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit cae040d into dev Oct 17, 2026
13 checks passed
@ZhuchkaTriplesix

Copy link
Copy Markdown
Member Author

🔍 Post-Merge Code Review & Verification

Crucial parser and formatter precision improvements:

  1. Lexical SQL Formatting (declarative_embedded_engine.dart):

    • Replacing global regex replacements with SqlLexicalScanner.segments(source) ensures semicolons, whitespace, and keyword casing transformations are strictly applied to SqlSegmentKind.code.
    • String literals, comments, and quoted identifiers are preserved verbatim with no corruption of embedded punctuation or keywords.
  2. String-Aware JSONC Preprocessing:

    • Migration to stripJsonc reliably preserves URLs (e.g. https://...) and comments within string values, while supporting trailing commas.
  3. Robust Statement Parsing:

    • stripLeadingWhitespaceAndLineComments guarantees that queries preceded by multi-line or block comments correctly identify the lead statement keyword.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core Core library logic and services P3 Low priority / Polish & Enhancements parser Theme parser epic label: parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant