(:ref)
matches references to a value (dereferencing - finds where a value is used, not where it's defined)
(:ref val)Where:
- val: the value to find references to *
Behavior
- Matches identifiers that reference a value, NOT the value itself (e.g., matches usage of 'x', not the literal 1 in 'var x = 1').
- Tracks references through variable assignments, including chains (ref to ref to ref).
- Follows values through object properties, array elements, and destructuring patterns.
- Respects lexical scope - only matches references within the same scope as the referent.
- For objects and arrays, tracks paths precisely (x.a.b must match the exact path, not partial paths like x.a).
Examples
Find all places where a specific numeric constant is used via variable references.
(arr (el _ (:ref (num 1))))Selects in lines { 3, 4 } but not in { }:
var a = 1;
var b = 1;
[a];
[b];Locate calls that use a jQuery import, excluding shadowed identifiers.
(call (:ref (import jquery)))Selects in lines { 9 } but not in { }:
import $ from 'jquery';
const jQuery = $;
function x(jQuery) {
return jQuery();
}
$('.button').click()Find where object property values are accessed, tracking through member paths.
(call log (arg _ (:ref (num 5))))Selects in lines { 2 } but not in { }:
var config = { timeout: 5 };
log(config.timeout)
log(config)Track a value through destructuring assignments.
(call process (arg _ (:ref (num 5))))Selects in lines { 4 } but not in { }:
var data = { count: 5 };
var { count: userCount } = data
process(userCount)Find references through transitive assignments (ref to ref).
(call log (arg _ (:ref (obj))))Selects in lines { 5 } but not in { }:
var a = {};
var b = a;
var c = b;
log(c)Track array element access by index.
(call process (arg _ (:ref (num 7))))Selects in lines { 2 } but not in { }:
var items = [7, 8, 9];
process(items[0])
process(items[1])Arguments
val
Does NOT support: Refinement — Replacement