Table of Contents

Class CompletionCandidate

Namespace
RDCore.SDK.Model.Symbols.Completion
Assembly
RDCore.SDK.dll

One item of a completion list: a name that can be written where the list was asked for, and what it names.

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

Constructors

CompletionCandidate(string, CompletionItemKind, string?, string?, Symbol?, int)

One item of a completion list: a name that can be written where the list was asked for, and what it names.

public CompletionCandidate(string Label, CompletionItemKind Kind, string? Detail = null, string? Documentation = null, Symbol? Symbol = null, int Rank = 0)

Parameters

Label string

The name, as it is written.

Kind CompletionItemKind

What kind of thing it names, as a client shows it.

Detail string

What a client shows next to the name: the type of a variable, the signature of a procedure; null when there is nothing to say.

Documentation string

What the name is, in a sentence or two: the doc string of a library member, chiefly.

Symbol Symbol

The symbol the name binds to; null for a keyword or an intrinsic type name.

Rank int

Where the candidate ranks among the others, ahead of the alphabetical order of their names: what is declared nearer to where the list was asked for comes first, and the keywords last.

Properties

Detail

What a client shows next to the name: the type of a variable, the signature of a procedure; null when there is nothing to say.

public string? Detail { get; init; }

Property Value

string

Documentation

What the name is, in a sentence or two: the doc string of a library member, chiefly.

public string? Documentation { get; init; }

Property Value

string

InsertText

What is inserted in place of the word when it is not the label: the name alone of a named argument whose := is written already (Send "a", Cop|:=2); null for the label.

public string? InsertText { get; init; }

Property Value

string

Kind

What kind of thing it names, as a client shows it.

public CompletionItemKind Kind { get; init; }

Property Value

CompletionItemKind

Label

The name, as it is written.

public string Label { get; init; }

Property Value

string

Rank

Where the candidate ranks among the others, ahead of the alphabetical order of their names: what is declared nearer to where the list was asked for comes first, and the keywords last.

public int Rank { get; init; }

Property Value

int

ReplacedAfter

How many characters after the cursor the candidate replaces, with the word typed before it: the rest of the name the cursor is in the middle of, for a named argument (Send "a", Co|pies:=2), so that no part of the name is written twice; 0 for a candidate written at the cursor.

public int ReplacedAfter { get; init; }

Property Value

int

Symbol

The symbol the name binds to; null for a keyword or an intrinsic type name.

public Symbol? Symbol { get; init; }

Property Value

Symbol

Methods

ToCompletionItem(CompletionMatch)

The candidate as an item of an LSP completion list (LSP 3.17 §Completion Request).

public CompletionItem ToCompletionItem(CompletionMatch match = CompletionMatch.Prefix)

Parameters

match CompletionMatch

How the label matches the word typed (MatchOf(string, string)).

Returns

CompletionItem

Remarks

What is filtered by is the label, which is what a client takes when an item has no filterText, and so is what is inserted unless InsertText says otherwise: neither is written for an item that does not need it, since a list can have a thousand items, and each travels.

The sortText orders a label the word starts before one whose humps it matches, and both before one it does not match; then by Rank, then by the label in any case: by the name it writes, so a name in brackets ([My Field]) sorts among the others by My Field.