Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: modello-plugin-jdom
-
Labels:None
-
Complexity:Intermediate
-
Testcase included:yes
-
Patch Submitted:Yes
Description
The insertAtPreferredLocation method generated for the JDOM writer seems to have a fencepost error in its calculation of the insert position. The symptom is that a new element is added one slot past where it should be.
For example, when counter.getCurrentIndex() is zero, the new element is added as the second item in the list rather than the first as you would expect. In a debugger, where parent.getContent() has first a Text and then an Element, contentIndex is set to 2 on the second and final loop iteration.
I am working on a test case for an instance of the generated code. So far it seems that replacing <= with < in the loop condition suffices to fix the bug.
There is also some sort of longstanding indentation bug (all lines past a certain point indented by one too many virtual tabs) but I am not going to spend time fixing this now.