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 | The Clojure symbol-constituent characters, as the body of a bracket expression. |
cider-xref--symbol-chars-no-slash | Like ‘cider-xref--symbol-chars’ but without the ‘/’ namespace separator. |
cider-xref--ws | A bracket expression matching one whitespace character, newlines included. |
cider-xref-source-extensions | File extensions scanned by the source-based reference search. |
Defined functions (18)
cider-xref--candidate-files | (NAME FILES) |
cider-xref--dedupe | (ITEMS) |
cider-xref--defmethod-regexp | (TARGET-NS NAME CONTEXT) |
cider-xref--defmethod-sites | (VAR) |
cider-xref--defmethods-in-file | (FILE TARGET-NS NAME) |
cider-xref--enclosing-libspec | (POS LIMIT) |
cider-xref--name-alts | (TARGET-NS NAME CONTEXT) |
cider-xref--ns-context | (TARGET-NS NAME) |
cider-xref--project-source-files | () |
cider-xref--reference-regexp | (TARGET-NS NAME CONTEXT) |
cider-xref--references-in-file | (FILE TARGET-NS NAME) |
cider-xref--resolve-var | (VAR) |
cider-xref--scan-buffer | (REGEXP FILE &optional EXCLUDE) |
cider-xref--scan-defmethods | (REGEXP FILE) |
cider-xref--short-name | (VAR) |
cider-xref--source-file-p | (FILE) |
cider-xref--source-references | (TARGET-NS NAME) |
cider-xref--var-source-references | (VAR) |