Skip to content

refactor(json): template the ParseError/Json/JsonPath Show impls - #4198

Merged
bobzhang merged 1 commit into
mainfrom
hongbo/simplify-template-json
Sep 3, 2026
Merged

refactor(json): template the ParseError/Json/JsonPath Show impls#4198
bobzhang merged 1 commit into
mainfrom
hongbo/simplify-template-json

Conversation

@bobzhang

@bobzhang bobzhang commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Part of the <+> template-writing simplification, split out of the closed
#4195 for reviewability.

  • ParseError variants and the deprecated Json Show render through
    <+> templates; the conditional Number(...) arm delegates to a local
    writer function so its delimiters stay paired in one template
  • JsonPath JSON Pointer rendering streams each path step through a
    template with \{cb => ...} writer holes (recursion and token escaping
    delegated to local writer functions)

Inline-writer holes use \{cb => ...} so delimiters stay paired and the
templates stay readable. Output is unchanged.

Verified: moon check 0 warnings/0 errors, json suite 219/219.

Generated with SeekMoon

- `ParseError` variants and the deprecated `Json` `Show` render through
  `<+` templates; the conditional `Number(...)` arm delegates to a local
  writer function so its delimiters stay paired in one template
- `JsonPath` JSON Pointer rendering streams each path step through a
  template with `\{cb => ...}` writer holes

Inline-writer holes use `\{cb => ...}` so delimiters stay paired and the
templates stay readable.

Co-Authored-By: SeekMoon <seekmoon@moonbitlang.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are a mechanical refactor to template-writing with preserved structure and no apparent behavioral change, and the PR reports passing checks/tests.

Pull request overview

Refactors JSON-related Show implementations to use <+> template-writing, improving readability by keeping delimiters paired and consolidating previously interleaved write_* sequences, while preserving existing output.

Changes:

  • Switched ParseError Show rendering to <+> templates for simpler, more uniform formatting.
  • Refactored deprecated Json Show formatting to use inline-writer holes, with a local writer helper for the conditional repr segment.
  • Updated JsonPath (JSON Pointer) rendering to stream each step via templates and writer holes, keeping recursion and escaping delegated to helpers.
File summaries
File Description
json/types.mbt Converts ParseError and deprecated Json Show output to <+> templates, using a local writer helper to keep parentheses and optional segments paired.
json/json_path.mbt Refactors JSON Pointer (JsonPath) streaming output to use templates with writer holes for recursive prefix building and token escaping.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 6526

Coverage decreased (-0.01%) to 89.183%

Details

  • Coverage decreased (-0.01%) from the base build.
  • Patch coverage: 16 of 16 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18193
Covered Lines: 16225
Line Coverage: 89.18%
Coverage Strength: 274819.42 hits per line

💛 - Coveralls

@bobzhang
bobzhang merged commit ee6fe38 into main Sep 3, 2026
17 checks passed
@bobzhang
bobzhang deleted the hongbo/simplify-template-json branch September 3, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants