From e886689876a46b9d682b10c8d9fe6f4de44ab770 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 3 Apr 2024 13:29:45 +0200 Subject: [PATCH] fixup! parser-json-gcc: read endLine/endColumn if available --- src/lib/parser-json-gcc.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/lib/parser-json-gcc.cc b/src/lib/parser-json-gcc.cc index 7ea1ed2e..cbce37fb 100644 --- a/src/lib/parser-json-gcc.cc +++ b/src/lib/parser-json-gcc.cc @@ -21,6 +21,8 @@ #include "parser-gcc.hh" // for GccPostProcessor +using std::string; + struct GccTreeDecoder::Private { GccPostProcessor postProc; }; @@ -34,23 +36,23 @@ GccTreeDecoder::~GccTreeDecoder() = default; static bool gccReadLocRegion( DefEvent *pEvt, - const pt::ptree &beg, - const pt::ptree &end) + const pt::ptree &start, + const pt::ptree &finish) { // read file name - pEvt->fileName = valueOf(beg, "file", ""); - if (pEvt->fileName != valueOf(end, "file", "")) + pEvt->fileName = valueOf(start, "file", ""); + if (pEvt->fileName != valueOf(finish, "file", "")) return false; // read line - if ((pEvt->line = valueOf(beg, "line"))) { - const int endLine = valueOf(end, "line"); + if ((pEvt->line = valueOf(start, "line"))) { + const int endLine = valueOf(finish, "line"); pEvt->vSize = diffNums(pEvt->line, endLine); } // read column - if ((pEvt->column = valueOf(beg, "byte-column"))) { - const int endColumn = valueOf(end, "byte-column"); + if ((pEvt->column = valueOf(start, "byte-column"))) { + const int endColumn = valueOf(finish, "byte-column"); pEvt->hSize = diffNums(pEvt->column, endColumn); } @@ -59,18 +61,16 @@ static bool gccReadLocRegion( static void gccReadLocation(DefEvent *pEvt, const pt::ptree *locs) { - using std::string; - if (locs->empty()) return; const pt::ptree &firstLoc = locs->begin()->second; // try to read a region between start..finish - const pt::ptree *beg, *end; - if (findChildOf(&beg, firstLoc, "start") - && findChildOf(&end, firstLoc, "finish") - && gccReadLocRegion(pEvt, *beg, *end)) + const pt::ptree *start, *finish; + if (findChildOf(&start, firstLoc, "start") + && findChildOf(&finish, firstLoc, "finish") + && gccReadLocRegion(pEvt, *start, *finish)) return; // fallback to caret @@ -84,8 +84,6 @@ static void gccReadLocation(DefEvent *pEvt, const pt::ptree *locs) static bool gccReadEvent(DefEvent *pEvt, const pt::ptree &evtNode) { - using std::string; - // read kind (error, warning, note) string &evtName = pEvt->event; evtName = valueOf(evtNode, "kind");