Uploaded image for project: 'BlueJ'
  1. BlueJ
  2. BLUEJ-326

Strange debug output during auto-layout operation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Affects Version/s: 3.0.4
    • Fix Version/s: 3.0.5
    • Component/s: Editor

      Description

      Load the attached java source (it is from a Greenfoot project) and perform auto-layout. Notice the following debug output:

      Element mismatch!!!!
      Element mismatch!!!!
      Element mismatch!!!!
      

      This comes from bluej.editor.Moe.!MoeIndent.!DocumentIndentAction, near the start of the apply() method:

                  if (doc.getDefaultRootElement().getElement(ll) != el) {
                      System.out.println("Element mismatch!!!!");
                  }
      

      Note the comment at the start of the same method:

              // Because we keep element references, we don't have to worry about the offsets
              // altering, because they will alter before we process the line, and thus
              // everything works nicely.
      

      I think that may be an incorrect assumption; any edits might change the elements that are part of the document. In particular deleting blank lines probably causes this, but even without that we're relying on undocumented behaviour here and ideally we shouldn't cache the elements like we do. I think it would be best to do two passes, one which removes the blank lines, and another which fixes the indents on the remaining lines, but even then it would ideally associate the updates with line numbers rather than with elements.

        Attachments

          Activity

            People

            • Assignee:
              davmac Davin McCall
              Reporter:
              davmac Davin McCall
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: