123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172(********************************************************************************)(* crs - A tool for managing code review comments embedded in source code *)(* Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com> *)(* *)(* This file is part of crs. *)(* *)(* crs is free software; you can redistribute it and/or modify it under the *)(* terms of the GNU Lesser General Public License as published by the Free *)(* Software Foundation either version 3 of the License, or any later version, *)(* with the LGPL-3.0 Linking Exception. *)(* *)(* crs is distributed in the hope that it will be useful, but WITHOUT ANY *)(* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *)(* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and *)(* the file `NOTICE.md` at the root of this repository for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* and the LGPL-3.0 Linking Exception along with this library. If not, see *)(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)(********************************************************************************)moduleSeverity=structtypet=|Error|Warning|Notice[@@derivingsexp_of]letto_string=function|Error->"error"|Warning->"warning"|Notice->"notice";;endtypet={loc:Loc.t;severity:Severity.t;title:string;message:string}[@@derivingsexp_of]letcreate~loc~severity~title~message={loc;severity;title;message}letto_loc_fields_internal~loc=letcolumn(pos:Lexing.position)=pos.pos_cnum-pos.pos_bol+1inletstart_pos=Loc.startlocinletstop_pos=Loc.stoplocin["file",Fpath.to_string(Loc.pathloc);"line",Int.to_stringstart_pos.pos_lnum;"col",Int.to_string(columnstart_pos);"endLine",Int.to_stringstop_pos.pos_lnum;"endColumn",Int.to_string(columnstop_pos)];;letto_loc_fields~loc=ifLoc.is_nonelocthen[]elseto_loc_fields_internal~locletto_string{loc;severity;title;message}=letfields=to_loc_fields~loc@["title",title]inString.concat~sep:""["::";Severity.to_stringseverity;" ";List.mapfields~f:(fun(field,value)->Printf.sprintf"%s=%s"fieldvalue)|>String.concat~sep:",";"::";String.substr_replace_allmessage~pattern:"\n"~with_:"%0A"];;