We want to implement a feature that allows the various features of Biome to tap into information regarding other files. At the moment, features like lint rules don't have access to information that belongs to other files. Some examples are exported bindings, exported types, types of modules, etc.
An entity we could call Project
(the name is not set in stone) should provide this kind of information.
Following, I will list some design aspects of the feature, which we can discuss. Don't take everything as set in stone, but assimilate it and then debate it. I will try to do my best to outline the current archicture as best as I can.
First, the architecture should follow this principle:
- Build for generic clients. Donβt assume that a terminal will only consume output using ANSI codes. Use abstractions that could be generalized for viewing in an IDE, browser, or other environments.
At the moment, we have the current actors at play:
FileSystem
trait. A generic trait meant to crawl the file system and evaluate if certain paths (directories, files, symbolic links, etc.) should be checked. Two types implement this trait OsFileSystem
and MemoryFileSystem
. The FileSystem
doens't know which files should be handled. The logic that checks if those paths can be handled is implemented elsewhere via another trait called TraversalContext
. As you can see, we are going elsewhere. OsFileSystem
, however, has an interner for paths, but it isn't related to the paths checked.WorkspaceServer
can be seen as our query compiler. The end consumer (e.g. CLI or LSP) has control over the compiler and tells it what to do. The WorkspaceServer
has some characteristics:
ProjectData
is already in use. It knows that a client might have different projects with different settings:biome/crates/biome_service/src/settings.rs
Lines 52 to 57 in eafc62e
The FileSystem
and the WorkspaceServer
rarely interact with each other. The only moment when they is for just one operation: fs.open_file
-> workspace.open_file
I envision the Project
to be part of the WorkspaceServer
. If so, Project
must be Send
, Sync
and RefUnwindSafe
. This means that we need to choose data that meets those criteria.
Fortunately, a module graph can be built with petgraph
, which implements these traits.
A Project
shouldn't duplicate the information that are already present in the WorkspaceServer
, e.g. file content, CST.
Here are some ideas that we should consider while implementing the architecture:
From a CLI perspective, a way to build a Project
and its graph is by doing two passes of the file system.
One pass to collect all files. A second pass to check the files. After the first pass it could be possible build the Project
we require.
The second pass is more challenging because, between the first pass and the second pass, we don't have an entity that will tell the WorkspaceServer
which files should be checked. Should we create one? Should we extend FileSystem
to tell us? Let's discuss it
From the LSP perspective, it's easier to initialise a new Project
, but it will be more challenging to update it. Every time a file is updated/created/deleted, the graph should be updated.
Here, Jeroen Engels, creator of elm-review
, explains how he does multi-file analysis inside the linter: https://jfmengels.net/multi-file-analysis/ .
However, let's take into consideration that we have different constraints and requirements.
I haven't talked about dependencies. Dependencies will be part of the graph, but they can be added later one, as we need a manifest to collect them (which we already have).
Project
inside biome_project
(Feel free to add more tasks if you think they are needed)
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too