[ANN] Rearranger plugin - version 2.2

This plugin
- rearranges (reorders) class and class member declarations according to a user-specified order and/or method call hierarchy;
- generates section-marking comments; and
- provides several controls for spacing within and between methods and classes.

Version 2.2 is primarily a bug fix release:

- repeated Rearranging no longer inserts an additional blank line after a generated separator comment

- inner class separator comments are properly removed and regenerated

- toolbar icons in Live Rearrange popup might be fixed (I am guessing that they worked on Windows platforms but not Linux because of upper/lowercase issues)

- blank lines before and/or after separator comments are now preserved and correctly inserted

- default configuration updated to add a blank line before and after each separator comment

New feature:

- Confirm Rearrangement dialog has been enhanced in a few ways. Separator comments may optionally be shown in the tree, both as rules and as generated comments. The list of rules shown may be restricted to only those with matching items. And the checkboxes have been replaced with buttons. The dialog has been made resizable.


I'll try to implement many of the remaining features you've suggested in the next release.

-Dave

Caveats:

I discovered a few oddities that can still affect appearance of blank lines around comments.

- Sometimes IDEA doesn't strip trailing whitespace from a line. I pressed 'Enter' repeatedly in one Java file, and got "\n \n " inserted in the file (one newline and four spaces per line). I have tried to account for this, but it may mess things up if this sort of behavior occurs inside or before the generated comment. Seems to happen infrequently.

- IDEA doesn't save newline characters in the other.xml file, even when emitted as element text. Perhaps a document formatter is losing them when it tidies up indentation. It does read newline characters. So you may create a configuration by hand (e.g. the included default configuration) that contains newline characters before and/or after a separator comment, and the plugin will see them. But when saved, these characters are escaped as "\n" for newline and "\t" for tab.

20 comments

One additional feature I forgot to mention:

- checkbox on General settings pane "Rearrange contents of inner classes" controls whether contents of inner classes are recursively rearranged (using the same rules as for class members), or are copied intact. By default, contents of inner classes are not rearranged.

0

I have some larger files that rearranger won't change. I don't get any error messages or anything and it doesn't rearrange the classes. It just sits at parsing for a minute then stops. Any ideas?

0

Well, there are a few things we can try to narrow it down.

1) Enable "confirm rearrangement" on General pane, and try to run it. Do you get a popup window showing proposed rearrangement?

2) If you do a Live Rearranger (Ctrl-comma), do you get a popup window?

3) Is your configuration non-empty? (If your configuration would cause the file to appear as it currently is, it might be difficult to detect if rearrangement occurred.) Try loading the default configuration; save yours first if you want to keep it.

4) does anything appear in the log file? If something bad happens, I would expect an exception to be generated.

5) If none of these pan out (you get no popup windows and nothing appears in the log file), we can do one of two things:

a) send me your file and configuration, and I'll try to reproduce it. This works reasonably well even though most external references (like other classes) are unknown.

b) If you don't want to part with your source :), or if I can't reproduce it, we can turn on the debugging output. Between that and your source I should be able to figure out what's going wrong.

