File: cider-xref-source.el.html

Find references to a Clojure var by scanning the project's source files, rather than introspecting the runtime. The runtime-based approach (see cider-xref-fn-refs) only sees namespaces that have been loaded into the REPL; this one covers the whole project on disk, including code that hasn't been evaluated yet.

The strategy splits the problem along its natural seam: resolving the symbol at point to a canonical ns/name genuinely needs semantic knowledge, so we use the lightweight nREPL info/lookup op (via cider-var-info) for that one step. Finding the occurrences is a breadth problem, so we hand it off to a fast text search (Emacs' own xref-matches-in-files, i.e. grep/ripgrep) and then refine the candidates per file.

The refinement is what makes this Clojure-aware rather than a dumb grep: each candidate file's (ns ...) form is parsed to learn that file's alias for the target namespace and whether it refers the name, so only the forms a given file actually licenses are matched. Matches inside strings and comments are dropped via the buffer's syntax table.

This is a heuristic, not a resolved index. It can include shadowing locals and same-named vars referred from a different namespace, and it can miss references hidden in .cljc reader-conditional branches or built from strings at runtime. When precision matters more than coverage, clojure-lsp's static analysis is the better tool.

Defined variables (4)

cider-xref--symbol-chars
cider-xref--symbol-chars-no-slash
cider-xref--ws
cider-xref-source-extensions

Defined functions (18)

cider-xref--candidate-files
cider-xref--dedupe
cider-xref--defmethod-regexp
cider-xref--defmethod-sites
cider-xref--defmethods-in-file
cider-xref--enclosing-libspec
cider-xref--name-alts
cider-xref--ns-context
cider-xref--project-source-files
cider-xref--reference-regexp
cider-xref--references-in-file
cider-xref--resolve-var
cider-xref--scan-buffer
cider-xref--scan-defmethods
cider-xref--short-name
cider-xref--source-file-p
cider-xref--source-references
cider-xref--var-source-references

Defined faces (0)