clojure-emacs / clojure-emacs/orchard

xref-find-references for keywords

Open
#181 1 comment 0 reactions 0 assignees View on GitHub
xref
Dominant language
Clojure
Stars
340
Forks
52
Avg merge
55m
Merged PRs (30d)
5

Description

One often can wonder "where is this keyword used?". Especially (but not limited to) ns-qualified keywords.

So our existing xref-find-references functionality could be extended to support keywords, based on simple source code analysis.

It would be our first xref-like feature that would support clojurescript.

And also, I believe, one of our very first features using a more comprehensive static source code analysis (e.g. traverse _many_ files in search of matches), with all it takes (performance, caching etc).

I wouldn't want to create our own clj-kondo/clojure-lsp style local databases - those projects are much more refined than what one could handroll of a one-off feature.

I'm thinking of something in-memory, parallel, maybe backed by a [LRU cache](https://github.com/clojure-emacs/orchard/blob/c78cec64703a274ad2985f1460440db55e010765/java/mx/cider/orchard/LruMap.java).

Normally, keyword search is limited to a project, so we can take advantage of that to quite greatly limit the search corpus (maybe to the extent of not needing a cache. IDK).

So, in a way, this would be like a glorified grep, except that it understands keywords better:

* for the input parsing, it understands that our query of `::foo` means `:some.ns/foo`
* while searching a given ns for matches, it knows to search for any of `::foo`, `::bar/foo`, `:a.b.c/foo`, depending on the context
* matches are exact (grep can struggle when a given keyword is a subset of a longer keyword)

Leaving it here for the hammock.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.