Architecture

March 23, 2026 ยท View on GitHub

High-Level Flow

  1. VS Code calls the document formatter provider.
  2. Extension reads workspace settings (maxLineLength, dialect).
  3. formatExpression() performs dialect-aware parsing.
  4. Parsed AST is sent to the deterministic printer.
  5. Printer returns canonical text; extension applies a full-document edit.

Dialect Pipeline

  • standard: strict JMESPath parse path.
  • roarpath: preprocess ~ roots to $, parse with legacy literal support, print root as ~.
  • auto: try standard first, fallback to roarpath.

This keeps parsing concerns isolated from printer concerns.

Formatter Invariants

  • Idempotent output.
  • Stable precedence and parentheses handling.
  • Stable wrapping controlled by maxLineLength.
  • No evaluation/runtime semantics in formatter logic.

Testing Strategy

  • Fixture tests for canonical output.
  • Behavior tests for dialect selection and edge-case handling.
  • Explicit invalid-input coverage.
  • Idempotency checks across fixture outputs.