Skip to content

Trigger known packages! #2072

@EagleoutIce

Description

@EagleoutIce

Consider:

library(ggplot2)

ggplot()

I want a reads | calls edge from ggplot to the ggplot2 library if we know that ggplot2 exports the ggplot function. Additionally, I want to add the information to ggplot, that it comes from the ggplot2 package.
So in other words, we want to link calls from package functions to the package that provides them.

This information is provided by the dependencies context.

Please note: Right now, flowR does not have dependencies for packages loaded (this is the step after this one with which we include the results from crawlR) so whenever you want to test this, you have to tell flowR what every package is exporting (but just for the tests, for this you can have a look at the namespace file tests which we already have.

It should mainly work like this: in the built-in-library handler:

export function processLibrary<OtherInfo>(
name: RSymbol<OtherInfo & ParentInformation>,
args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[],
rootId: NodeId,
data: DataflowProcessorInformation<OtherInfo & ParentInformation>
): DataflowInformation {
/* we do not really know what loading the library does and what side effects it causes, hence we mark it as an unknown side effect */

I want access knowledge that we have about this package (with the dependencies context of the flowr analyzer context). Similar to assignments

information.environment = define(nodeToDefine, assignmentConfig?.superAssignment, information.environment);

this should add the exported variables to the current environment. In other words, if we know ggplot2 exports ggplot, the built-in library handler with library(ggplot2) should assign ggplot to point to the package (i.e., add an according Identifier Definition). Then, every variable use of ggplot etc. should link to this definition (you can set definedAt to built-in:ggplot when defining it in the environment).

Metadata

Metadata

Assignees

Labels

dataflowRelated to dataflow extractionenhancementNew feature or request
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions