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

Method OnTextDocumentDiagnostic

CodeFormatServer/src/LSP/LSPHandle.cpp:302–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302std::shared_ptr<lsp::DocumentDiagnosticReport> LSPHandle::OnTextDocumentDiagnostic(
303 std::shared_ptr<lsp::DocumentDiagnosticParams> params) {
304 auto report = std::make_shared<lsp::DocumentDiagnosticReport>();
305 report->kind = lsp::DocumentDiagnosticReportKind::Full;
306
307 auto &vfs = _server->GetVFS();
308 auto opFileId = vfs.GetUriDB().Query(params->textDocument.uri);
309 if (!opFileId.has_value()) {
310 return report;
311 }
312
313 auto opSyntaxTree = vfs.GetVirtualFile(params->textDocument.uri).GetSyntaxTree(vfs);
314 if (!opSyntaxTree.has_value()) {
315 return report;
316 }
317
318 auto &syntaxTree = opSyntaxTree.value();
319
320 if (syntaxTree.HasError()) {
321 return report;
322 }
323
324 LuaStyle &luaStyle = _server->GetService<ConfigService>()->GetLuaStyle(params->textDocument.uri);
325
326 auto diagnostics = _server->GetService<DiagnosticService>()->Diagnostic(
327 opFileId.value(), syntaxTree, luaStyle);
328 report->resultId = std::to_string(opFileId.value());
329
330 report->items = std::move(diagnostics);
331 return report;
332}
333
334
335std::shared_ptr<lsp::WorkspaceDiagnosticReport> LSPHandle::OnWorkspaceDiagnostic(

Callers

nothing calls this directly

Calls 6

GetSyntaxTreeMethod · 0.80
GetVirtualFileMethod · 0.80
QueryMethod · 0.45
valueMethod · 0.45
HasErrorMethod · 0.45
DiagnosticMethod · 0.45

Tested by

no test coverage detected