Fork me on GitHub
#calva
<
2022-06-26
>
yonatanel17:06:55

I'm trying to use the "Resolve macro as" code action by clicking the lightbulb. I choose to resolve as defn, and getting an error "No macro was found at cursor to resolve as 'clojure.core/defn'.". The macro is definintely there as I'm using the context lightbulb action, and it happens on mac and ubuntu. What should I look for to troubleshoot this?

pez09:06:28

Let's see if @U9A1RLFNV has some idea about what to do here. Might be a bug we need to fix.

bringe15:06:15

I just tried this out and sometimes it worked, sometimes it didn’t. I’m not sure what could be causing it to not work, aside from stale clojure-lsp analysis data. CC @UKFSJSM38

bringe15:06:49

For example, after it didn’t work, I edited the file to cause clojure-lsp to re-analyze the file, and then it worked, but I can’t say that consistently made it work after not working.

bringe15:06:27

In a file with this code in it, the command always worked on the first deftest , but sometimes failed on the second.

(ns core-test
  (:require [clojure.test :refer [is deftest]]))

(deftest test-1
  (is true))

(deftest test-2
  (is (= 1 1)))

ericdallo16:06:13

that's weird :thinking_face:

bringe16:06:44

I noticed that if I put the cursor after the t in deftest the command always fails, but if I put it before the t, the command always succeeds.

bringe16:06:14

I included logs from successful and unsuccessful runs in the issue.

bringe16:06:18

I need to work now, but I can check back later.

ericdallo16:06:30

hum, probably we could do a smart resolve macro on clojure-lsp side

ericdallo16:06:38

it's probably using the exactly symbol at point

ericdallo16:06:45

thanks for the help

pez16:06:01

I commented on the issue that Calva could send a selection for what it thinks is the relevant symbol. Then it would correspond to Calva user expectations.

ericdallo16:06:58

Yeah, but that should be handled by server IMO, we already do that for most refactorings, probably there is room to improvement on clojure-lsp side if that's the issue indeed

pez16:06:22

Yeah, it does seem like deftest is a reasonable symbol to use for both those cases. Regardless of editor.