refactor(json): template the ParseError/Json/JsonPath Show impls - #4198
Merged
Conversation
- `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>
Contributor
There was a problem hiding this comment.
🟢 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
ParseErrorShowrendering to<+>templates for simpler, more uniform formatting. - Refactored deprecated
JsonShowformatting to use inline-writer holes, with a local writer helper for the conditionalreprsegment. - 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.
Collaborator
Coverage Report for CI Build 6526Coverage decreased (-0.01%) to 89.183%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the
<+>template-writing simplification, split out of the closed#4195 for reviewability.
ParseErrorvariants and the deprecatedJsonShowrender through<+>templates; the conditionalNumber(...)arm delegates to a localwriter function so its delimiters stay paired in one template
JsonPathJSON Pointer rendering streams each path step through atemplate with
\{cb => ...}writer holes (recursion and token escapingdelegated to local writer functions)
Inline-writer holes use
\{cb => ...}so delimiters stay paired and thetemplates stay readable. Output is unchanged.
Verified:
moon check0 warnings/0 errors, json suite 219/219.Generated with SeekMoon