fwcd / fwcd/kotlin-language-server

Extend "Add missing import" code action to suggest "static methods"/functions

Open
#528 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
2k
Forks
252
PR merge metrics
No merged PRs in 30d

Description

Currently, the code action for adding missing imports only suggests classes. Often we might want to statically import a Java static method or similar. Those are currently not suggested by the code action. Worked a lot with some static helper methods in a library at work today, so it bothered me enough to create an issue 😛 If nothing else, then as a wishlist item.

Example: We have written the code `currentThread()` in our editor, and naturally we get an error. Neither the completion (when we wrote it) or the code action (after writing) suggests anything. One possible suggestion would be to import `java.lang.Thread.currentThread` (aka the static method `currentThread`).

Unsure on how to solve this. The easiest solution would probably be to put the static methods in the symbol index as well, as we would easily query it that way. The initialization of the server is already slow and consume a lot of memory, so I'm a little bit hesitant to implement it that way. Please let me know if anyone have any suggested solutions 🙂

This is probably true for the completion functionality as well.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.