kotlin-community-tools / kotlin-language-server

MIT License
10 stars 3 forks source link

"Add missing imports" action #4

Open owl-from-hogvarts opened 2 months ago

owl-from-hogvarts commented 2 months ago

Goal

Enhance developer experience.

State of art

Unsure, how well infrastructure is prepared to handle such requests.

Why to change?

Manually adding each missing import is a burden (though I am unsure that such action even exists). This is one of the key features in other language servers. It removes a lot of routine work.

Implementation considerations

First, KLSP has to find out which symbols are missing in a current file. Then, it has to resolve these symbols. KLSP may try to find every symbol with matching name in a workspace. Symbols with the same name but different fully qualified name may exist. In such case we have to provide user with a choice which symbol to pick.

Notice, that files located in the exactly same directory does not need to be imported.

Task

Implement "Add missing imports" code action according to Implementation considerations.