[ANN] Rearranger plugin version 4.3 released

The rearranger plugin:

- Rearranges (reorders) class and class member declarations according to a user-specified order and/or method call hierarchy;
- generates section-marking comments;
- provides several controls for spacing within and between methods and classes; and
- permits the user to manually rearrange items.

This version fixes several problems:

- Fixed corruption of Java file header region (package statement, import statement, or comments) when respacing options were enabled and document had no trailing blank line.

- Fixed possible corruption of Java file (typically deletion of left or right brace for a method or class) when respacing options conflicted.

- Clarified rule "Methods implementing interfaces"; now include generated comment in rule description.

+For those interested in the gory details:

The corruption of the Java file header region has been frequently reported, but I was unable to reproduce it until Jason Ozias noticed that that the package statement always gets corrupted in files that don't have a trailing blank line. (Thanks, Jason!)

This explains why sample files submitted to reproduce the problem didn't exhibit the problem: I'd paste them into an empty document (which had one blank line) and the test file would now have a trailing blank line.

If the respacing option to control the number of blank lines at the end of file was enabled, then the code attempted to find whitespace after the last close brace of the file. The code walked the PSI tree looking for the next PsiWhiteSpace element after the close brace. If there was no trailing blank line, the code would actually jump to the next PsiFile (a different document, dependent on the order in which documents were opened - adding a random effect to the bug) and find whitespace there. This whitespace of course would tend to be at the beginning of the other document. Based on the offset of this incorrectly located whitespace, one or more newlines would be inserted into the current document, at an apparently random location.

To all who reported this bug over the past months, thanks for your report and your patience.

Please sign in to leave a comment.