Skip to content

[Query] Origin

github-actions[bot] edited this page Jul 21, 2026 · 1 revision

This document was generated from 'src/documentation/wiki-query.ts' on 2026-07-20, 17:48:26 UTC presenting an overview of flowR's query API (v2.12.3). Please do not edit this file/wiki page directly.

Origin Query [overview]

Retrieve the origin of a variable, function call, ...
This query is requested with the type origin.
Run in the REPL: :query @origin (<criterion>) <code | file://path>

With this query you can use flowR's origin tracking to find out the read origins of a variable, the functions called by a call, and more.

Using the example code x <- 1 print(x) (with the print(x) in the second line), the following query returns the origins of x in the code:

[
  {
    "type": "origin",
    "criterion": "2@x"
  }
]

(This can be shortened to @origin (2@x) "x <- 1\nprint(x)" when used with the REPL command :query).

Results (prettified and summarized):

Query: origin (6 ms)
   ╰ Origins for {2@x}
     ╰ {"type":0,"id":0}
All queries together required ≈6 ms (1ms accuracy, total 7 ms)

Show Detailed Results as Json

The analysis required 7.5 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "origin": {
    ".meta": {
      "timing": 6
    },
    "results": {
      "2@x": [
        {
          "type": 0,
          "id": 0
        }
      ]
    }
  },
  ".meta": {
    "timing": 6
  }
}
Original Code
x <- 1
print(x)
Dataflow Graph of the R Code

The analysis required 5.8 ms (including parse and normalize, using the r-shell engine) within the generation environment. No signature database is mounted for these generated graphs, so library() calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. acf as stats::acf). We encountered unknown side effects (with ids: 6 (linked)) during the analysis.

flowchart LR
    1{{"`*#91;RNumber#93;* **1**
      *1.6* (**id: 1**)`"}}
   %% No edges found for 1
    0["`*#91;RSymbol#93;* **x**
      *1.1* (**id: 0**, v: 1)`"]
    2[["`*#91;RBinaryOp#93;* base#58;#58;**#60;#45;**
      *1.1-6* (**id: 2**)
    arg: (0, 1)`"]]
    built-in:_-["`Built-In:
#60;#45;`"]
    style built-in:_- stroke:gray,fill:gray,stroke-width:2px,opacity:.8;
    4(["`*#91;RSymbol#93;* **x**
      *2.7* (**id: 4**)`"])
    6[["`*#91;RFunctionCall#93;* base#58;#58;**print**
      *2.1-8* (**id: 6**)
    arg: (4)`"]]
    built-in:print["`Built-In:
print`"]
    style built-in:print stroke:gray,fill:gray,stroke-width:2px,opacity:.8;
    0 -->|"defined-by"| 1
    0 -->|"defined-by"| 2
    2 -->|"reads, arg"| 1
    2 -->|"returns, arg"| 0
    2 -.->|"reads, calls"| built-in:_-
    linkStyle 4 stroke:gray;
    4 -->|"reads"| 0
    6 -->|"reads, returns, arg"| 4
    6 -.->|"reads, calls"| built-in:print
    linkStyle 7 stroke:gray;
Loading
Implementation Details

Responsible for the execution of the Origin Query query is executeSearch in ./src/queries/catalog/origin-query/origin-query-executor.ts.

Clone this wiki locally