Repository navigation
[Query] Static Slice
Generated from 'wiki-query.ts' on 2026-11-08, 08:41:45 UTC (v2.17.4), do not edit directly.
Static Slice Query [overview]
Slice the dataflow graph reducing the code to just the parts relevant for the given criteria (backward and forward).
This query is requested with the type static-slice.
Run in the REPL: :query @static-slice (<crit>;...)[fricIB] <code | file://path>
To slice, flowR needs one thing from you: a variable or a list of variables (function calls are supported to, referring to the anonymous return of the call) that you want to slice the dataflow graph for (additionally, you have to tell flowR if you want to have a forward slice). Given this, the backward slice is essentially the subpart of the program that may influence the value of the variables you are interested in. To specify a variable of interest, you have to present flowR with a slicing criterion (or, respectively, an array of them).
To exemplify the capabilities, consider the following code:
x <- 1
y <- 2
z <- 3
xIf you are interested in the parts required for the use of x in the last line and z, you can use the following query:
[ { "type": "static-slice", "criteria": [ "3@z", "4@x" ] } ](This can be shortened to @static-slice (3@z;4@x) "x <- 1\ny <- 2\nz <- 3\nx" when used with the REPL command :query).
Results (prettified and summarized):
x <- 1
z <- 3
x
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
The JSON contains the ids of the nodes in question (see the Interface wiki page).
{"static-slice":{".meta":{},"results":{"3@z,4@x":{"slice":{"timesHitThreshold":0,"result":[6,9,0,2,1,8,7],"slicedFor":[6,9],"freeNames":[],".meta":{}},"reconstruct":{"code":"x <- 1\nz <- 3\nx","files":[{"code":"x <- 1\nz <- 3\nx"}],"linesWithAutoSelected":0,".meta":{}}}}},".meta":{}}In general, you may be uninterested in seeing the reconstructed version and want to save some computation time, for this,
you can use the noReconstruction flag.
No Reconstruction Example
[ { "type": "static-slice", "criteria": [ "4@x" ], "noReconstruction": true } ]Results (prettified and summarized):
Query: static-slice (5 ms)
╰ Slice "4@x"
╰ Id List: {9, 0, 2, 1}
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
The JSON contains the ids of the nodes in question (see the Interface wiki page).
{"static-slice":{".meta":{},"results":{"4@x":{"slice":{"timesHitThreshold":0,"result":[9,0,2,1],"slicedFor":[9],"freeNames":[],".meta":{}}}}},".meta":{}}Likewise, if you want the forward slice for the first use of x, you can do it like this:
[ { "type": "static-slice", "criteria": [ "1@x" ], "direction": "forward" } ](This can be shortened to @static-slice (1@x)f "x <- 1\ny <- 2\nz <- 3\nx" when used with the REPL command :query).
Results (prettified and summarized):
x <- 1
x
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
The JSON contains the ids of the nodes in question (see the Interface wiki page).
{"static-slice":{".meta":{},"results":{"1@x":{"slice":{"timesHitThreshold":0,"result":[0,2,9],"slicedFor":[0],"freeNames":[],".meta":{}},"reconstruct":{"code":"x <- 1\nx","files":[{"code":"x <- 1\nx"}],"linesWithAutoSelected":0,".meta":{}}}}},".meta":{}}If your program pulls in other files with source(...), the inlineSources flag splices the reconstruction
of each resolvable sourced file into the place of its source() call, so the slice becomes a single
self-contained R text (cyclic or unresolvable source() calls are kept verbatim and reported via
reconstruct.inlineWarnings). With the :query REPL command you append an i to the
criteria (and may combine it with the forward f as fi), for example (with a faked library.R providing greeting):
[ { "type": "static-slice", "criteria": [ "2@print" ], "inlineSources": true } ](This can be shortened to @static-slice (2@print)i "source("library.R")\nprint(greeting)" when used with the REPL command :query).
Results (prettified and summarized):
greeting <- "hello"
print(greeting)
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
The JSON contains the ids of the nodes in question (see the Interface wiki page).
{"static-slice":{".meta":{},"results":{"2@print":{"slice":{"timesHitThreshold":0,"result":[7,5,"library.R:1:1-0",3,"library.R:1:1-2","library.R:1:1-1",1],"slicedFor":[7],"freeNames":[],".meta":{}},"reconstruct":{"code":"greeting <- \"hello\"\nprint(greeting)","linesWithAutoSelected":0,"inlineWarnings":[],".meta":{}}}}},".meta":{}}You can disable magic comments using the noMagicComments flag.
This query replaces the old request-slice message.
Implementation Details
The Static Slice Query is executed by executeStaticSliceQuery.
Currently maintained by Florian Sihler and Oliver Gerstl at Ulm University
Email | GitHub | Penguins | Portfolio
- 🧑💻 Developer Onboarding
- 💻 Setup
- 👓 Overview
- 🪟 Interfacing with flowR
- 🌋 Core
- 🧹 Testing & Linting (Benchmark Page)
⁉️ FAQ- ℹ️ Extra Information