Class SyntaxEdits
- Namespace
- RDCore.SDK.Extensibility.Diagnostics
- Assembly
- RDCore.SDK.dll
The edits of a fix (EditFix), placed by the positions of the syntax tree an analyzer is given: what to write where, without the text around it.
public static class SyntaxEdits
- Inheritance
-
SyntaxEdits
- Inherited Members
Remarks
An analyzer is given the syntax tree of a module and not its text (ModuleAnalysisContext), so an edit is placed only where the tree says what
is there: at the start or the end of a node, between two nodes, or over a keyword whose length the tree implies, such as the Rem of a comment the
tree says is written with it. Where the tree does not say what is between two positions, the width of the span is what tells: in an index expression, a
span of one character between the name of the callee and its first argument is the (. Where nothing tells, the fix is not offered.
Methods
Fix(string, params TextEdit[])
A fix of one or more edits of the document a finding is in, under the title a code action offers it by.
public static EditFix Fix(string title, params TextEdit[] edits)
Parameters
titlestringThe title of the code action, which says what the fix writes.
editsTextEdit[]The edits, in any order.
Returns
Remarks
The fix is made of the edits as they are given: they are applied together, and none of them may overlap another.
Following(SourcePosition, int)
The range of length characters from a position, on its line: a keyword that starts a node, such as Dim or ByRef.
public static SourceRange Following(SourcePosition at, int length)
Parameters
atSourcePositionThe position the range starts at.
lengthintHow many characters the range is.
Returns
Insert(SourcePosition, string)
Text written at a position, before what is there.
public static TextEdit Insert(SourcePosition at, string text)
Parameters
atSourcePositionThe position the text is written at.
textstringThe text.
Returns
LineAfter(SourceRange)
The start of the line after the last line of a node: where lines written after the node go, ended with their own line ends.
public static SourcePosition LineAfter(SourceRange node)
Parameters
nodeSourceRangeThe range of the node.
Returns
LinesThrough(int, int)
The range from the start of a line to the start of the line after another, their line ends included: removed, the lines after them move up.
public static SourceRange LinesThrough(int first, int last)
Parameters
Returns
Remarks
The range ends at the start of the line after last, so it takes the line end of last only where there is one. The
last line of a text that does not end with a line end has none: where the lines may be the last of the text, the text is what places the range
(DeclarationEdits.WholeLines).
Preceding(SourcePosition, int)
The range of length characters up to a position, on its line: a type-declaration character that ends a name, or a keyword that ends
a block, such as Wend.
public static SourceRange Preceding(SourcePosition at, int length)
Parameters
atSourcePositionThe position the range ends at.
lengthintHow many characters the range is.
Returns
Remove(SourceRange)
What a range holds, removed.
public static TextEdit Remove(SourceRange range)
Parameters
rangeSourceRangeThe range whose text is removed, which may span lines.
Returns
Replace(SourceRange, string)
Text written in place of what a range holds.
public static TextEdit Replace(SourceRange range, string text)
Parameters
rangeSourceRangeThe range whose text is replaced, which may span lines.
textstringThe text written in its place.
Returns
Width(SourcePosition, SourcePosition)
How many characters there are from one position to another, when both are on the same line; -1 when they are not, where the tree does not say
how many there are.
public static int Width(SourcePosition from, SourcePosition to)
Parameters
fromSourcePositionThe first position.
toSourcePositionThe second position, on or after the first.