Table of Contents

Class MemberEdits

Namespace
RDCore.SDK.Semantics.Refactoring
Assembly
RDCore.SDK.dll

The edits that remove, insert and move whole members of a module, which keep their comments, annotations, line continuations and Attribute lines: each takes a member's whole lines (MemberExtent), and keeps one blank line between two members.

public static class MemberEdits
Inheritance
MemberEdits
Inherited Members

Remarks

The edits are of the text as it is, none of them overlapping another, as LSP 3.17 TextEdits of one document are. What they write ends its lines as the text does: with what ends the text's first line, and with a carriage return and a line feed when the text has a single line.

Methods

Extent(ModuleParseResult, string, MemberDeclarationNode)

The whole text of a member of a module.

public static MemberExtent Extent(ModuleParseResult parse, string text, MemberDeclarationNode member)

Parameters

parse ModuleParseResult

The module, parsed: its syntax tree, its trivia (the comments) and its precompiler trivia (the #If blocks).

text string

The text the module was parsed from.

member MemberDeclarationNode

A member of the module.

Returns

MemberExtent

InsertAfter(string, MemberExtent, string)

The edit that writes a member after another, a blank line between them.

public static RefactorTextEdit InsertAfter(string text, MemberExtent after, string member)

Parameters

text string

The text of the module.

after MemberExtent

The whole text of the member it goes after (Extent(ModuleParseResult, string, MemberDeclarationNode)).

member string

The whole text of the member written: the text of a Range, or a new member's.

Returns

RefactorTextEdit

InsertBefore(string, MemberExtent, string)

The edit that writes a member before another, a blank line between them: before the comments directly above that other one, which are its.

public static RefactorTextEdit InsertBefore(string text, MemberExtent before, string member)

Parameters

text string

The text of the module.

before MemberExtent

The whole text of the member it goes before (Extent(ModuleParseResult, string, MemberDeclarationNode)).

member string

The whole text of the member written: the text of a Range, or a new member's.

Returns

RefactorTextEdit

Move(string, MemberExtent, MemberExtent, bool)

The edits that move a member after another, or before it: its removal (Remove(string, MemberExtent)), and its text written at its new place (InsertAfter(string, MemberExtent, string), InsertBefore(string, MemberExtent, string)), in the order they are in the text.

public static IReadOnlyList<RefactorTextEdit> Move(string text, MemberExtent moved, MemberExtent target, bool after)

Parameters

text string

The text of the module.

moved MemberExtent

The whole text of the member moved (Extent(ModuleParseResult, string, MemberDeclarationNode)).

target MemberExtent

The whole text of the member it goes next to.

after bool

Whether it goes after target; before it when not.

Returns

IReadOnlyList<RefactorTextEdit>

Exceptions

ArgumentException

target overlaps moved, or moved is already on the side of target that after names, with nothing but blank lines between them.

Remove(string, MemberExtent)

The edit that removes a member and the blank lines after it. When nothing but blank lines follows the member, the blank lines before it are removed with it as well.

public static RefactorTextEdit Remove(string text, MemberExtent extent)

Parameters

text string

The text of the module.

extent MemberExtent

The member's whole text (Extent(ModuleParseResult, string, MemberDeclarationNode)).

Returns

RefactorTextEdit

Reorder(string, IReadOnlyList<MemberExtent>, IComparer<MemberExtent>)

The edits that write members in another order: for each run of members written one after another, with nothing but blank lines between them, one edit that writes them in the order comparer gives, with one blank line between two of them. A run whose order does not change has no edit.

public static IReadOnlyList<RefactorTextEdit> Reorder(string text, IReadOnlyList<MemberExtent> members, IComparer<MemberExtent> comparer)

Parameters

text string

The text of the module.

members IReadOnlyList<MemberExtent>

The whole texts of the members (Extent(ModuleParseResult, string, MemberDeclarationNode)), in the order they are written. Anything but blank lines between a member and the next, such as a comment on lines of its own or an #If directive, ends a run: no member is written past it.

comparer IComparer<MemberExtent>

The order the members of a run are written in. Members it orders alike keep the order they are written in.

Returns

IReadOnlyList<RefactorTextEdit>

Exceptions

ArgumentException

members are not in the order they are written, or two of them overlap.