Class FileBlocks
Finds the modules a source file declares in blocks, besides its own module: a file may hold several modules, in any dialect.
public static class FileBlocks
- Inheritance
-
FileBlocks
- Inherited Members
Remarks
A block starts on a line that holds Class or Module and the module's name, and nothing else but a comment and the header's modifiers,
and ends on the first line after it that holds the end of its kind (End Class for a Class block, End Module for a
Module block). Blocks do not nest: a header inside a block is the block's code. A header that no matching end follows starts no block. A
line that continues the line before it ( _) is neither a header nor an end. What is outside every block is the file's own module. A
block's name is the name its header writes: an Attribute VB_Name inside it does not rename it, and is not the file's own module's either
(FromSource(string?)).
The modifiers come before the kind, each at most once and in this order: a visibility, Public or Private
(Visibility), then Partial (IsPartial), then, for a Class block only,
Creatable (IsCreatable), as in Public Partial Creatable Class Name. Keywords are read in any case. A line
that writes the modifiers in another order, a modifier twice, a modifier after the kind, Creatable before Module, or another
visibility (Friend, Global) is not a header.
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
Returns
- Uri
The module's URI,
file:///c:/ws/Backup.vbs/Loggerfor the moduleLoggerofBackup.vbs.
Exceptions
- ArgumentNullException
fileornameis null.- ArgumentException
nameis 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
pathstringThe module's path, or its URI's path;
/and</code> both separate segments.
Returns
- string
The file's path;
pathitself 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
pathis 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
moduleUriThe address of the module.
Returns
- Uri
The URI of the file that holds the module.
Exceptions
- ArgumentNullException
moduleis null.
Find(string?)
The blocks of source, in the order they are written.
public static IReadOnlyList<FileBlock> Find(string? source)
Parameters
Returns
- IReadOnlyList<FileBlock>
The file's blocks; empty when it declares none.