At 09:22 AM 5/5/99 -0700, Thomas K. Burkholder wrote:
>A useful feature I've been thinking about for awhile (in a scripting sort of
>fashion, but it would work even better in jde) is auto-insertion and sorting
>of import statements. As a general coding practice, I avoid ever using * in
Same here.
>import statements. In almost every case, when I use class Foo in code, I
>want to import Foo from it's first occurrence on the classpath... so with
>this feature enabled, I could type "Foo blegga = new Foo()" and the
>
>import com.warga.bar.Foo;
>
>statement would be automatically inserted in the import block at the top of
>the file, if it wasn't already there, the next time the class is compiled.
>
Why not immediately?
>Other useful side-effects: imports could be sorted alphabetically and a
>newline inserted at package boundaries. Also, classes that are no longer
>used could be eliminated from the import block - over time, this becomes
>very useful for maintaining the actual dependencies of your classes.
>
Nice too.
>This would be a huge time-saver for the work I do - I wonder if jde-parse
>could help do this? The hard parts about this feature is the collection of
>class names from the file, and the identification of package-level classes
>that don't need to be imported.
Yes, this is the hard part of a number of "advanced" features we've been
discussing in this list.
>Otherwise it should be a straightforward
>matter of classpath-parsing and final sorting.
>
>Oh, and to save some email bandwidth, I recognize (and mostly agree with)
>the general principle that many folks have with anything that changes code
>"behind the back" of the developer. I just think that in this case the time
>saved and value added would far outweigh any possible confusion generated.
>As with all power features, only those who are comfortable with it need use
>it.
>
I like these suggestions and will make an effort to implement them in some
form--no promises when, however. Right now, method arg/class field
prompting and debugger enhancments are my priority. If someone else wants
to tackle automatic import statement generation, I'd be glad to help in a
consulting role.
Meanwhile, if you haven't already, I'd suggest playing with the new JDE
2.1.5 command, jde-wiz-import (C-c C-v C-z). This command prompts you to
enter the qualified name of the class to import. It then generates the
import statement at the top of the buffer or after any existing import
statements. I use the command a lot.
- Paul