Class ProjectFileLoader
Loads a workspace's .rdproj ProjectFile from disk, read-only. Every platform
component that needs the project structure — the language server's workspace services and the
environment host's session composition — resolves the project through this service so there is a
single deserialization path.
public sealed class ProjectFileLoader : IProjectFileLoader
- Inheritance
-
ProjectFileLoader
- Implements
- Inherited Members
Constructors
ProjectFileLoader(IFileSystem)
Loads a workspace's .rdproj ProjectFile from disk, read-only. Every platform
component that needs the project structure — the language server's workspace services and the
environment host's session composition — resolves the project through this service so there is a
single deserialization path.
public ProjectFileLoader(IFileSystem fileSystem)
Parameters
fileSystemIFileSystem
Methods
LoadAsync(string, CancellationToken)
Loads and deserializes the .rdproj under workspaceRoot, stamping its
Uri with the workspace root everything else is relative to.
public Task<ProjectFile> LoadAsync(string workspaceRoot, CancellationToken token = default)
Parameters
workspaceRootstringThe absolute path of the workspace root directory.
tokenCancellationTokenA token that cancels the read.
Returns
Exceptions
- FileNotFoundException
No
.rdprojexists under the workspace root.- InvalidDataException
The
.rdprojis not JSON; the message says where it stops being JSON.- InvalidOperationException
The
.rdprojcould not be deserialized.
LoadOrSynthesizeAsync(string, SupportedLanguage, CancellationToken)
Loads the .rdproj under workspaceRoot as LoadAsync(string, CancellationToken) does, or, when the folder has none, makes up the project
the folder holds (IsSynthesized): every source file of language under it is a module, and nothing is
written.
public Task<ProjectFile> LoadOrSynthesizeAsync(string workspaceRoot, SupportedLanguage language, CancellationToken token = default)
Parameters
workspaceRootstringThe absolute path of the workspace root directory.
languageSupportedLanguageThe language the workspace is written in, whose FileTypes are its source files.
tokenCancellationTokenA token that cancels the read.
Returns
Remarks
A client that opens a folder - rather than a project - is given the project the folder is. The folder is searched to every depth, except the folders
whose name starts with a dot (.git, .vscode) and links to other folders. Each folder that holds a module, at any depth, is a folder of the
project. Paths are relative to the workspace root, separated by /, and in ordinal order, so the language server and the environment host, which
each synthesize the project, make up the same one.
A module name is unique in a project (RD-VBAL §2.2.3.3): of two files that declare the same VB_Name, the first in that order
is the module, and the other is not in the project. The project is named after the folder when its name is an identifier, and VBAProject
otherwise, as the VBE names a new one.
Exceptions
- InvalidDataException
The
.rdprojis not JSON; the message says where it stops being JSON.- InvalidOperationException
The
.rdprojcould not be deserialized.
TryLocate(string, out string)
Resolves the path a .rdproj would occupy under workspaceRoot and
reports whether a file exists there.
public bool TryLocate(string workspaceRoot, out string projectFilePath)
Parameters
workspaceRootstringThe absolute path of the workspace root directory.
projectFilePathstringThe resolved
.rdprojpath, whether or not it exists.
Returns
- bool
trueif a file exists atprojectFilePath.