json Serializer::serializeLogMessage(const LogMessagePtr& aMessageData) noexcept { return{ { "id", aMessageData->getId() }, { "text", aMessageData->getText() }, { "time", aMessageData->getTime() }, { "severity", getSeverity(aMessageData->getSeverity()) }, { "is_read", aMessageData->getRead() } }; }
void CSMTools::ScriptCheckStage::report (const std::string& message, Type type) { CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); std::ostringstream stream; stream << "script " << mFile << ": " << message; mMessages->add (id, stream.str(), "", getSeverity (type)); }
LogMessage::~LogMessage() { if (DebugAnnotationsInitialized() && (mSeverity == LOG_ERR || mSeverity == LOG_WARN)) { g_debugAnnotator->logMessage(*this); } else { Trace(getSeverity(), getMessage().c_str()); } }
void CSMTools::ScriptCheckStage::report (const std::string& message, const Compiler::TokenLoc& loc, Type type) { std::ostringstream stream; CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); stream << "script " << mFile << ", line " << loc.mLine << ", column " << loc.mColumn << " (" << loc.mLiteral << "): " << message; std::ostringstream hintStream; hintStream << "l:" << loc.mLine << " " << loc.mColumn; mMessages->add (id, stream.str(), hintStream.str(), getSeverity (type)); }
ErrorSeverity getCheckSeverity(IAtom * name) { ErrorSeverity severity = getSeverity(name); assertex(severity != SeverityUnknown); return severity; }
bool LogPartition::doLog (LogSeverity s) const { return s >= getSeverity(); }
QString ErrorReport::toString(){ return getSeverity() + ":" + getMessage(); }
TEST(DiagnosticsTest, ToLSP) { clangd::Diag D; D.Message = "something terrible happened"; D.Range = {pos(1, 2), pos(3, 4)}; D.InsideMainFile = true; D.Severity = DiagnosticsEngine::Error; D.File = "foo/bar/main.cpp"; clangd::Note NoteInMain; NoteInMain.Message = "declared somewhere in the main file"; NoteInMain.Range = {pos(5, 6), pos(7, 8)}; NoteInMain.Severity = DiagnosticsEngine::Remark; NoteInMain.File = "../foo/bar/main.cpp"; NoteInMain.InsideMainFile = true; D.Notes.push_back(NoteInMain); clangd::Note NoteInHeader; NoteInHeader.Message = "declared somewhere in the header file"; NoteInHeader.Range = {pos(9, 10), pos(11, 12)}; NoteInHeader.Severity = DiagnosticsEngine::Note; NoteInHeader.File = "../foo/baz/header.h"; NoteInHeader.InsideMainFile = false; D.Notes.push_back(NoteInHeader); clangd::Fix F; F.Message = "do something"; D.Fixes.push_back(F); auto MatchingLSP = [](const DiagBase &D, llvm::StringRef Message) { clangd::Diagnostic Res; Res.range = D.Range; Res.severity = getSeverity(D.Severity); Res.message = Message; return Res; }; // Diagnostics should turn into these: clangd::Diagnostic MainLSP = MatchingLSP(D, R"(something terrible happened main.cpp:6:7: remark: declared somewhere in the main file ../foo/baz/header.h:10:11: note: declared somewhere in the header file)"); clangd::Diagnostic NoteInMainLSP = MatchingLSP(NoteInMain, R"(declared somewhere in the main file main.cpp:2:3: error: something terrible happened)"); // Transform dianostics and check the results. std::vector<std::pair<clangd::Diagnostic, std::vector<clangd::Fix>>> LSPDiags; toLSPDiags(D, [&](clangd::Diagnostic LSPDiag, llvm::ArrayRef<clangd::Fix> Fixes) { LSPDiags.push_back({std::move(LSPDiag), std::vector<clangd::Fix>(Fixes.begin(), Fixes.end())}); }); EXPECT_THAT( LSPDiags, ElementsAre(Pair(EqualToLSPDiag(MainLSP), ElementsAre(EqualToFix(F))), Pair(EqualToLSPDiag(NoteInMainLSP), IsEmpty()))); }