Skip to content

Static analysis of exportPattern() directives #8520

@lionel-

Description

@lionel-

Follow-up to #1325 and posit-dev/ark#870.

We now examine the DESCRIPTION and NAMESPACE files of a package to statically determine its exports, but we don't support the exportPattern() NAMESPACE directive yet, which exports all symbols matching a regex.

It's tricky because packages are installed without their source code, which means we can't statically discover what objects are defined in a namespace. To do this, we'll need access to the source code of the project dependencies: #2286. Then we'll be able to:

  • Parse the source code and detect all top-level assignments

  • For dynamic assignments, packages will have to declare the symbols:

    # Declaration
    foo <- function(my, signature) {}
    
    .onLoad <- function(...) {
      # Dynamic definition. This case is analysable in principle but the namespace
      # might be modified in more complex ways, e.g. via `.Call()`, hence the need
      # for declarations in general
      foo <<- function(my, signature) body
    }
  • Apply export pattern to known namespace objects

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions