[TxMt] Auto-import for java source files
Alex Garrett
ljagged at gmail.com
Wed Sep 14 20:37:17 UTC 2005
I'm trying to figure out a way to do auto-importing for Java in
TextMate. I'm stuck at a couple of places and I would appreciate it if
someone who knows more about TM than I do could chime in with some
suggestions.
Essentially, what I'd like to be able to do is take a class name,
select it, and hit Ctrl-Meta-Bucky-I and have TM add the appropriate
import statement to the file. My naive implmentation would look
something like:
1. Get the project CLASSPATH from a project-level config file
2. Build a list of the jar files on the CLASSPATH and grep through
their contents to find matches.
3. If there's only one match, munge it appropriately and stick it in
the import section of the buffer
4. If there's more than one match, pop up a dialog and let the user
pick the appropriate fully-qualified class name, then stick in import
section.
Does this seem to be a sensible way of approaching the problem? Is
there a way of sticking the import statement where it belongs? More
generally, is there any way to do arbitrary transformations on the
contents of the buffer as if it were a java AST, instead of a stream
of characters? I think that would probably be necessary to create
commands to do source-level refactorings.
Thanks,
Alex
More information about the textmate
mailing list