Open parlough opened 1 month ago
Some notes:
Summary: allows the analyzer to load all of the code across a monorepo as an individual package, as opposed to blown up memory usage analyzing for every different package
How to: workspace
field in pubspec indicates this is a workspace, so analyzer analyzes globally.
(Also an IDE configuration option?)
Right after this section might be a good place to caveat that if you enable a workspace, what analysis_options.yaml applies to what packages would be different (?):
It's mentioned early in the page that not using the workspace feature causes bloated analysis contexts:
If you open the root folder in your IDE, the dart analyzer will have to have separate analysis contexts for each package (increasing memory usage).
Later somewhere it should mention how the analysis context problem changes on pub workspaces are enabled.
Maybe at the end of the "To create a workspace" section, after "Now the file structure looks like this:"
Or maybe a small section titled "Analysis context in a workspace" that briefly explains how one can expect their workspace to be handled by the analyzer, and the benefits of that.
Does this need updating for analysis context changes?
An analysis context is a representation of a set of code that should be analyzed using the same sources of metadata (same package_spec.json file, same analysis options file, etc.). That set of code typically corresponds to a package.
-- Is this still true? Analysis contexts can be wider now in a workspace, and I think they don't necessarily use the same analysis options file (or they do, but it's multiple files now?).
Also, an analysis context can correspond to multiple packages, not just a package, now.
Each analysis session is associated with a single analysis context...
-- Now that the nature of analysis contexts has changed, is this still true?
AnalysisContextCollection
-- Instead of using this, would it be easier to use workspaces to account for a wider context? Kind of sounds like they address the same goal (or i'm mixing up "files" vs. "packages")
The page talks a lot about analyzing collections of files; does any of that change/have a better solution now with the changes to analyzer contexts?
Related issue: https://github.com/dart-lang/site-www/issues/5891
References relating to multi-option contexts and workspaces: