Table of Contents

Class RDCoreDocument

Namespace
RDCore.SDK.Workspace
Assembly
RDCore.SDK.dll

A source file and the modules it holds: its own module, which is what is outside every block, and the module of each of its blocks (BlockModules).

public sealed record RDCoreDocument : IEquatable<RDCoreDocument>
Inheritance
RDCoreDocument
Implements
Inherited Members

Remarks

A client edits files, and the platform compiles modules. A file of one module is its own module, addressed by the file's URI. A block's module is addressed under it, by the file's URI with the module's name as one more segment (BlockUri(Uri, string)): file:///c:/ws/Backup.vbs/Logger. That is no file on disk, so what is decided by a file (its language, whether it is a script, the extension it has) is decided by the file the module is in (FileOf(string)).

Constructors

RDCoreDocument(Uri, ModuleParseResult)

A source file and the modules it holds: its own module, which is what is outside every block, and the module of each of its blocks (BlockModules).

public RDCoreDocument(Uri File, ModuleParseResult Parse)

Parameters

File Uri

The file's URI.

Parse ModuleParseResult

The file's parse: its own module, and its blocks' modules.

Remarks

A client edits files, and the platform compiles modules. A file of one module is its own module, addressed by the file's URI. A block's module is addressed under it, by the file's URI with the module's name as one more segment (BlockUri(Uri, string)): file:///c:/ws/Backup.vbs/Logger. That is no file on disk, so what is decided by a file (its language, whether it is a script, the extension it has) is decided by the file the module is in (FileOf(string)).

Properties

File

The file's URI.

public Uri File { get; init; }

Property Value

Uri

ModuleUris

The address of every module of the file: the file's own first, then each block's, in the order they are written.

public IEnumerable<Uri> ModuleUris { get; }

Property Value

IEnumerable<Uri>

Parse

The file's parse: its own module, and its blocks' modules.

public ModuleParseResult Parse { get; init; }

Property Value

ModuleParseResult

Methods

BlockUri(Uri, string)

The address of the module a block of a file declares: the file's address, with the module's name as one more segment.

public static Uri BlockUri(Uri file, string name)

Parameters

file Uri

The file's URI.

name string

The module's name, as the block's header writes it.

Returns

Uri

The module's URI, file:///c:/ws/Backup.vbs/Logger for the module Logger of Backup.vbs.

Exceptions

ArgumentNullException

file or name is null.

ArgumentException

name is empty.

FileOf(string)

The path of the file a module is in: the path of the file of a block's module (BlockUri(Uri, string)), and the path itself otherwise.

public static string FileOf(string path)

Parameters

path string

The module's path, or its URI's path; / and </code> both separate segments.

Returns

string

The file's path; path itself when it is the path of a file.

Remarks

A path is a block's module's when its last segment has no extension (a module's name has none) and the segment before it is a file of one of the languages the platform serves (FileTypes, ModuleFileTypes). A file without an extension in a folder named as such a file is read as a block's module too.

Exceptions

ArgumentNullException

path is null.

FileOf(Uri)

The file a module is in: the file of a block's module (BlockUri(Uri, string)), and the module's own address otherwise.

public static Uri FileOf(Uri module)

Parameters

module Uri

The address of the module.

Returns

Uri

The URI of the file that holds the module.

Exceptions

ArgumentNullException

module is null.

KindOf(Uri)

The kind of one of the file's modules: a block's module is its block's (Kind), and the file's own module is read from the file's parse (Of(ModuleParseResult, string?)): a class module when the file has a VERSION header or a designer, or is the code of an RDForms form, and a standard module otherwise.

public ModuleType? KindOf(Uri module)

Parameters

module Uri

The address of the module: the file's (File), or a block's (BlockUri(Uri, string)).

Returns

ModuleType?

The module's kind; null when the file holds no module at that address. When two blocks have one name, the first block's.

Remarks

A document holds no project entry, so a host's document module reads as its header says. A host that has the project and the text asks Of(RDCoreModule?, string?), which knows a document module.

ModuleAt(SourcePosition)

The module a position of the file is in: the block whose range holds it, its end included, and the file's own module otherwise.

public Uri ModuleAt(SourcePosition position)

Parameters

position SourcePosition

A position in the file.

Returns

Uri

The address of the module: a block's (BlockUri(Uri, string)), or the file's.

NameOf(Uri)

The name of one of the file's modules, as RD-VBA names a module (MS-VBAL §4.2). The file's own module is named by its Attribute VB_Name (GetDeclaredName(ModuleNode)), or by the file's name without its extension when it declares none or could not be read (FromFileName(string)), as Resolve(string, string) names it from the file's text. A block's module is named by its header (Name).

public string? NameOf(Uri module)

Parameters

module Uri

The address of the module: the file's (File), or a block's (BlockUri(Uri, string)).

Returns

string

The module's name; null when the file holds no module at that address. When two blocks have one name, the first block's.

ParseOf(Uri)

The parse of one of the file's modules: its tree, and what of the file's trivia, directives and syntax errors is that module's.

public ModuleParseResult? ParseOf(Uri module)

Parameters

module Uri

The address of the module: the file's (File), or a block's (BlockUri(Uri, string)).

Returns

ModuleParseResult

The module's parse; null when the file holds no module at that address. When two blocks have one name, the first block's.

Remarks

The file's parse holds the trivia (Trivia), the directives (PrecompilerTrivia) and the syntax errors (SyntaxErrors) of all its modules. An item is the module's whose lines hold its start: a block's module has the lines between its header and its end, and the comment lines directly above its header, which hold the annotations of the block's module (GetHeaderAnnotations(ModuleParseResult)). Those comment lines end, going up from the header, at a blank line, a line of code (a comment written after code included), a directive's line, or a line of another block, its header and its end line included. The file's own module has every other line. An item that runs on past the module's lines (a #If left open) is still the module's it starts in. The header and the end lines of a block (BlockBoundaryTriviaNode) are the file's, and no module's: a comment on either is the file's own module's. Positions are the file's, as in the file's parse.

A block's module has the file's LineEnding, and no Designer; the file's own module has the file's line ending and designer. Neither has BlockModules. A block's module has its block's range (BlockRange), and the file's own module none. A file with no block has the file's parse as its own module's.

SyntaxTreeOf(Uri)

The tree of one of the file's modules.

public ModuleNode? SyntaxTreeOf(Uri module)

Parameters

module Uri

The address of the module: the file's, or a block's.

Returns

ModuleNode

The module's tree; null when the file holds no module at that address, or its own module could not be read.