java-language-server
java-language-server copied to clipboard
Auto-import completed classes
Hello,
I first want to say I love this project so far. I discovered it today, and I think it will be very useful for me.
I noticed that classes were not auto-importing on completion for me, and searching the issues I saw #167 that wasn't picked up. I thought I would give an implementation of this a try.
I have not added any tests for this yet, but I thought I would share the implementation first to see if you like the approach.
Original Commit Message:
This patch uses the CompilationUnitTree of the file being processed for a completion to build a Set of imports for the current file and to get the path to the file. It then uses the list of imports to determine whether the completion candidate has already been imported. If not, the AddImport class is used to add to the additionalTextEdits field on the CompletionItem.
Some small refactoring was done to pull useful class and package name extractors out of JavaCompilerService.java.