Fix Root class name conflict in JDOM writer generator#520
Merged
slachiewicz merged 3 commits intomasterfrom Oct 8, 2025
Merged
Fix Root class name conflict in JDOM writer generator#520slachiewicz merged 3 commits intomasterfrom
slachiewicz merged 3 commits intomasterfrom
Conversation
Copilot
AI
changed the title
[WIP]
Fix Root class name conflict in JDOM writer generator
Oct 5, 2025
Root can not be used as class name for jdom-writer
slachiewicz
approved these changes
Oct 6, 2025
…e to rootElement Co-authored-by: slachiewicz <[email protected]>
Co-authored-by: slachiewicz <[email protected]>
5ddb79a to
890036f
Compare
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.
Problem
When using
Rootas a class name for the root element in a model definition, the JDOM writer generator would produce code that failed to compile due to a variable naming conflict.The generated
updateRoot()method would declare both:Root root(from uncapitalizing the class name "Root")Element root(for the XML element being created)This resulted in a compilation error:
Solution
Renamed the local
Elementvariable fromroottorootElementthroughout theJDOMWriterGenerator.updateClass()method. This makes the generated code use distinct names:root- the model object parameterrootElement- the XML Element being createdBefore (would not compile):
After (compiles successfully):
Testing
root-classname.mdotest model withRootas the class nameRootClassnameJDOMGeneratorTestto verify generated code compiles successfullyFixes the issue where models with a root class named "Root" would generate non-compilable JDOM writer code.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.