Class DiagnosticFixes
- Namespace
- RDCore.SDK.Extensibility.Diagnostics
- Assembly
- RDCore.SDK.dll
What can be done about a finding, which the platform knows how to do: the fixes an analyzer states with what it found, and which travel with the diagnostic
in its data (LSP 3.17 Diagnostic.data) for the language server to offer as code actions.
public sealed record DiagnosticFixes : IEquatable<DiagnosticFixes>
- Inheritance
-
DiagnosticFixes
- Implements
- Inherited Members
Remarks
An analyzer says what the fix is, and the platform makes it: a rename, or another refactoring, is worked out by the language server against the whole workspace when it is asked for, and is offered only when it can be made. An extension states such a fix without knowing how the workspace is changed, and gets the code actions of the platform for it. A fix that changes only the document the finding is in (the edits of one procedure) is the analyzer's to make, from the syntax tree it was given: it states the edits themselves (Edits). A fix that changes what the project file says (a library the project references, or what it says of the module) is a change the analyzer states, and the language server makes (Project).
Properties
Edits
The fixes that are edits of the document the diagnostic is in, which the analyzer made, best first; empty when there are none. Each is offered as a
code action of its own. The first is the one a client may apply without showing it (LSP 3.17 CodeAction.isPreferred), unless
it changes what the code does (ChangesBehavior); no other one is.
[JsonProperty("edits")]
public IReadOnlyList<EditFix> Edits { get; init; }
Property Value
Project
The fix is a change of the project: what its project file is to say, which the language server writes when the fix is taken (ChangeProject); null when it is not.
[JsonProperty("project", NullValueHandling = NullValueHandling.Ignore)]
public ProjectFix? Project { get; init; }
Property Value
Refactoring
The fix is a refactoring of the declaration or the statements in the range of the diagnostic, which the language server plans against the whole workspace when it is asked for, as it plans a Rename; null when it is not.
[JsonProperty("refactoring", NullValueHandling = NullValueHandling.Ignore)]
public RefactoringFix? Refactoring { get; init; }
Property Value
Rename
The fix is to rename the name in the range of the diagnostic, which is the name of a declaration; null when it is not.
[JsonProperty("rename", NullValueHandling = NullValueHandling.Ignore)]
public RenameFix? Rename { get; init; }
Property Value
Setting
The fix is to add an item to the list of a setting, such as a name the analyzer is to allow; null when it is not.
[JsonProperty("setting", NullValueHandling = NullValueHandling.Ignore)]
public SettingFix? Setting { get; init; }
Property Value
Methods
AtVersion(int?)
The fixes, with the version of the document they were made of on each edit fix that does not state one (Version). An analyzer is not told the version of the document it reads: what answers DiagnoseDocument stamps its findings' fixes with SourceVersion.
public DiagnosticFixes AtVersion(int? sourceVersion)
Parameters
sourceVersionint?The version of the document the findings were made of; null when it is not known.
Returns
Of(Diagnostic)
The fixes a diagnostic carries, when it carries any: a diagnostic whose data is something else - the metadata of an error - has none.
public static DiagnosticFixes? Of(Diagnostic diagnostic)
Parameters
diagnosticDiagnosticThe diagnostic, as a client sent it back with a code action request.
Returns
ShouldSerializeEdits()
Whether Edits is written in the data: not when it is empty.
public bool ShouldSerializeEdits()
Returns
ToData()
The fixes, as a diagnostic's data.
public JToken ToData()
Returns
- JToken