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
parseModuleParseResultThe module, parsed: its syntax tree, its trivia (the comments) and its precompiler trivia (the
#Ifblocks).textstringThe text the module was parsed from.
memberMemberDeclarationNodeA member of the module.
Returns
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
textstringThe text of the module.
afterMemberExtentThe whole text of the member it goes after (Extent(ModuleParseResult, string, MemberDeclarationNode)).
memberstringThe whole text of the member written: the text of a Range, or a new member's.
Returns
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
textstringThe text of the module.
beforeMemberExtentThe whole text of the member it goes before (Extent(ModuleParseResult, string, MemberDeclarationNode)).
memberstringThe whole text of the member written: the text of a Range, or a new member's.
Returns
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
textstringThe text of the module.
movedMemberExtentThe whole text of the member moved (Extent(ModuleParseResult, string, MemberDeclarationNode)).
targetMemberExtentThe whole text of the member it goes next to.
afterboolWhether it goes after
target; before it when not.
Returns
Exceptions
- ArgumentException
targetoverlapsmoved, ormovedis already on the side oftargetthatafternames, 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
textstringThe text of the module.
extentMemberExtentThe member's whole text (Extent(ModuleParseResult, string, MemberDeclarationNode)).
Returns
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
textstringThe text of the module.
membersIReadOnlyList<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
#Ifdirective, ends a run: no member is written past it.comparerIComparer<MemberExtent>The order the members of a run are written in. Members it orders alike keep the order they are written in.
Returns
Exceptions
- ArgumentException
membersare not in the order they are written, or two of them overlap.