Skip to content

(:text) - Operators

select a value by source code (text-based search)

clojure
(:text val)

Where:

  1. val: literal source code to match *

Guides

Examples

Find Rust macro invocations that TreeSitter doesn't parse into structured nodes.

clojure
(:and (:text /Foo::A/) (:kind "token_tree"))

Selects in lines { 2 }:

typescript
macro_rules! m {
  () => { Foo::A }
}
m!();

Locate TODO comments in any language by matching comment text.

clojure
(:text /TODO:/)

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

typescript
// TODO: fix this
// FIXME: refactor
/* TODO: add tests */

Find specific string patterns that appear in code before extracting to constants.

clojure
(:text "https://api.example.com")

Selects in lines { 1, 1 }:

typescript
const url1 = 'https://api.example.com/users'
const url2 = 'https://api.other.com/users'
fetch('https://api.example.com/posts')

Arguments

val

  1. String
  2. Pattern
  3. Identifier

Does NOT support: CompositionFree-form SelectionRefinementReplacement

Copyright © 2022-present Semantic Works, Inc.