Skip to content

(:ref)

matches references to a value (dereferencing - finds where a value is used, not where it's defined)

clojure
(:ref val)

Where:

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

clojure
(arr (el _ (:ref (num 1))))

Selects in lines { 3, 4 } but not in { }:

typescript
var a = 1;
var b = 1;
[a];
[b];

Locate calls that use a jQuery import, excluding shadowed identifiers.

clojure
(call (:ref (import jquery)))

Selects in lines { 9 } but not in { }:

typescript
import $ from 'jquery';

const jQuery = $;

function x(jQuery) {
  return jQuery();
}

$('.button').click()

Find where object property values are accessed, tracking through member paths.

clojure
(call log (arg _ (:ref (num 5))))

Selects in lines { 2 } but not in { }:

typescript
var config = { timeout: 5 };
log(config.timeout)
log(config)

Track a value through destructuring assignments.

clojure
(call process (arg _ (:ref (num 5))))

Selects in lines { 4 } but not in { }:

typescript
var data = { count: 5 };
var { count: userCount } = data

process(userCount)

Find references through transitive assignments (ref to ref).

clojure
(call log (arg _ (:ref (obj))))

Selects in lines { 5 } but not in { }:

typescript
var a = {};
var b = a;
var c = b;

log(c)

Track array element access by index.

clojure
(call process (arg _ (:ref (num 7))))

Selects in lines { 2 } but not in { }:

typescript
var items = [7, 8, 9];
process(items[0])
process(items[1])

Arguments

val

• Identifier • String (:kind) (:ref) (:text) (:and) (:not) (:or)

Does NOT support: RefinementReplacement

Copyright © 2022-present Semantic Works, Inc.