Fork me on GitHub

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.


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


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

:var-usages, a list of maps with:

: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

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


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


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


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

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


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

😻 2

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


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


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


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

👍 1

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

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

❤️ 1

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


And then offer a nice API over this


as a separate tool


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..?


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

👍 1

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


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


Codeq2 was supposed to go into that direction I think


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


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? 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.


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

👍 1

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

🚀 7