David, 

Thanks a lot for the change, so fast too!  Nicely packaged now, great!
I really like this feature, and have wanted it for awhile!

More feedback: I find it almost perfect now.  The issues I see relate
to handling package names with only two part domains.  To show this, I
have a contrived example of many variations of package names.  Running
jde-import-organize on this:

import a.b.c.*;
import a.b.d.*;
import a.b.e.*;
import a.c.c;
import a.c.d.*;
import a.c.e;
import b.c.c.*;
import b.c.d.*;
import b.c.e;
import b.d.c;
import b.d.d;
import b.d.e;
import c.a.b;
import d.a.b;
import e.a.b;
import f.a.b;
import g.e.ab.*;
import g.a;
import g.b;
import g.c.*;
import g.d;
import java.awt.*;
import javax.swing.*;
import threejartest2.*;
import threejartest3.*;

results in this:
import a.b.c.*;
import a.b.d.*;
import a.b.e.*;

import a.c.c;
import a.c.d.*;
import a.c.e;

import b.c.c.*;
import b.c.d.*;
import b.c.e;

import b.d.c;
import b.d.d;
import b.d.e;

import c.a.b;

import d.a.b;

import e.a.b;

import f.a.b;

import g.e.ab.*;        <-- this line should be

import g.c.*;           <-- after this line via sort

import java.awt.*;
import javax.swing.*;

import g.a;             <-- these should be placed above via sort
import g.b;
import g.d;
import threejartest2.*;
import threejartest3.*;


I expected it to place them fully sorted, with the packages with only
two domain sections not at the end with the "...last group for imports
not belonging to the above ones...".  I expected the list to result
like this:

import a.b.c.*;
import a.b.d.*;
import a.b.e.*;

import a.c.c;
import a.c.d.*;
import a.c.e;

import b.c.c.*;
import b.c.d.*;
import b.c.e;

import b.d.c;
import b.d.d;
import b.d.e;

import c.a.b;

import d.a.b;

import e.a.b;

import f.a.b;

import g.a;
import g.b;
import g.d;

import g.c.*;

import g.e.ab.*;

import java.awt.*;

import javax.swing.*;

import threejartest2.*;

import threejartest3.*;

Next, I added:
    ("^[^.]+[.]" . 0)
to the rules, so they were:
  '(
    ("^javax?\\.")
    ("^[^.]+[.][^.]+[.]" . 0)
    ("^[^.]+[.]" . 0)
    )

That improved things with the grouping, but the sorting was still off.
That change resulted in:

import a.b.c.*;
import a.b.d.*;
import a.b.e.*;

import a.c.c;
import a.c.d.*;
import a.c.e;

import b.c.c.*;
import b.c.d.*;
import b.c.e;

import b.d.c;
import b.d.d;
import b.d.e;

import c.a.b;

import d.a.b;

import e.a.b;

import f.a.b;

import g.e.ab.*;

import g.c.*;

import java.awt.*;
import javax.swing.*;

import g.a;
import g.b;
import g.d;

import threejartest2.*;

import threejartest3.*;


I also removed:
    ("^javax?\\.")
but that had no effect.


Here is the rules I would like to see for the default grouping
behavior we are talking about (which seems to work with the two rules
set):

if (the first one changes)
{
    blank line
}
else if (the first one is the same and the second one changes)
{
    if (more than two domain sections)
    {
        blank line
    }
    else
    {
        keep together
    }
}

I am puzzled by the sorting issue...

Thanks again for this David!


David Ponce
Sent: Wednesday, November 15, 2000 6:53 AM
[...]
> My feedback: I would like an option to not specify groups, and have
> it automatically insert the line break on changes in the first two
> sections of the package/domain.  e.g.
>
>    com.a.b
>    com.a.c.d
>    com.c.d
>    com.x.y
>    com.x.z
>    java.x.y
>    mno.g.h.i
>
> would break/sort as
>    com.a.b
>    com.a.c.d
>
>    com.c.d
>
>    com.x.y
>    com.x.z
>
>    java.x.y
>
>    mno.g.h.i
[...]

Thank you for your feedback :-)

The attached jde-import-org.el is a new improved library to organize
Java import statements. It defines the command `jde-import-organize'
which breaks/sorts imports following group definitions in
`jde-import-group-rules'.

So now to automatically insert the line break on changes in the first
two sections of the package/domain you can set `jde-import-group-rules'
like the following:

'(("^javax?\\.") ("^[^.]+[.][^.]+[.]" . 0))

And imports statements will be organized in:

- a first group for standard java packages.
- a group for each package with different first two sections.
- a last group for imports not belonging to the above ones.

See the source code for more details on how to customize
`jde-import-group-rules'.

Any feedback will be welcome.

Sincerely,
David

Reply via email to