make types.Diagnostic correctly parseable

This commit is contained in:
Techatrix 2022-09-25 01:01:31 +02:00
parent 548ced259f
commit ca58cbb3f3
2 changed files with 7 additions and 7 deletions

View File

@ -335,10 +335,10 @@ fn getAstCheckDiagnostics(
} else if (std.mem.startsWith(u8, msg, "note: ")) {
var latestDiag = &diagnostics.items[diagnostics.items.len - 1];
var fresh = if (latestDiag.relatedInformation.len == 0)
try server.arena.allocator().alloc(types.DiagnosticRelatedInformation, 1)
var fresh = if (latestDiag.relatedInformation) |related_information|
try server.arena.allocator().realloc(@ptrCast([]types.DiagnosticRelatedInformation, related_information), related_information.len + 1)
else
try server.arena.allocator().realloc(@ptrCast([]types.DiagnosticRelatedInformation, latestDiag.relatedInformation), latestDiag.relatedInformation.len + 1);
try server.arena.allocator().alloc(types.DiagnosticRelatedInformation, 1);
const location = types.Location{
.uri = handle.uri(),

View File

@ -117,11 +117,11 @@ pub const DiagnosticRelatedInformation = struct {
pub const Diagnostic = struct {
range: Range,
severity: DiagnosticSeverity,
code: string,
source: string,
severity: ?DiagnosticSeverity,
code: ?string,
source: ?string,
message: string,
relatedInformation: []const DiagnosticRelatedInformation = &.{},
relatedInformation: ?[]const DiagnosticRelatedInformation = null,
};
pub const TextDocument = struct {