Fix mismatched XML element pairs on transpile#1746
Draft
TwitchBronBron with Copilot wants to merge 4 commits into
Draft
Fix mismatched XML element pairs on transpile#1746TwitchBronBron with Copilot wants to merge 4 commits into
TwitchBronBron with Copilot wants to merge 4 commits into
Conversation
- Added xmlTagMismatch diagnostic message (code 1155) - Modified SGParser to capture and validate closing tag names - Updated SGTag and subclasses to store optional closingTag - Added diagnostic when opening/closing tags mismatch - Transpile always uses opening tag name for closing tag - Added comprehensive tests for both diagnostic and transpile behavior - All existing tests pass Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix mismatch XML element pairs on transpile
Fix mismatched XML element pairs on transpile
Jul 7, 2026
Reworks the mismatched-closing-tag detection so it runs during validation against the stored `closingTag` on the AST, rather than at parse time from raw tokens. This means the diagnostic now fires for AST injected/mutated by plugins, not just AST produced by the parser. - Parser: keep capturing the closing tag name into `SGTag.closingTag`, but no longer emit the diagnostic during parse (reverts the parse-time diagnostic and the unnecessary `diagnostics` threading through mapNode/mapNodes). - Validator: add `validateTagClosings`, which walks the SG tag tree via a new `SGTag.getChildren()` and reports `xmlTagMismatch` when a present closingTag does not match the opening tag. Self-closing / programmatically-built tags (closingTag undefined) are left valid, preserving backwards compatibility. - Move diagnostic 1155 to its correct sequential position in DiagnosticMessages. - Add SGTypes.spec.ts proving every affected tag type behaves correctly when constructed without a closingTag, and an XmlFile test proving a plugin-injected mismatch is caught at validation time. Note: transpile already emitted the corrected closing tag (`this.tag.text`) in both current master and older v0, so no transpile fix was needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
In v0, mismatched XML tags like
<Group></LayoutGroup>would transpile correctly to<Group></Group>. In v1, this correction was lost and no diagnostics were emitted.Changes
xmlTagMismatchdiagnostic (code 1155) to report when opening/closing tags don't match@xml-tools/parser'sEND_NAMEtoken during parsingSGTagand subclasses to optionally store closing tag for validationmapElementandmapNodeto detect mismatchesExample
Input:
Output after transpile:
Diagnostic emitted: