Sublime Forum

Java AutoComplete

#1

Hello!

I was getting a bit tired of there not being any working autocomplete for Java code, one option being old and buggy, and the other also old and buggy and also relying on a java process every time auto complete is checked which made things really slow.

I went over to GitHub, found Display-Functions, only ST2 support, and got to work. This is my first time ever working with Python code which was quite a bit interesting.

Anyway, on to what I did:
March 2nd, 2017
Support for ST3
Classes are now searched in your project folders instead of just the current directory of the file you’re editing
Added chaining for methods that take arguments ( o.doSomething(“hello”).keepGoing() )
Autocomplete static calls ( Object.someStaticMethod() )
Fixed a bug with chained methods when the initial object is one letter ( o.doSomething().keepGoing() )
Fixed some issues I was having with chaining when the method was in a super class
March 29th, 2017
Added an option to set the location of Java’s src.zip for further autocompletion.
typing import CLASS_NAME will attempt to give you suggestions.
Typing package FOLDER_NAME will attempt to give you suggestions.
Continued general improvement on autocompletion.
Added a class buffer to keep things alittle more smooth.
Auto-create getters and setters at the bottom of the class.
New sublime-completions file for general autofill.

What I would like to do is add a setting that allows you to specify a directory where Java’s default classes are so that autocomplete will work without having to import it into your project (the src.zip I believe all JDKs still come with), or even better have the plugin automatically determine the location of your Java installation and use the src.zip on its own. - Can now designate the location of the src.zip.

I’d also like to setup inner class auto completion over top of the standard auto completion to better pull up the current working class methods.

Due to the way the classes are searched, if your project has classes that share the same name you will run into issues of this choosing whichever one comes up first for all auto completion. If it would help, I can re-add checking the current working directory before checking all of your project’s folders. - Now checks all files with the same name, however displays methods for them all and not just the one specifically used. An improvement but not perfect.

One last feature I can think of I want to work on is calling static methods (Object.getStaticMethod). - Done.

I may work on this again in the future, but for the time being it’s still pretty basic from where the original author left off and I don’t make any guarantee I’ll pick this back up.

Now on GitHub!

3 Likes

#2

Not quite a month later and it seems I’ve found myself working on this again. Updated and moved it to GitHub.

0 Likes

#3

Just updated this, rewrote a large chunk of it. A huge number of bugs squashed, auto locating Java’s src.zip, and constructor auto-completion.

0 Likes