diff --git a/src/core/slicer.ts b/src/core/slicer.ts index e026533993..e132dd357e 100644 --- a/src/core/slicer.ts +++ b/src/core/slicer.ts @@ -208,7 +208,7 @@ export class SteppingSlicer, 'dataflow': { description: 'Construct the dataflow graph', - processor: a => produceDataFlowGraph(a), + processor: (r, a) => produceDataFlowGraph(r, a), required: 'once-per-file', printer: { [StepOutputFormat.Internal]: internalPrinter, diff --git a/src/dataflow/extractor.ts b/src/dataflow/extractor.ts index 3a05026fc3..49c6b5929f 100644 --- a/src/dataflow/extractor.ts +++ b/src/dataflow/extractor.ts @@ -1,4 +1,4 @@ -import type { NormalizedAst, ParentInformation, RAssignmentOp, RBinaryOp} from '../r-bridge' +import type {NormalizedAst, ParentInformation, RAssignmentOp, RBinaryOp, RParseRequest} from '../r-bridge' import { RType } from '../r-bridge' import type { DataflowInformation } from './internal/info' import type { DataflowProcessorInformation, DataflowProcessors} from './processor' @@ -48,13 +48,13 @@ const processors: DataflowProcessors = { [RType.ExpressionList]: processExpressionList, } -export function produceDataFlowGraph(ast: NormalizedAst, initialScope: DataflowScopeName = LocalScope): DataflowInformation { +export function produceDataFlowGraph(request: RParseRequest, ast: NormalizedAst, initialScope: DataflowScopeName = LocalScope): DataflowInformation { return processDataflowFor(ast.ast, { completeAst: ast, activeScope: initialScope, environments: initializeCleanEnvironments(), processors: processors as DataflowProcessors, - currentPath: 'initial', + currentRequest: request, sourceReferences: new Map() }) } diff --git a/src/dataflow/internal/process/functions/source.ts b/src/dataflow/internal/process/functions/source.ts index 6766509b3b..247ce91ed7 100644 --- a/src/dataflow/internal/process/functions/source.ts +++ b/src/dataflow/internal/process/functions/source.ts @@ -30,7 +30,7 @@ export function processSourceCall(functionCall: RFunctionCall(functionCall: RFunctionCall - const dataflow = processDataflowFor(normalized.ast, {...data, currentPath: path, environments: information.environments}) + const dataflow = processDataflowFor(normalized.ast, {...data, currentRequest: request, environments: information.environments}) // update our graph with the sourced file's information const newInformation = {...information} diff --git a/src/dataflow/processor.ts b/src/dataflow/processor.ts index 8672b746c0..b4388a95e0 100644 --- a/src/dataflow/processor.ts +++ b/src/dataflow/processor.ts @@ -4,7 +4,7 @@ import type { NormalizedAst, ParentInformation, RNode, - RNodeWithParent + RNodeWithParent, RParseRequest } from '../r-bridge' import type { DataflowInformation } from './internal/info' import type { DataflowScopeName, REnvironmentInformation } from './environments' @@ -27,8 +27,7 @@ export interface DataflowProcessorInformation { * Other processors to be called by the given functions */ readonly processors: DataflowProcessors - // TODO using "initial" as the default path doesn't allow us to skip re-sourcing the initial file - how do we find out the initial file's name/path? - readonly currentPath: string | 'initial' + readonly currentRequest: RParseRequest readonly sourceReferences: Map }