From dde1c687ecb7cbde563312b928301240dbf3ec61 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 12 Jul 2017 11:25:58 -0700 Subject: [PATCH] Build diagnostics during code completion --- src/clang_complete.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 5449f1e8..b26260ac 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -403,6 +403,19 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) { request->on_complete(ls_result, false /*is_cached_result*/); timer.ResetAndPrint("[complete] Running user-given completion func"); + + unsigned num_diagnostics = clang_codeCompleteGetNumDiagnostics(cx_results); + NonElidedVector ls_diagnostics; + std::cerr << "!! There are " + std::to_string(num_diagnostics) + " diagnostics to build\n"; + for (unsigned i = 0; i < num_diagnostics; ++i) { + std::cerr << "!! Building diagnostic " + std::to_string(i) + "\n"; + CXDiagnostic cx_diag = clang_codeCompleteGetDiagnostic(cx_results, i); + optional diagnostic = BuildAndDisposeDiagnostic(cx_diag); + if (diagnostic) + ls_diagnostics.push_back(*diagnostic); + } + completion_manager->on_diagnostic_(session->file.filename, ls_diagnostics); + timer.ResetAndPrint("[complete] Build diagnostics"); } // Make sure |ls_results| is destroyed before clearing |cx_results|.