Class CompletionCandidates
- Namespace
- RDCore.SDK.Model.Symbols.Completion
- Assembly
- RDCore.SDK.dll
The names a completion list offers, as the scope tree of a composed workspace has them: the names visible from where the list is asked for, the members of a module, a project or a type, and the keywords of the language.
public static class CompletionCandidates
- Inheritance
-
CompletionCandidates
- Inherited Members
Remarks
The names are the ones the resolver would bind (ScopeTreeSymbolResolver): a name declared nearer shadows one of the same name declared farther, and
is the only one offered. What a scope declares that is not a name in the binding context the list is for is not offered - a user-defined type is no value, a
local is no type (MS-VBAL §5.6.4). A member declared Private is offered only where it is accessible, which is in its own module
(MS-VBAL §5.2.3), and a member a library hides (VB_MemberFlags, HiddenMemberFlag) is not offered at all,
as the VBE's own lists leave it out.
A name is offered once whatever the number of its declarations: the Get, the Let and the Set of a property are one property.
Methods
Classes(ScopeTree, Uri)
The classes that can be named where origin is, as the interface of an Implements (MS-VBAL §5.2.4.2) or the type
of a TypeOf ... Is (§5.6.9.8.1): the class modules of the project, and the classes of the libraries.
public static IReadOnlyList<CompletionCandidate> Classes(ScopeTree tree, Uri origin)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
originUriWhere the lookup originates (OriginAt(ScopeTree, Uri, SourcePosition)).
Returns
ConstantsOf(ScopeTree, VBEnumType)
The constants of an Enum, by name: what an argument given to a parameter declared as it is most likely to be (MsgBox "Hello", vbYesNo).
public static IReadOnlyList<CompletionCandidate> ConstantsOf(ScopeTree tree, VBEnumType type)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
typeVBEnumTypeThe
Enum.
Returns
Remarks
A library's Enum carries its constants (MembersOf(VBType)). One the workspace declares does not: its constants are declarations of
the module that declares it, each of them of the Enum (ParentUri), and are found there.
EventsOf(ScopeTree, Uri)
The events the class module that origin is in declares: what a RaiseEvent raises (MS-VBAL §5.4.2.20).
public static IReadOnlyList<CompletionCandidate> EventsOf(ScopeTree tree, Uri origin)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
originUriWhere the lookup originates (OriginAt(ScopeTree, Uri, SourcePosition)).
Returns
ListOf(string, IReadOnlyList<CompletionGroup>, IReadOnlyList<CompletionCandidate>, Position?, string?)
The completion list for the word being typed (LSP 3.17 §Completion Request): the candidates word matches
(MatchOf(string, string)), each label once, the best of them preselected.
public static CompletionList ListOf(string word, IReadOnlyList<CompletionGroup> first, IReadOnlyList<CompletionCandidate> candidates, Position? cursor = null, string? after = null)
Parameters
wordstringWhat is typed of the name; an empty word matches every candidate.
firstIReadOnlyList<CompletionGroup>The groups of candidates ranked apart from the others, in the order they rank: the constants of the
Enuman argument's parameter is declared as, then the named arguments (NamedArgumentGroup(SignatureDescription, SignatureSite, string, string)).candidatesIReadOnlyList<CompletionCandidate>The other candidates; a label of
firstis not offered again.cursorPositionWhere the cursor is in the client's document, as the completion request gives it. For a document that is part of a module, such as a program that is the body of one, this is the position in the document and not in the module. The item of a candidate that also replaces text after the cursor (ReplacedAfter) carries a
textEditover the word typed and that text, in the client's document; so does every item of a word typed from the opening bracket of a name in brackets, which a client does not take as part of the word. null when no position is known; every item then replaces the word typed only.afterstringWhat follows the cursor on its line, for a client that takes an item's edit as two ranges (LSP 3.17
InsertReplaceEdit, which a client says it does withinsertReplaceSupport); null for one that does not. Every item of such a client, withcursorknown, carries both: the one that inserts, over the word typed and what the candidate replaces after the cursor, and the one that replaces, which also takes in the rest of the word the cursor is in (RestOfWordIn(string)). The client chooses between them, as its user asks.
Returns
Remarks
The groups of first are tiers of their own, in their order, before every other candidate: Paint DR ranks and preselects the
constant DeepRed, whose humps the word matches, before a function Drum the word starts. A group that ranks after the others
(RanksAfterTheOthers) is a tier after every other candidate instead, in the same order. In each tier the labels the word starts rank
before the ones whose humps it matches; then the candidates of a group keep their order, and the others rank by
Rank, then by label in any case. The item that ranks first is the one preselect marks, unless nothing is typed
and its group is not selected then (IsSelectedWhenNothingIsTyped): the first item that can be is marked instead.
A label that is the word typed, in any case, is what the word is meant to be, and its item is the one marked, wherever it ranks: Send "a", heading
selects a variable heading, and the named argument Heading:= still ranks first.
The list is incomplete (isIncomplete): it is the list of this word, and a client asks again as the word grows. Every label a longer word
matches is in it, so a client that narrows it by MatchOf(string, string) itself narrows it to the same list.
MatchOf(string, string)
How word matches label: as its start, as its humps (the way Visual Studio matches PascalCase names), or not at all.
Case does not tell one name from another in VBA (MS-VBAL §3.3.5), and every comparison here ignores it.
public static CompletionMatch MatchOf(string label, string word)
Parameters
labelstringThe label of a candidate: a name, as it is written.
wordstringWhat is typed of the name.
Returns
- CompletionMatch
Prefix when the word is the start of the label, else Humps when it matches its humps, else None.
Remarks
A label is cut into humps, and the underscores between them belong to none:
- the first letter starts a hump, and so does the first character after an underscore;
- a capital after a lowercase letter or a digit starts one:
vbKeyEscapeisvb,Key,Escape, so a lowercase prefix is a hump of its own; - a run of capitals is one hump, and its last capital starts the next when a lowercase letter follows it:
CLngPtrisC,Lng,Ptr,IOErrorisIO,Error, andVBAis one hump; - a run of digits is one hump, and a letter after it starts the next:
Win32ApiisWin,32,Api; Class_InitializeisClass,Initialize, and_NewEnumisNew,Enum.- a letter after a character that is neither a letter nor a digit starts one:
[My Field]isMy,Field, soMFmatches it.
A name written in brackets (MS-VBAL §3.3.5.3 foreign-name) is matched by the name between them, and a word that starts with
an opening bracket matches as the rest of it does: My and [My both match [My Field], and [To matches Total.
The word matches the humps when it can be cut into as many parts as there are humps from the first, each part the start of its hump, in order: no hump
is skipped, and the humps after the last part are not needed. MP and MuPl match MultiPlayer, LoPi matches
LoadPicture, vbKEs matches vbKeyEscape, CLP matches CLngPtr. Pr does not match CLngPtr,
Player does not match MultiPlayer, and WA does not match Win32Api.
An underscore typed ends a part and matches nothing itself: what follows it is the start of the next hump, as after an underscore in a label, and
underscores typed in a row are one. C_I and C_ match Class_Initialize; Cl_ass does not. A word that starts with an
underscore matches the humps of a label that starts with one: _NEn matches _NewEnum, __ matches _private, and _x
does not match xyz.
A label that a word matches is matched by the word without its last character as well, so a client narrows the list of a word by this rule as the word grows. The match allocates nothing for a word of up to 128 characters.
MembersOf(ScopeTree, Symbol, Uri)
The members of a namespace - a project or a procedural module - as the right-hand side of a member access on it (MS-VBAL §5.6.12): the
modules of a project and the members of its procedural modules, or the members of a module, its Private ones only where they are accessible.
public static IReadOnlyList<CompletionCandidate> MembersOf(ScopeTree tree, Symbol owner, Uri origin)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
ownerSymbolThe project or the module.
originUriWhere the lookup originates (OriginAt(ScopeTree, Uri, SourcePosition)), which decides what is accessible.
Returns
MembersOf(VBType)
The members of a value of the type type, as the right-hand side of a member access on it (MS-VBAL §5.6.12): the members
of the default interface of a class, the fields of a user-defined type, the constants of an Enum. None for a type that has no members known when the code is
written - a Variant, an Object - whose members are bound when it runs.
public static IReadOnlyList<CompletionCandidate> MembersOf(VBType type)
Parameters
typeVBTypeThe declared type of the expression the member is accessed on.
Returns
NamedArgumentGroup(SignatureDescription, SignatureSite, string, string)
The named arguments of the call being written (NamedArguments(SignatureDescription, SignatureSite, string, string)), as the group of a completion list (ListOf(string, IReadOnlyList<CompletionGroup>, IReadOnlyList<CompletionCandidate>, Position?, string?)), ranked where they are most likely to be written.
public static CompletionGroup NamedArgumentGroup(SignatureDescription signature, SignatureSite site, string word, string after)
Parameters
signatureSignatureDescriptionThe signature of what is called.
siteSignatureSiteThe call being written.
wordstringWhat is typed of the name at the cursor.
afterstringThe text of the logical line from the cursor on, where named arguments can be written already.
Returns
- CompletionGroup
The group of the named arguments; it has no candidates where a name cannot be written.
Remarks
The names rank before the other candidates where the argument at the cursor would be given to an Optional parameter by position, which is often
skipped by naming the one after it, and where a named argument is written before the cursor: after one, nothing but a name can be written. Elsewhere a
value is what is most likely written, and the names rank after every other candidate (RanksAfterTheOthers). None of them
is preselected before a word is typed (IsSelectedWhenNothingIsTyped).
NamedArguments(SignatureDescription, SignatureSite, string, string)
The parameters of the call being written that can be named where the cursor is, each as the named argument that starts with it (Title:=): what
a client inserts is the label, or the name alone where the := after it is written already (Send "a", Cop|:=2).
public static IReadOnlyList<CompletionCandidate> NamedArguments(SignatureDescription signature, SignatureSite site, string word, string after)
Parameters
signatureSignatureDescriptionThe signature of what is called.
siteSignatureSiteThe call being written.
wordstringWhat is typed of the name at the cursor.
afterstringThe text of the logical line from the cursor on, where named arguments can be written already.
Returns
- IReadOnlyList<CompletionCandidate>
The named arguments, in the order the parameters are declared; none where a name cannot be written.
Remarks
A name is offered wherever an argument starts (IsWhereAnArgumentStarts(string)), the first one included, whether or not the parameter
that argument would be given to by position is Optional: any argument can be named (MS-VBAL §5.6.13.1
positional-or-named-argument-list), and after a named one, every argument is. NamedArgumentGroup(SignatureDescription, SignatureSite, string, string) says where the
names rank. No name is offered where a positional argument is written after the cursor, an omitted one included
(IsFollowedByAPositionalArgument(string)): it would follow a named one.
A parameter that has an argument already is not offered (MS-VBAL §5.3.1.11: two arguments mapped to one parameter make the argument
list incompatible): one given by position, an omitted one counted, and one named before or after the cursor, its name in any case. A ParamArray
is not offered either: it takes the positional arguments left over, and there is no one argument to name.
An external procedure (Declare) takes named arguments as a procedure of the language does (MS-VBAL §5.2.3.5). A procedure whose
parameter names are placeholders (NamesArePlaceholders) is offered no names.
Names(ScopeTree, Uri)
The names that can be written as a simple name expression where origin is: what the procedure, the module, the project, the libraries
and the language declare, nearest first. The keywords are not names; which of them can be written where is CompletionRules' to say.
public static IReadOnlyList<CompletionCandidate> Names(ScopeTree tree, Uri origin)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
originUriWhere the lookup originates (OriginAt(ScopeTree, Uri, SourcePosition)).
Returns
NamespaceOf(ISymbolResolver, Uri, string, bool)
The project or the module a qualifier names, when it names one: VBA, VBA.Strings, Module1 - what a member access is written on that
is a namespace and not a value, and whose members are its declarations (MembersOf(ScopeTree, Symbol, Uri)).
public static Symbol? NamespaceOf(ISymbolResolver resolver, Uri origin, string qualifier, bool typeContext)
Parameters
resolverISymbolResolverThe resolver of the composed workspace.
originUriWhere the lookup originates (OriginAt(ScopeTree, Uri, SourcePosition)).
qualifierstringThe qualifier, as it is written: names separated by
..typeContextboolWhether the qualifier is the one of a qualified type name, which is bound in the type binding context (ResolveQualifier(string, ScopeKind, Uri)); otherwise it is bound as a simple name expression is.
Returns
OriginAt(ScopeTree, Uri, SourcePosition)
Where a name written at position of a module is looked up from: the procedure the position is in, or the module itself when it is in
none - in the declarations section, say.
public static Uri OriginAt(ScopeTree tree, Uri moduleUri, SourcePosition position)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
moduleUriUriThe module's own URI.
positionSourcePositionThe position, in the module's source.
Returns
- Uri
The URI of the symbol the lookup originates from.
RestOfWordIn(string)
The length of the rest of the word the cursor is in: the letters, digits and underscores right after it, as a name has them.
public static int RestOfWordIn(string after)
Parameters
afterstringWhat follows the cursor on its line.
Returns
- int
The number of characters of
afterthe word goes on for; 0 when the cursor is at its end.
Exceptions
- ArgumentNullException
afteris null.
Types(ScopeTree, Uri, bool)
The names that can be written as a declared type where origin is (Type), or as the class of a
New (NewType). After As: the intrinsic types; the classes, user-defined types and Enums the project and the
libraries declare; the projects and the libraries, which qualify a type name; and New. After New: the classes that can be created, and the
projects and the libraries. Nothing that is no type is offered - not a procedural module, not a local, not a keyword but New.
public static IReadOnlyList<CompletionCandidate> Types(ScopeTree tree, Uri origin, bool creatable)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
originUriWhere the lookup originates (OriginAt(ScopeTree, Uri, SourcePosition)).
creatableboolWhether only the classes that
Newcan create are offered.
Returns
TypesOf(ScopeTree, Symbol, bool)
The types a project or a module declares, as the last part of a qualified type name (VBA.Collection, Module1.Point; MS-VBAL
§5.6.12).
public static IReadOnlyList<CompletionCandidate> TypesOf(ScopeTree tree, Symbol owner, bool creatable)
Parameters
treeScopeTreeThe scope tree of the composed workspace.
ownerSymbolThe qualifier, as ResolveQualifier(string, ScopeKind, Uri) bound it.
creatableboolWhether only the classes that
Newcan create are offered.