Rearranger plugin and tabifier plugin...

when using the tabifier plugin I found that long strings (split over multiple lines) were not being aligned as I would have expected. At least not consistently.

And I didn't seem able to get the rearranger to do the rearranging. I had some private fields at the top of the class that didn't move down the pecking order as I desired. Unfortunately, I closed Idea so I can't paste the examples right now, but I can do it tomorrow if this little post isn't sufficient!

BTW - I LOVE the plugins. I think they're absolutely essential. Can't wait to see Rearranger do its thing for me. Tabifier has been a god send!

Comment actions Permalink

Here's my example with the rearranger...

I have the following fields...

private String wibble;
protected String wobble;
public static final String sillyField = "";
public String hitandmiss;
public static int hithere;
public static final String sillyField2 = "";

And in my ide settings for the rearranger, I have only one entry...

public static final fields

However ctrl-alt-shift-R has no effect on the file.


Comment actions Permalink

Hi Joe,

Thanks for the bug reports. Could you send me that multi-line text that the tabifier isn't handling properly? I'll need enough context so that it compiles, or I can guess what to add to make it compile.

I'm working on (another) completely new version of that plugin. It is handling multiline stuff much better than the last published one. But one more test case won't hurt. :)

I will look into the rearranger problem tomorrow morning.


P.S. Anybody as complimentary as you gets free upgrades. :) (In fact, anybody admitting they use the plugin gets an extra copy for free!)

Comment actions Permalink

This is probably not the smallest testcase I could give you, but it should suffice...

public class Test {

private static final String SQL_GET_COMPANY_NAMES = "select name, id from company order by name";
private static final String SQL_GET_COMPANY_STATUS = "select name, id from company_status order by name";
private static final String SQL_GET_CONTACT_STATUS = "select name, id from contact_status order by name";
private static final String SQL_GET_EMPLOYEE = "select name, id from employee order by name";
private static final String SQL_GET_PASSWORD = "select password from employee where name = ?";

private static final String SQL_GET_CONTACT = "select, co.fname, co.lname, co.title, cu.description, co.company_id, " +
", co.contact_status_id, co.next_call, co.next_call_objective, " +
"cu.areacode,, cu.created_by, cu.created_on, " +
"a.street1, a.street2,, a.state, " +
"from contact co, customer cu, address a " +
"where = " +
"and cu.address_id = a .id ";
private static final String SQL_GET_CONTACT_BY_ID =
"and = ? ";
private static final String SQL_GET_CONTACTS_BY_COMPANY =
"and co.company_id = ?";

private static final String SQL_GET_COMPANY_BY_ID =
"select,, cu.description, co.owner_id, co.environment," +
"co.company_status_id, cu.areacode,, cu.created_by, " +
"cu.created_on, a.street1, a.street2,, a.state, " +
"from customer cu, company co, address a " +
"where = " +
"and cu.address_id = " +
"and = ?";
private static final String SQL_GET_NOTES =
"select id, information, customer_id, created, created_by " +
"from note where customer_id = ? " +
"order by created descending";
private static final String SQL_GET_SECONDARY_ADDRESSES = "";

private static final String SQL_CREATE_CONTACT = "insert into contact values (?,?,?,?,?,?,?,?,?)";
private static final String SQL_CREATE_COMPANY = "insert into company values (?,?,?,?,?)";
private static final String SQL_CREATE_CUSTOMER = "insert into customer values (null,?,?,?,?,?,?)";
private static final String SQL_CREATE_ADDRESS = "insert into address values (null,?,?,?,?,?)";
private static final String SQL_CREATE_NOTE = "insert into note values (null,?,?,?,?)";


Comment actions Permalink

BTW - I can offer you no greater compliment than that I don't think Intellij needs to worry about making Tabification (?!) a first class citizen in their app, as your plugin handles it perfectly well.

However, I will say that it slows down to a crawl on 3000 line classes! I know, I know, my classes shouldn't be that large, but I've just inherited them and making them readable is the first step toward changing them. It is taking 5+ minutes to tabify the whole thing (although a lot of that could be the code style work as I'm doing it all in one motion)

Comment actions Permalink

Yes, the version you have builds a complete line-by-line parsed equivalent, then breaks it into groups, formats each group, and outputs each changed line (in reverse order from the end of the document forward so that earlier offsets are unaffected); finally the whole mess can be garbage collected.

I could definitely be smarter about replacing lines in the document as I parse them into groups so that they can be discarded immediately. I think this would probably help the speed on 3000 line classes. One reason I am afraid to do this is that I don't know what the effect will be on the offsets in the Psi (program structure information) tree if I change the document but don't "commit" it. Would IDEA reparse the document into a new Psi tree while I'm working on it? I don't know. I doubt it, but if it did the document would be ruined. So I didn't take the chance.

I don't think IDEA's code layout reformatting is taking up much of that time. You might try doing the code layout manually using the Tools menu item, then tabifying the whole file manually using the Edit menu Tabifier item, just to see what the actual division of time is.

Say, could you send me a 3000 line class for a test? I've never actually seen one! :)


Comment actions Permalink

Here's another feature request for you...

public static final String JOB_NAME = "OpsCheckOrderStatusBatchJob";
private static final String PADDING = "000000000000000";
private static volatile boolean isRunning = false;
private static final Object lock = new Object();
private static final opsx.log.OpsLogCategory logCat = (opsx.log.OpsLogCategory) opsx.log.OpsLogCategory.getInstance(

In the previous list of methods, the last assignment screws everything up. Because it is casting, all the other lines have their assignments shot right over to the right, to align with "opsx.log.OpsLogCategory.getInstance..."

Also the 'new Object()' line is not aligned with the lines above it. It's left shifted by 3 chars.

Thanks for all the attention on all this.

BTW - did you see what I was talking about with the rearranger. I'm looking forward to getting tucked into using that in earnest.


Comment actions Permalink

er, just to clarify, I obviously meant "previous list of assignments"...



Comment actions Permalink

Yes, I saw your rearranger problem, and have fixed it in version 0.4. Go over to -- we should probably continue our plugin discussions in that forum.


Comment actions Permalink

Joe ( || anyone else interested),

The unreleased new version of the tabifier fixes almost everything you want. But I have a dilemma. Lines like the last one in your example

are being aligned as follows:

In other words, the parameter is being forced to a column to the right of the method call's open parend. Clearly this is not right since the whole point of moving the parameter to the next line was to avoid this sort of right-margin-overrun problem.

However, under other circumstances, this is really the desired behavior. For example, given a method declaration

we want the second line to align with the first, not simply be left justified.

I'm trying to come up with a rule that will do what everybody thinks "is right." (If I can't find a rule, maybe it requires a setting.)

The rule might be that at certain well known points, syntactic items continued on a new line are aligned at the new line's normal indentation. Those points might be:

But I fear that this list could get long. Maybe it would be shorter to list the places where alignment of second and subsequent lines with the first line is forced. That list might be:

So according to R4, an expression like this would be aligned:

since "prefix" (the beginning of the initialization expression) follows the '=' sign. If "prefix" was on the next line, it would align as follows:

I'm leaning toward the latter solution (identifying syntactic points where a newline character does not move subsequent lines to left margin + indent size.) Something like rules R4 & R5.

Does this sound like it will do what folks want? Are there any other rules necessary?


Comment actions Permalink

Sorry - this should have been posted under Plugins forum. Reply there. -D


Please sign in to leave a comment.