MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / DiagnosticToJson

Function DiagnosticToJson

CodeFormat/src/LuaCheck.cpp:40–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40nlohmann::json DiagnosticToJson(std::string_view message, TextRange range, LuaSource &file) {
41 auto startLine = file.GetLine(range.StartOffset);
42 auto startChar = file.GetColumn(range.StartOffset);
43 auto endLine = file.GetLine(range.GetEndOffset());
44 auto endChar = file.GetColumn(range.GetEndOffset());
45 auto obj = nlohmann::json::object();
46 obj["message"] = message;
47 obj["range"] = {
48 {"start", {{"line", startLine}, {"character", startChar}}},
49 {"end", {{"line", endLine}, {"character", endChar}} }
50 };
51 return obj;
52}
53
54bool LuaCheck::CheckSingleFile(const FormatContext &context, std::string_view path, std::string &&sourceText, LuaStyle style) {
55 auto file = std::make_shared<LuaSource>(std::move(sourceText));

Callers 1

CheckSingleFileMethod · 0.85

Calls 3

GetLineMethod · 0.80
GetColumnMethod · 0.80
GetEndOffsetMethod · 0.45

Tested by

no test coverage detected