package crs
Source file diagnostic.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56(****************************************************************************) (* ocaml-reviewdog - A reviewdog diagnostics json serializer for OCaml *) (* SPDX-FileCopyrightText: 2025 Mathieu Barbin <mathieu.barbin@gmail.com> *) (* SPDX-License-Identifier: MIT *) (****************************************************************************) type t = { message : string ; location : Location.t ; severity : Severity.t option ; source : Source.t option ; code : Code.t option ; suggestions : Suggestion.t list ; original_output : string option ; related_locations : Related_location.t list } let to_json { message ; location ; severity ; source ; code ; suggestions ; original_output ; } : Yojson.Basic.t = `Assoc (List.concat [ [ "message", `String message ] ; [ "location", Location.to_json location ] ; (match severity with | None -> [] | Some s -> [ "severity", Severity.to_json s ]) ; (match source with | None -> [] | Some s -> [ "source", Source.to_json s ]) ; (match code with | None -> [] | Some c -> [ "code", Code.to_json c ]) ; (match suggestions with | [] -> [] | _ -> [ "suggestions", `List (List.map Suggestion.to_json suggestions) ]) ; (match original_output with | None -> [] | Some o -> [ "originalOutput", `String o ]) ; (match related_locations with | [] -> [] | _ -> [ ( "relatedLocations" , `List (List.map Related_location.to_json related_locations) ) ]) ]) ;;