Table of Contents

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

title string

The title of the code action, which says what the fix writes.

edits TextEdit[]

The edits, in any order.

Returns

EditFix

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

at SourcePosition

The position the range starts at.

length int

How many characters the range is.

Returns

SourceRange

Insert(SourcePosition, string)

Text written at a position, before what is there.

public static TextEdit Insert(SourcePosition at, string text)

Parameters

at SourcePosition

The position the text is written at.

text string

The text.

Returns

TextEdit

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

node SourceRange

The range of the node.

Returns

SourcePosition

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

first int

The first line.

last int

The last line, the same as first or after it.

Returns

SourceRange

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

at SourcePosition

The position the range ends at.

length int

How many characters the range is.

Returns

SourceRange

Remove(SourceRange)

What a range holds, removed.

public static TextEdit Remove(SourceRange range)

Parameters

range SourceRange

The range whose text is removed, which may span lines.

Returns

TextEdit

Replace(SourceRange, string)

Text written in place of what a range holds.

public static TextEdit Replace(SourceRange range, string text)

Parameters

range SourceRange

The range whose text is replaced, which may span lines.

text string

The text written in its place.

Returns

TextEdit

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

from SourcePosition

The first position.

to SourcePosition

The second position, on or after the first.

Returns

int