Short description
Correctly configure project scope of a library, and limit library to externally visible scopes.
Problem description.
Currently, Statix provides a menu option to export scope graph libraries, which can subsequently be imported by other projects. However, the exported scope graphs have five important deficiencies:
The project root scope is added to the second list of scopes, instead of to the first one.
The project root scope has a datum set. This is incorrect, because, at library consumer analysis time, the project type checker (not the library type checker) will set the datum of that scope.
Scope graph libraries also contain declarations made by the projectOk constraint. These will be duplicated once the library is used.
Scope graph libraries also contain the 'local' parts of the scope graph (i.e. the parts that are not reachable from outside). These segments are useless, but still consume disk space, memory and might increase library query execution time.
Describe the solution you'd like
To solve these problems, we should include the project root scope in the ProjectResult. On export, that will allow adding it to the list of shared scopes of the library, and avoid setting the datum.
Addintionally, we can filter out all scopes with the same resource as the project root scope, which effectively removes all declarations from the projectOk constraint.
The fourth problem can be solved by transitively traversing the edges and data of all scopes reachable from the root scope, and only including these scopes in the final library.
Short description Correctly configure project scope of a library, and limit library to externally visible scopes.
Problem description. Currently, Statix provides a menu option to export scope graph libraries, which can subsequently be imported by other projects. However, the exported scope graphs have five important deficiencies:
projectOk
constraint. These will be duplicated once the library is used.Describe the solution you'd like To solve these problems, we should include the project root scope in the
ProjectResult
. On export, that will allow adding it to the list of shared scopes of the library, and avoid setting the datum. Addintionally, we can filter out all scopes with the same resource as the project root scope, which effectively removes all declarations from theprojectOk
constraint. The fourth problem can be solved by transitively traversing the edges and data of all scopes reachable from the root scope, and only including these scopes in the final library.Additional context The manual solution to the first two steps in described in https://www.spoofax.dev/howtos/statix/migrating-to-concurrent-solver/#using-libraries.