-
Notifications
You must be signed in to change notification settings - Fork 56
Improve error messaging for incorrect XML tag casing #1540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
e7efd04
445946e
016d2db
226d953
e550398
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -257,11 +257,23 @@ function mapElements(content: ContentCstNode, allow: string[], diagnostics: Diag | |
| if (allow.includes(name.image)) { | ||
| tags.push(mapElement(entry, diagnostics)); | ||
| } else { | ||
| //unexpected tag | ||
| diagnostics.push({ | ||
| ...DiagnosticMessages.xmlUnexpectedTag(name.image), | ||
| range: rangeFromTokens(name) | ||
| }); | ||
| // Check if this is a case mismatch for a known tag | ||
| const lowerCaseTag = name.image.toLowerCase(); | ||
| const matchingAllowedTag = allow.find(allowedTag => allowedTag.toLowerCase() === lowerCaseTag); | ||
|
|
||
| if (matchingAllowedTag && matchingAllowedTag !== name.image) { | ||
| // Case mismatch for a known tag | ||
| diagnostics.push({ | ||
| ...DiagnosticMessages.xmlTagCaseMismatch(name.image, matchingAllowedTag), | ||
| range: rangeFromTokens(name) | ||
| }); | ||
| } else { | ||
| // Truly unexpected tag | ||
| diagnostics.push({ | ||
| ...DiagnosticMessages.xmlUnexpectedTag(name.image), | ||
| range: rangeFromTokens(name) | ||
| }); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this into Add a unit test where a plugin changes the casing of one of these elements and then it gets caught during validation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved the XML tag casing validation to |
||
| } else { | ||
| //bad xml syntax... | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the bottom of the list so its code is in the correct order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved xmlTagCaseMismatch diagnostic to the bottom of the list so its code (1143) is in the correct numerical order after code 1142.