jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Modello
  • MODELLO-257

JDOM writer: fencepost error in insertAtPreferredLocation

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor 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.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Jesse Glick added a comment - 19/Oct/11 12:58 PM

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.

Show
Jesse Glick added a comment - 19/Oct/11 12:58 PM 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.
Hide
Permalink
Jesse Glick added a comment - 19/Oct/11 1:11 PM

http://hg.netbeans.org/core-main/rev/f3e4f46151cc has my attempted fix to generated code, including test case.

Show
Jesse Glick added a comment - 19/Oct/11 1:11 PM http://hg.netbeans.org/core-main/rev/f3e4f46151cc has my attempted fix to generated code, including test case.

People

  • Assignee:
    Unassigned
    Reporter:
    Jesse Glick
Vote (0)
Watch (1)

Dates

  • Created:
    19/Oct/11 12:56 PM
    Updated:
    19/Oct/11 1:11 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.