Skip to content

Analyzer

github-actions[bot] edited this page Sep 29, 2025 · 1 revision

This document was generated from 'src/documentation/print-analyzer-wiki.ts' on 2025-09-29, 19:41:24 UTC presenting an overview of flowR's analyzer (v2.5.0, using R v4.5.0). Please do not edit this file/wiki page directly.

We are currently working on documenting the capabilities of the analyzer (with the plugins, their loading order, etc.). In general, the code documentation starting with the FlowrAnalyzer and the FlowrAnalyzerBuilder should be the best starting point.

Overview

No matter whether you want to analyze a single R script, a couple of R notebooks, or a complete project, your journey starts with the FlowrAnalyzerBuilder (further described in Builder Configuration below). This builder allows you to configure the analysis in many different ways, for example, by specifying which files to analyze, which plugins to use, or what Engine to use for the analysis.

Note

If you want to quickly try out the analyzer, you can use the following code snippet that analyzes a simple R expression:

const analyzer = await new FlowrAnalyzerBuilder()
    .addRequestFromInput('x <- 1; print(x)')
    .setEngine('tree-sitter')
    .build();
// get the dataflow
const df = await analyzer.dataflow();
// obtain the identified loading order
console.log(analyzer.inspectContext().files.loadingOrder.getLoadingOrder());
// run a dependency query
const results = await analyzer.query([{ type: 'dependencies' }]);

TODO: mention Context

Builder Configuration

TODO also explain buildSync and that TreeSitter has to be initialized for this

Plugins

Plugin Types

During the construction of a new FlowrAnalyzer, plugins of different types are applied at different stages of the analysis. These plugins are grouped by their PluginType and are applied in the following order (as shown in the documentation of the PluginType):

┌───────────┐   ┌───────────────────┐   ┌─────────────┐   ┌───────────────┐   ┌───────┐
│           │   │                   │   │             │   │               │   │       │
│ *Builder* ├──>│ Project Discovery ├──>│ File Loader ├──>│ Dependencies  ├──>│ *DFA* │
│           │   │  (if necessary)   │   │             │   │   (static)    │   │       │
└───────────┘   └───────────────────┘   └──────┬──────┘   └───────────────┘   └───────┘
                                               │                                  ▲
                                               │          ┌───────────────┐       │
                                               │          │               │       │
                                               └─────────>│ Loading Order ├───────┘
                                                          │               │
                                                          └───────────────┘

We describe the different plugin types in more detail below.

Project Discovery

File Loading

Dependency Identification

Loading Order

How to add a new plugin

How to add a new plugin type

Context Information

Files Context

Loading Order Context

Dependencies Context

Analyzer Internals

Clone this wiki locally