Builder for the FlowrAnalyzer, use it to configure all analysis aspects before creating the analyzer instance with .build() or .buildSync().

You can add new files and folders to analyze using the .addRequest() method on the resulting analyzer.

const analyzer = new FlowrAnalyzerBuilder()
.setParser(new TreeSitterExecutor())
.buildSync()
.addRequest('file:///path/to/script.R')

If you now want to get the dataflow information for the file, you can do this:

const dfInfo = await analyzer.dataflow();
console.log(dfInfo);

Constructors

Methods

  • Apply an amendment to the configuration the builder currently holds. Per default, the defaultConfigOptions are used.

    Parameters

    • func: (
          config: {
              abstractInterpretation: {
                  dataFrame: {
                      maxColNames: number;
                      readLoadedData: { maxReadLines: number; readExternalFiles: boolean };
                  };
                  wideningThreshold: number;
              };
              defaultEngine?: "r-shell"
              | "tree-sitter";
              engines: (
                  | { rPath?: string; type: "r-shell"; [key: string]: unknown }
                  | {
                      lax?: boolean;
                      treeSitterWasmPath?: string;
                      type: "tree-sitter";
                      wasmPath?: string;
                      [key: string]: unknown;
                  }
              )[];
              ignoreSourceCalls: boolean;
              project: { resolveUnknownPathsOnDisk: boolean };
              repl: { dfProcessorHeat: boolean; quickStats: boolean };
              semantics: {
                  environment: {
                      overwriteBuiltIns: {
                          definitions: (
                              | {
                                  assumePrimitive?: boolean;
                                  names: Identifier[];
                                  type: "constant";
                                  value: unknown;
                              }
                              | {
                                  assumePrimitive?: boolean;
                                  config: { readIndices: boolean };
                                  names: Identifier[];
                                  suffixes: ("<-" | "<<-")[];
                                  type: "replacement";
                              }
                              | {
                                  assumePrimitive?: boolean;
                                  config?: | {
                                      forceFollow?: (...)
                                      | (...)
                                      | (...);
                                      includeFunctionCall?: (...) | (...) | (...);
                                      libFn?: (...) | (...) | (...);
                                  }
                                  | {
                                      forceArgs?: (...)
                                      | (...)
                                      | (...);
                                      libFn?: (...) | (...) | (...);
                                      treatIndicesAsString: boolean;
                                  }
                                  | {
                                      indexOfFunction?: (...)
                                      | (...);
                                      libFn?: (...) | (...) | (...);
                                      nameOfFunctionArgument?: (...) | (...);
                                      resolveInEnvironment?: (...) | (...) | (...);
                                      resolveValue?: (...) | (...) | (...);
                                      unquoteFunction?: (...) | (...) | (...);
                                      [key: string]: unknown;
                                  }
                                  | {
                                      canBeReplacement?: (...)
                                      | (...)
                                      | (...);
                                      forceArgs?: (...) | (...) | (...);
                                      indicesCollection?: (...) | (...);
                                      libFn?: (...) | (...) | (...);
                                      makeMaybe?: (...) | (...) | (...);
                                      mayHaveMoreArgs?: (...) | (...) | (...);
                                      quoteSource?: (...) | (...) | (...);
                                      superAssignment?: (...) | (...) | (...);
                                      swapSourceAndTarget?: (...) | (...) | (...);
                                      targetVariable?: (...) | (...) | (...);
                                  }
                                  | {
                                      canBeReplacement?: (...)
                                      | (...)
                                      | (...);
                                      forceArgs?: (...) | (...) | (...);
                                      indicesCollection?: (...) | (...);
                                      libFn?: (...) | (...) | (...);
                                      makeMaybe?: (...) | (...) | (...);
                                      mayHaveMoreArgs?: (...) | (...) | (...);
                                      quoteSource?: (...) | (...) | (...);
                                      source: { idx?: ...; name: ... };
                                      superAssignment?: (...) | (...) | (...);
                                      swapSourceAndTarget?: (...) | (...) | (...);
                                      target: { idx?: ...; name: ... };
                                      targetVariable?: (...) | (...) | (...);
                                  }
                                  | {
                                      cfg?: (...)
                                      | (...);
                                      forceArgs?: (...) | (...) | (...);
                                      hasUnknownSideEffects?: (...) | (...) | (...) | (...);
                                      libFn?: (...) | (...) | (...);
                                      readAllArguments?: (...) | (...) | (...);
                                      returnsNthArgument?: (...) | (...) | (...);
                                      treatAsFnCall?: (...) | (...);
                                      useAsProcessor?: (...) | (...);
                                  }
                                  | {
                                      includeFunctionCall?: (...)
                                      | (...)
                                      | (...);
                                      libFn?: (...) | (...) | (...);
                                  }
                                  | { args?: (...)
                                  | (...); libFn?: (...) | (...) | (...) }
                                  | { args: { env: ...; expr: ... }; libFn?: (...) | (...) | (...) }
                                  | {
                                      forceArgs?: (...) | (...) | (...);
                                      libFn?: (...) | (...) | (...);
                                      quoteArgumentsWithIndex?: (...) | (...);
                                  }
                                  | {
                                      args: { add?: ...; after?: ...; expr: ... };
                                      hook: OnFnExit;
                                      libFn?: (...) | (...) | (...);
                                  }
                                  | {
                                      activeIndices?: (...)
                                      | (...);
                                      assignmentOperator?: (...) | (...) | (...);
                                      assignRootId?: (...) | (...);
                                      forceArgs?: (...) | (...) | (...);
                                      libFn?: (...) | (...) | (...);
                                      makeMaybe?: (...) | (...) | (...);
                                      readIndices?: (...) | (...) | (...);
                                  }
                                  | {
                                      args: { generic: ...; object: ... };
                                      libFn?: (...) | (...) | (...);
                                  }
                                  | {
                                      evalRhsWhen: boolean;
                                      forceArgs?: (...)
                                      | (...)
                                      | (...);
                                      lazy: boolean;
                                      libFn?: (...) | (...) | (...);
                                  }
                                  | {
                                      block: string;
                                      handlers: { error?: ...; finally?: ... };
                                      libFn?: (...) | (...) | (...);
                                  };
                                  evalHandler?: string;
                                  names: Identifier[];
                                  processor: | Access
                                  | Apply
                                  | Assignment
                                  | AssignmentLike
                                  | Default
                                  | Eval
                                  | ExpressionList
                                  | ForLoop
                                  | FunctionDefinition
                                  | Get
                                  | IfThenElse
                                  | Library
                                  | List
                                  | Local
                                  | Pipe
                                  | Quote
                                  | RegisterHook
                                  | RepeatLoop
                                  | Replacement
                                  | Rm
                                  | S3Dispatch
                                  | Source
                                  | SpecialBinOp
                                  | StopIfNot
                                  | Try
                                  | Vector
                                  | WhileLoop;
                                  type: "function";
                              }
                          )[];
                          loadDefaults?: boolean;
                      };
                  };
              };
              solver: {
                  evalStrings: boolean;
                  instrument: {
                      dataflowExtractors?: (
                          extractor: DataflowProcessors<ParentInformation>,
                          ctx: FlowrAnalyzerContext,
                      ) => DataflowProcessors<ParentInformation>;
                  };
                  pointerTracking: boolean
                  | { maxIndexCount: number };
                  resolveSource?: {
                      applyReplacements?: { [key: string]: string }[];
                      dropPaths: DropPathsOption;
                      ignoreCapitalization: boolean;
                      inferWorkingDirectory: InferWorkingDirectory;
                      repeatedSourceLimit?: number;
                      searchPath: string[];
                      [key: string]: unknown;
                  };
                  slicer?: { threshold?: number };
                  variables: VariableResolve;
              };
              [key: string]: unknown;
          },
      ) => void
      | FlowrConfigOptions

      Receives the current configuration of the builder and allows for amendment.

    Returns this