-
-
Notifications
You must be signed in to change notification settings - Fork 939
Kotlin override/implement member functionality #3719
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
clients/lsp-kotlin.el
Outdated
| (lambda (member-options) | ||
| (-if-let* ((option-items (-map (lambda (x) | ||
| (list (lsp-get x :title) | ||
| (ht-get (lsp-get (lsp-get x :edit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ht-get -> lsp-get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with that is that lsp-get seems to expect a symbol as the key, while ht-get allows strings as well ((lsp--buffer-uri) is a string). I get the following error when using lsp-get in place of ht-get here:
Error processing message (wrong-type-argument symbolp "file:///....")
Tried a few other solutions as well, like converting to symbol, but I couldn't get it to work properly. Let me know if there is something I'm missing 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you try something like this:
(let ((key "uri"))
(intern (concat ":" key) ))
The issue is that when you run that code with lsp-use-plists that map wont the hashtable but it will be plists and it won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works! Thought I tried that earlier... Damn brain 😆
Also good to know about that lsp-use-plists-stuff! Will try to remember that for future work.
|
Thank you! Not that happy with having that multiselect here but we are pretty much out of options... |
Functionality to support override/implement member was recently merged in the language server (screenshot in that PR):
fwcd/kotlin-language-server#379
Think I described the functionality quite well in the PR above:
(the quick fix I'm referring to is a code action that the language server provides)
I think an interactive function makes sense here. The users can then create a key binding for it if they want to. If you feel like we should have one out of the box, let me know 🙂
This functionality is very similar to the Java-version of implement/override methods, but has a few minor differences in how it works. Both need a multiple select field where we can select the methods/members we want. Due to this reason I stole that function from lsp-java:
https://github.com/emacs-lsp/lsp-java/blob/a1aff851bcf4f397f2a968557d213db1fede0c8a/lsp-java.el#L1065
Maybe it should be in a common place? At this point I don't know where it should really be.