Thanks for the report! (Sorry for the bug :( ) -
-Dave

0

Hi Dave,

Thanks for the Live Rearranger. Nevertheless I have some
suggestions/complaints in random order:
- the toolbar buttons do not have an IDEA-typical border,
- I see 3 toolbar buttons, the type button, then space and then again
two toolbar buttons without an icon
- toggling the type toolbar button collapses the class node
- please use an OK/Cancel dialog so it is easy to revert changes
- using a dialog also would allow to put an move-up/move down button
right beside the tree, so one could rearrange easily using mnemonics
- using a dialog also would allow to resize the window
- when drag'n'dropping, please show anyhow where the dropped item will
be placed (see Mozilla Firefox' Bookmark Manager for an good example)
- do you have the ability to change the icons, so for instance abstract
methods show up differently then "normal" ones (maybe a tree table
would be also a solution?)

Again, thanks for providing us with such a good plugin. If you need a
SmartCVS Professional license for your plugin development, let me know.

Cheers,
Tom

0

I vote for replacing the idea structure view. Then all of Thomas' idea
would fit in cleanly.

Thomas Singer (MoTJ) wrote:

Hi Dave,

Thanks for the Live Rearranger. Nevertheless I have some
suggestions/complaints in random order:
- the toolbar buttons do not have an IDEA-typical border,
- I see 3 toolbar buttons, the type button, then space and then again
two toolbar buttons without an icon
- toggling the type toolbar button collapses the class node
- please use an OK/Cancel dialog so it is easy to revert changes
- using a dialog also would allow to put an move-up/move down button
right beside the tree, so one could rearrange easily using mnemonics
- using a dialog also would allow to resize the window
- when drag'n'dropping, please show anyhow where the dropped item will
be placed (see Mozilla Firefox' Bookmark Manager for an good example)
- do you have the ability to change the icons, so for instance abstract
methods show up differently then "normal" ones (maybe a tree table
would be also a solution?)

Again, thanks for providing us with such a good plugin. If you need a
SmartCVS Professional license for your plugin development, let me know.

Cheers,
Tom


--
Barry Kaplan
Integrated Trading Solutions
bkaplan@integratedtrading.com

0

Thomas Singer (MoTJ) wrote:

- I see 3 toolbar buttons, the type button, then space and then again
two toolbar buttons without an icon


I noticed this problem as well. It turned out to be caused by the icon files
having different capitalisation in their names to what the plugin was
looking for. You can fix it by expanding the jar, renaming the icon files to
have the correct capitalisation (camel case for the name with the first
letter in upper case, all lower case for the extension) and recreating the jar.

BTW, the space is actually an extra toggle button which isn't selected.

- toggling the type toolbar button collapses the class node


+1, this is (mildly) annoying.

- please use an OK/Cancel dialog so it is easy to revert changes


-1, you can use Undo to revert the changes. Maybe if there was an option to
show a confirmation dialog before applying the changes?

- using a dialog also would allow to put an move-up/move down button
right beside the tree, so one could rearrange easily using mnemonics


Good idea! It would be nice to be able to keep my hands on the keyboard,
instead of having to use the mouse for rearranging. I think I'd still use
the mouse if I was rearranging a couple of methods, but if it was just one
of them the keyboard would probably be easier.

- using a dialog also would allow to resize the window
- when drag'n'dropping, please show anyhow where the dropped item will
be placed (see Mozilla Firefox' Bookmark Manager for an good example)


+1, I've suggested this too and supplied some sample code for it. Dave, you
did receive that, didn't you...?

Cheerio,
Vil.
--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

Vilya Harvey wrote:

Dave, you did receive that, didn't you...?


Oops, ignore this Dave - I've just read your reply to Thomas.

Vil.
--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

Tom, Barry,

Perhaps you saw the original request by Keith Lea (http://www.intellij.net/forums/thread.jsp?forum=18&thread=68347&tstart=30&trange=30) for the live rearranger feature. (Tom posted some replies to the thread.) Keith expressed a desire for behavior that could not be provided with a standard dialog box.

In retrospect, it would have been much easier to use a dialog box; but I sure learned a lot about Swing internals, windows/frames/internal frames/popups etc.!

Keith, if you see this post, perhaps you could weigh in. Would replacing the popup with a standard OK/cancel dialog be acceptable? If not, I either have to implement two UI's (starting to look like IDEA classic vs. modern configuration panels!) or alienate one or more valuable plugin users! Implementing both is not terribly hard but wouldn't be my preference.

Addressing your individual items in order, Tom:

- the toolbar buttons do not have an IDEA-typical border
Looks like I need a black border around the button when it is selected or highlighted by mouseover. Tell me if that's not what you mean.

- I see 3 toolbar buttons, the type button, then space and then again two toolbar buttons without an icon
Vil diagnosed this problem; I'll have a fix shortly.

- toggling the type toolbar button collapses the class node
There are other problems with the expanded state of nodes in the tree. The tree should always expand the path to the item where the cursor (caret) is, but it isn't. Thereafter it should preserve the state.

- please use an OK/Cancel dialog so it is easy to revert changes
Easy to do with a dialog. Keith explicitly didn't want this, and felt that Undo-ing was sufficient.

+- using a dialog also would allow to put an move-up/move down button
right beside the tree, so one could rearrange easily using mnemonics+
Will do.

- using a dialog also would allow to resize the window
Will do.

- when drag'n'dropping, please show anyhow where the dropped item will be placed (see Mozilla Firefox' Bookmark Manager for an good example)
Vil sent me some sample code to do this; I plan to implement it.

- do you have the ability to change the icons, so for instance abstract methods show up differently than "normal" ones (maybe a tree table would be also a solution?)
Right now, the icons chosen for the tree nodes are hardcoded and come from IDEA's icons.jar file (all are from nodes directory at the moment.) I could allow you to specify the icons (at the expense of complicating the UI, I suppose). Is that what you want? I didn't understand what you meant by 'tree table'; please explain.

Thanks for the feedback and suggestions,
-Dave

0

Hi Dave,

Keith, if you see this post, perhaps you could weigh in. Would replacing the popup with a standard OK/cancel dialog be acceptable? If not, I either have to implement two UI's (starting to look like IDEA classic vs. modern configuration panels!) or alienate one or more valuable plugin users! Implementing both is not terribly hard but wouldn't be my preference.


I don't see any point against a dialog. Maybe Keith can give me some hint.

- the toolbar buttons do not have an IDEA-typical border
Looks like I need a black border around the button when it is selected or highlighted by mouseover. Tell me if that's not what you mean.


Hmm, I guess, not manipulating IDEA's toolbar buttons should be
sufficient. Do you set them an empty border?

- using a dialog also would allow to resize the window


BTW, this is for me the most important issue, because I need it much
larger for large classes.

- when drag'n'dropping, please show anyhow where the dropped item will be placed (see Mozilla Firefox' Bookmark Manager for an good example)
Vil sent me some sample code to do this; I plan to implement it.


Vil, could you please send it me too, I'm also interested.

- do you have the ability to change the icons, so for instance abstract methods show up differently than "normal" ones (maybe a tree table would be also a solution?)
Right now, the icons chosen for the tree nodes are hardcoded and come from IDEA's icons.jar file (all are from nodes directory at the moment.) I could allow you to specify the icons (at the expense of complicating the UI, I suppose). Is that what you want? I didn't understand what you meant by 'tree table'; please explain.


I meant the icons in the tree. If you would use an tree table (it's just
an idea, not direct wish), then the modifiers (visibility, static,
final, abstract, ...) could easily been shown.

--
Cheers,
Tom

0

Would it be possible to have rearranger ignore leading whitespace when inserting separator comments (or rather, when it checks to see if it needs to)? Or have an option to do so?

When people reformat my code to their pet indentation style, I don't want rearranger to insert the same comment it just did, but with a slightly different indentation.

I end up with:

/////////////////
// instance vars
/////////////////
/////////////////
// instance vars
/////////////////

as an example.

0

1. I had the confirm rearrangement selected and that didn't help.

2. I have also tried the live rearranger.

3. My config should be good because I am able to rearrange the majority of my source files just fine.

4. As far as a log, I'm not seeing any logs. Is there a way to turn them on or is there a specific folder that I can look in? This would be extremely helpful I'm sure.

5. I'll try to find a valid code snippit that I can send to you. I'm not sure how to turn on the debugging, but I would be more than happy to trace some debug info.

Thanks

Nic

P.S. I really enjoy the rearranger even with a couple minor glitches.

0

I'm not completely sure what its doing, but it seems to have something to do with interface implementation. If I remove my implements part of my class, it runs fine. When I add the interface back to the class, it doesn't rearrange. I'm still planning to get you a code sample. I'm just playing around with it for a minute.

0

Yes, it should be done that way. I'll add it to the todo list.

I have a feature request (well, it was my own request :) to optionally indent generated comments. Then of course the comment removal code would also have to recognize indented comments. So this would kill two birds with one stone.

Thanks for the request,
-Dave

0

I had a couple of files I was about to send, then all of a sudden they worked. It seems a little random. Maybe it would be better if you told me how to turn on the debugging and I'll keep an eye on it.

0

Funny..maybe the plugin heard you were going to send me the files, and it would be in trouble.. ;)

To turn on debugging:

Put the following in your /bin/log.xml file just before the final element. and be sure that the console is enabled in idea.lax for stderr and stdout redirection (search for "console" and add it to the respective properties.) Then restart IDEA. This should start generating a ton of output to a console window (and the log file). You can set ]]> to reduce everything again (or just remove the entire category insertion.)

Thanks for taking the trouble to track this down -
-Dave

0

It looks like the code inside the isCanonicalOrInterface get stuck in an infinite loop. I added another check that seems to have taken care of all my issues. I have attached the source file for your review.

Nic



Attachment(s):
ClassEntry.java
0

Dave Kriewall wrote:

Tom, Barry,

Perhaps you saw the original request by Keith Lea (http://www.intellij.net/forums/thread.jsp?forum=18&thread=68347&tstart=30&trange=30) for the live rearranger feature. (Tom posted some replies to the thread.) Keith expressed a desire for behavior that could not be provided with a standard dialog box.


Yes I did. I came back to post this just after wanting to resize the
popup and found I could not.

0

I overcome this by modify the comment pattern in general page. try add "\s*" before and after ur pattern and ur comments will always be recognized.

0

Thomas Singer (MoTJ) wrote:
>> Vil sent me some sample code to do this; I plan to implement it.


Vil, could you please send it me too, I'm also interested.


Sure, as an occasional user of SmartCVS I'm more than happy to. :) If I
remove the spam blocking parts from the return address on your post, will
that get through to you?

Vil.
--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

Can you give me a discrete example? I think I understand what you're getting at but am not 100% sure.

Something like:

^\s//.\s*$ ?

0

Please sign in to leave a comment.