Fork me on GitHub
#lsp
<
2021-11-20
>
slipset10:11:20

My colleague @holyjak was looking for some specific calls to a fn based on arity, so he ended up with:

clj -Sdeps {io.github.borkdude/grasp {:git/sha "435301926d9e832964a75bf117e4199651d21a53"}} (g/grasp "/path/to/ardoq" (g/seq (g/rsym 'ardoq.core/->context) any? any? any?))
I have no idea how to implement in a UI, but I think it would be useful as a feature in general, it’s like a “find references”, but on steroids.

ericdallo13:11:40

It's a find references but that matches the function arity? If doesn't matches it'd throw an error right? Not sure the use case here

Jakub Holý (HolyJak)14:11:02

The use case was that I wanted to remove the 3 årg version of the fn so wanted to find where that is used

borkdude14:11:09

you can find this using the clj-kondo static analysis output as well.

:var-usages, a list of maps with:

:filename
:name: the name of the used var
:row, col: the start position of this usage, the parenthesis start location if a function call
:end-row, end-col: the end position of this usage, the parenthesis end location if a function call
:name-row, :name-col: the start position of the name of this usage
:name-end-row, :name-end-col: the end position of the name of this usage
:from: the namespace from which the var was used
:to: the namespace of the used var
:from-var: the function name from which the var was used
Optional:

:arity: if the usage was a function call, the amount of arguments passed

ericdallo14:11:37

IMO that could work on clojure-lsp, passing some extra info to filter N arities, needs to check if we could hack the spec for that though

borkdude14:11:45

Here you would need to look at the :name , :to and :arity keys

borkdude14:11:20

This seems like a rather one-off analysis thing for which I would just write a script rather than hacking it into lsp

☝️ 1
👍 1
ericdallo14:11:25

yeah, actually you already have clj-kondo analysis for your whole project since clojure-lsp uses it, maybe we could have a custom method to expose that to user

borkdude14:11:52

@UKFSJSM38 I think it would be better to allow users to query directly on the datalevin database using datalog ;)

😻 2
borkdude14:11:17

clojure-lsp --query '<some-datalog> || query.edn'

borkdude14:11:35

but this would require you to expose the structure of the database, not sure you want to do that

ericdallo14:11:45

yeah, it's something that could open doors for a lot of possibilities indeed, I don't see any issues exposing db structure I think, needs some hammock time though I think

borkdude14:11:41

just writing a script directly on the clj-kondo analysis is easy enough though

👍 1
slipset15:11:07

Just to be clear, I'm perfectly happy with this not being a part of clojure-lsp, and I really appreciate the hammock time

👍 1
borkdude15:11:24

I think I want to experiment throwing the clj-kondo analysis into #asami because it also keeps track of history

❤️ 1
borkdude15:11:37

Then you can ask questions like, what changed over time, etc.

borkdude15:11:05

And then offer a nice API over this

borkdude15:11:24

as a separate tool

borkdude15:11:29

this can also be done from a babashka script even with datalevin + clj-kondo as a pod.

Jakub Holý (HolyJak)16:11:07

Is the var name always unqualified or..?

borkdude16:11:21

@holyjak The var name is separate from the ns name in the clj-kondo analysis

👍 1
borkdude16:11:59

but of course you can dump it into a datalog db in any format you like

borkdude16:11:07

or just add a clause [?x :var/ns clojure.core]

mpenet17:11:50

Codeq2 was supposed to go into that direction I think

mpenet17:11:30

In theory allowing you to do stuff like only running the test for code that changed etc

borkdude17:11:41

I think you could build that on this analysis by looking at the transitive namespace graph and file modified times for example

Drew Verlee15:11:43

Is anyone able to follow these instructions successfully to get a debugger in cljs? https://emacs-lsp.github.io/lsp-mode/tutorials/debugging-clojure-script/ I can't figure out how to install this google chrome debug adapter. i don't have a M-X dap-chrome-setup command and the link takes me to a deprecated extension.

ericdallo16:11:34

Tô bem honesto I never tried, yyoncho from emacs-lsp discord channel that built that some time ago

👍 1
ericdallo23:11:24

Stub generation coming soon! 🚀 Check closed source analysis working with datomic.api

🚀 7