#943: rework combine of text nodes in XML merger - #2324
Open
Paras14 wants to merge 3 commits into
Open
Conversation
Collaborator
Coverage Report for CI Build 31963392865Warning No base build found for commit Coverage: 72.922%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
krystynaShatkovska
self-requested a review
August 13, 2026 07:54
Contributor
|
All tests cases pass. combine-text-nodes-mixed and combine-text-nodes cover what is needed. About trim behavior, it is now consistent. As it overwrite and append path trim. Because of getText() method trim, append path now matches overwrite path. Good work! |
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.
This PR fixes #943
Implemented changes:
XmlMergeStrategy.replaceTextNodeso that it no longer restarts its search at the first child of the result element on every call. It now receives the index to start searching from and returns the index to continue from, so the n-th textual child of the template is merged into the n-th textual child of the result.XmlMergeStrategy.combineChildNodesto carry that index across loop iterations instead of callingreplaceTextNodewith no position information.combine-text-nodesandcombine-text-nodes-mixed.This only affects elements that have more than one textual child, which is why it went unnoticed. Almost all configuration files handled by the merger use a single text node per element, and that case was and still is merged correctly. Multiple textual children occur when a CDATA section sits next to plain text, for example in formatter or file header templates.
Note that the code referenced in the issue has been moved since the issue was written. It is now in
cli/src/main/java/com/devonfw/tools/ide/merge/xml/XmlMergeStrategy.javaand the reported behaviour was unchanged by that move.Testing instructions
Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:
com.devonfw.tools.ide.merge.xml.XmlMergerTestfrom your IDE. The relevant test method istestMerger, which is a parameterized test with one execution per subfolder ofcli/src/test/resources/xmlmerger. All 21 executions should pass, 19 of which existed before this PR.combine-text-nodesandcombine-text-nodes-mixed. Each test folder containstemplate.xmlas the merge template,target.xmlas the existing workspace file, andresult.xmlas the expected merge output.cli/src/test/resources/xmlmerger/combine-text-nodesonto a checkout without the change inXmlMergeStrategy.javaand runXmlMergerTestagain. Thecombine-text-nodesexecution then fails withexpected:<...text1<![CDATA[text2]]>text3...> but was:<...text3<![CDATA[text5]]>text6...>.The test cases cover the following:
combine-text-nodeselem1combine-text-nodeselem2combine-text-nodeselem3combine-text-nodeselem4combine-text-nodes-mixedelem1Checklist for this PR
Make sure everything is checked before merging this PR. For further info please also see
our DoD.
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.batand notfeature/921 fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)with
internalpom.xmlfiles or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc