Offer compiler quick fixes as code actions

Decode GCC SARIF fixes into bounded diagnostic edits through the same
physical-origin policy as locations; unprovable regions are dropped. A
bounded projection filters fixes to the requested range, deduplicates
and bounds them, and textDocument/codeAction serves them from retained
published diagnostics. Registered tests cover the SARIF binding and the
projection; a real stdio session returned the compiler's
Replace 'valu' with 'value' quickfix.
This commit is contained in:
faumaray committed 2026-12-05 15:03:21 +03:00
1 parent 624c24d028
commit 946b1a005e
15 files changed
+418 -10

No files matched your search

+13
View File
@@ -90,11 +90,24 @@ struct RelatedLocation {
DiagnosticLocation location;
};
enum class DiagnosticSeverity { error, warning, information, hint };
// One replacement from a compiler-suggested fix, in the owner snapshot's
// negotiated coordinates.
struct DiagnosticEdit {
Documents::Range range;
std::string replacement;
};
struct DiagnosticFix {
std::string description;
std::vector<DiagnosticEdit> edits;
};
struct CompilerDiagnostic {
DiagnosticSeverity severity;
std::string message, rule;
DiagnosticLocation location;
std::vector<RelatedLocation> related;
// Bounded compiler-suggested fixes. An edit whose region cannot be proven
// in the owner snapshot is dropped, never guessed.
std::vector<DiagnosticFix> fixes;
};
struct DiagnosticBatch {
std::string invocation_id, input_view_id;
@@ -48,6 +48,10 @@ class EditorDiagnostics {
selection_ranges(std::string_view uri, std::span<const Documents::Position>) const;
// Foldable brace blocks, comments, regions and include groups.
[[nodiscard]] Void::LanguageServer::Protocol::Json folding_ranges(std::string_view uri) const;
// Quick fixes suggested by the compiler for diagnostics overlapping the
// requested range. Only fixes proven in the owner snapshot are offered.
[[nodiscard]] Void::LanguageServer::Protocol::Json code_actions(std::string_view uri,
Documents::Range range) const;
struct NavigationReply {
Void::LanguageServer::Protocol::Json result;