Class SymbolUri
The addresses of symbols: what a module, and what a member of anything, is identified by (Uri).
public static class SymbolUri
- Inheritance
-
SymbolUri
- Inherited Members
Remarks
A module is addressed under the root of the project it is part of, by its name, as the fragment: file:///C:/Work/Battleship#GameBoard. A member of
anything is addressed under it, its name appended to the fragment after a dot: file:///C:/Work/Battleship#GameBoard.Reset. The language server and
the environment host address the same symbol by the same Uri, and a symbol's address is its identity (SemanticId).
No two declarations of a module have one address. Where a module may declare a name twice, one of the two has a suffix after its name: a ] that closes
no [, then the reserved word of what it declares. An identifier is letters, digits and underscores (MS-VBAL §3.3.5); a foreign name
(§3.3.5.3) may have brackets of its own, and each ] of it closes a [ before it ([a[b]c] is named a[b]c):
- a
Property Letand aProperty SetareItem]LetandItem]Set, beside theirProperty Get,Item; - an Enum, a Type and an Event are
PlayerType]Enum,Point]TypeandChanged]Event, beside a variable, a constant or a procedure of the name (MS-VBAL §5.2.3.1 to §5.2.3.4, §5.2.4.3).
What such a symbol declares is addressed under that: GameBoard.PlayerType]Enum.HumanControlled, GameBoard.Item]Let.value. A name is read off
an address with NameOf(Uri), and a symbol is shown with QualifiedNameOf(Uri), which leave the suffixes out. A name may be the suffix's word
itself (a field of a Type named Type, Excel's Worksheet.Type): only what follows the ] that closes no [ is a suffix.
This is the one place the rule is written: a symbol, the descriptors of symbols on the wire, and every component that names a module address them with it.
Properties
RootComparer
Compares addresses by their root, as SameRoot(Uri, Uri) does: what keys a project by its root, whichever address of it is given.
public static IEqualityComparer<Uri> RootComparer { get; }
Property Value
Methods
Member(Uri, string)
The address of a symbol that is a member of another - a procedure of a module, a variable of a procedure, a field of a type - or of a module, when the parent is the root of a project or a library.
public static Uri Member(Uri parent, string name)
Parameters
parentUriThe address of the symbol it is a member of, or the root of its project or library.
namestringIts name.
Returns
Module(string, string)
The address of a module, under the root of its project given as a path or a URI (Root(string)).
public static Uri Module(string workspaceRoot, string moduleName)
Parameters
workspaceRootstringThe root of the module's project: an absolute path, or an absolute URI.
moduleNamestringThe module's name, as its
Attribute VB_Namesays.
Returns
Exceptions
- ArgumentException
The root is neither an absolute path nor an absolute URI.
Module(Uri, string)
The address of a module: the root of its project, with its name as the fragment.
public static Uri Module(Uri workspaceRoot, string moduleName)
Parameters
workspaceRootUriThe root of the module's project.
moduleNamestringThe module's name, as its
Attribute VB_Namesays.
Returns
ModuleNameOf(Uri)
The name of the module a symbol is addressed under (Module(Uri, string)): the first name of its path (PathOf(Uri)), as the module's name was written, and not as an address escapes it.
public static string ModuleNameOf(Uri symbol)
Parameters
symbolUriThe address of a module, or of any symbol declared in one.
Returns
- string
The module's name, or an empty string for the root of a project or a library.
Remarks
A module's name is an identifier (MS-VBAL §4.2), which has no dot (MS-VBAL §3.3.5): whatever follows the first one is the path of a member.
Exceptions
- ArgumentException
symbolis a relative URI.
NameOf(Uri)
The name of the symbol an address is of: the last name of its path (PathOf(Uri)), without the suffix that tells the symbol from a namesake of
its module (Item]Let for a Property Let, PlayerType]Enum for an Enum), as the name was written.
public static string NameOf(Uri symbol)
Parameters
symbolUriThe address of a symbol.
Returns
- string
The symbol's name, or an empty string for the root of a project or a library.
Remarks
A name read from an address is read with this, not by splitting the path: GameBoard.PlayerType]Enum is the address of PlayerType, and
GameBoard.PlayerType]Enum.Human of Human.
Exceptions
- ArgumentException
symbolis a relative URI.
PathOf(Uri)
Where a symbol is in its project or library, as its address has it: the names of the module and of each member down to the symbol, joined by dots
(GameBoard.Reset.Count), as they were written, and not as an address escapes them.
public static string PathOf(Uri symbol)
Parameters
symbolUriThe address of a symbol, or the root of a project or a library.
Returns
- string
The symbol's path, or an empty string for a root.
Remarks
Fragment is escaped: the address of Modèle has the fragment #Mod%C3%A8le. A name read from it is unescaped, and a name
compared with one, shown, or looked up is read with this, not from the fragment.
A relative URI addresses no symbol: every symbol is addressed under the absolute root of its project or library (Root(string)), and a relative one reaching this is a mistake of whatever made it, which is not covered up as an empty name.
Exceptions
- ArgumentException
symbolis a relative URI.
ProjectRootOf(Uri)
The root a symbol is addressed under: its address without the fragment, which is the root of its project or library (Module(Uri, string)).
public static Uri ProjectRootOf(Uri symbol)
Parameters
symbolUriThe address of a symbol, or the root of a project or a library.
Returns
- Uri
The root.
Remarks
The root of a root is the root itself.
Exceptions
- ArgumentException
symbolis a relative URI.
QualifiedNameOf(Uri)
A symbol as code names it, from its module down: the names of its path (PathOf(Uri)), without the suffixes that tell a symbol from a namesake
(NameOf(Uri)). GameBoard.PlayerType]Enum.Human is GameBoard.PlayerType.Human, and Cls.Item]Let.value is
Cls.Item.value.
public static string QualifiedNameOf(Uri symbol)
Parameters
symbolUriThe address of a symbol.
Returns
- string
The symbol's qualified name, or an empty string for the root of a project or a library.
Remarks
What is shown of a symbol is this; what identifies it is its address. Two namesakes of a module (an Enum and a Property Get of one name) have one qualified name and two addresses.
Exceptions
- ArgumentException
symbolis a relative URI.
Root(string)
The root of a project, given as a path or as a URI of any scheme: what the modules of the project are addressed under.
public static Uri Root(string workspaceRoot)
Parameters
workspaceRootstringAn absolute path, or an absolute URI.
Returns
Remarks
A path and a file URI of the same folder are the same root, however the URI escapes its path: file:///c%3A/Work, as a client may write
it (LSP 3.17 §URI), is the root c:\Work is.
A URI of another scheme is the root as it is: a client's documents need not be files (untitled:Untitled-1).
The root of a path is written as its file URI (file:///tmp/Work), never as the path: a root travels between the platform's components
(DefineSymbolsParams.WorkspaceRoot) as the text it is written with, and the text of a path is read back as a relative URI where a path begins with
/, which addresses nothing.
Exceptions
- ArgumentException
The root is neither: a relative path addresses nothing until it is said what it is relative to.
RootOf(Uri, string?)
The root the module of a document is addressed under: the root of the project it is part of, or the document's own address when it is part of none.
public static Uri RootOf(Uri document, string? workspaceRoot)
Parameters
documentUriThe address of the document, as the client gives it.
workspaceRootstringThe root of the workspace, as a path or a URI; empty when the server has no workspace.
Returns
Remarks
A file is part of the project of the workspace, wherever it is: a document a client opens from outside the workspace's folder is compiled with the
workspace's modules, as a program a shell loads is. A document that is no file - one the client holds and has not saved, untitled:Untitled-1 - is
part of no project, and so is any document of a server that has no workspace: it is a project of its own, addressed under its own URI, which no module of
a workspace is.
SameRoot(Uri, Uri)
Whether two addresses are under the same root (ProjectRootOf(Uri)): whether the symbols are of one project or library.
public static bool SameRoot(Uri left, Uri right)
Parameters
leftUriThe address of a symbol, or a root.
rightUriThe address of another symbol, or another root.
Returns
- bool
Whether the roots are the same.
Remarks
Two file roots compare as the paths of the platform do (Comparison): on Windows, a client may write the drive or a folder of the
same root in another case (file:///c:/Work, file:///C:/Work), and both name one folder. A root of any other scheme compares as it is written.
Equals(object) cannot say so: it ignores the fragment, so the addresses of two modules of a project are equal by it, and it compares the path as it is written.
Exceptions
- ArgumentException
Either is a relative URI.