Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-import completed classes #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

epaulson10
Copy link

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant