This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-06
Channels
- # announcements (37)
- # babashka (17)
- # beginners (20)
- # calva (2)
- # clj-kondo (15)
- # cljs-dev (1)
- # clojure (6)
- # clojure-austin (2)
- # clojure-china (3)
- # clojure-europe (27)
- # clojure-korea (1)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojurescript (13)
- # conjure (3)
- # datomic (31)
- # events (3)
- # honeysql (14)
- # jobs-discuss (33)
- # leiningen (4)
- # lsp (57)
- # membrane (3)
- # missionary (5)
- # off-topic (1)
- # releases (3)
- # shadow-cljs (18)
- # slack-help (2)
- # specter (2)
- # yamlscript (10)
I still can't see import missing libspec and add missing imports in the code actions. I'm not even sure how to execute add-missing-import without code actions. This is using Emacs
otherwise if you wanna execute a specific command, lsp-clojure-*
, although via code action is probably a better idea
add-missing-import
doesn't show up as a code action, and also does not exist as a lsp-clojure-* command
There's add-import-to-namespace, but I believe that's different no? This one it asks you what is the full import you want to add
The truth is that code actions should be used for that, it cover all cases that command does and even more like suggestions and so on
Code Actions have not been very reliable for me. The libspec/missing import has not shown up in it for over a year
The code action is just a friendly UX for a command, if that's not showing it's because even the command wouldn't work. Looks like a bug or misconfiguration in the project, if you manage to repro in https://github.com/ericdallo/clojure-sample would be easier to understand
Is it not possible that it's the contextual logic that does not work? Like for showing the code action or not?
I saw last time you said:
> the missing import code action relies on java analysis, that for JDK is done after startup as an async process, you should see Analyzing JDK source
after startup message from latest clojure-lsp or just check the logs, you can force java analysis scan removing ~/.cache/clojure-lsp
and restart LSP
please, share a piece of code or test in that repo sample I mentioned, it's really hard to understand only saying: "it doesn't work for me"
You mean as in, if I checkout that sample project? Or you want a similar sample project to repro?
You can checkout that project, I just need to understand what you are trying to do in what snippet of code
(Date.)
Cursor over the D, run lsp-execute-code-action. Expect to see add missing import, but do not see it.
Ya, I see at the Create private function Date. But I don't see the Add 'import above it
Right. Ok so ya, if I try for a java class that I wrote in my project I do see it. So it seems specific to java.util.Date
I deleted my ~/.cache/clojure-lsp
, restarted lsp with lsp-workspace-restart
and now it works, it seems clojure-lsp had a wrong cached java analaysis for some reason
probably some clojure-lsp bug with the post startup java sdk analysis :thinking_face:
yeah, after startup clojure-lsp will do a async task of analyze jdk, it should mention in the progress on the right bottom
Oh weird. So I have two java classes in my project. One it works, the other it does not.
first let's check if the built-in java.util.Date works, then we check the other issue
but it should show in clojure-lsp logs too, although would be nice checking why you don't see it
> 2024-05-06T16:27:56.643Z WARN [clojure-lsp.feature.java-interop:303] - [Java] JDK source not found, skipping java analysis.
> 2024-05-06T16:27:56.643Z WARN [clojure-lsp.feature.java-interop:292] - [Java] Skipping download JDK source, setting :java :download-jdk-source?
is disabled.
Is this because I don't have on my machine the JDK installed where the source files are included? And in that case, I could turn on this option and clojure-lsp would download the source on its own? Or I could try to install the JDL sources on my machine?
yeah, clojure-lsp didn't find any JDK installation, and since :java :download-jdk-source?
setting is disabled by default it didn't download
I'm wondering if we should change that setting to true
as default, I could swear it was true already :thinking_face: , but meanwhile could you try changing to true?
Before I change it to true, I'm wondering why it didn't find a JDK install? Where does it look for the JDK and it's source files?
@UKFSJSM38 Ok, on openSuse the jdk install does not install the sources by default, you have to install the source bundle as well. After I did that, it all works now. One thing I noticed is the issue I was having with some of my classes also not appearing in the code actions is resolved. So maybe somehow if the JDK sources are missing, it also breaks the analysis of some of the java sources in the project itself. Not sure, but at least it seems it's all working for me now.