mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
Add options to turn off diagnostics.
diagnostics.onParse: semi-real time diagnostics that reported when a file is indexed or prepared for code completion diagnostics.onCodeComplete: real time diagnostics that are reported as you type
This commit is contained in:
parent
152e98363f
commit
22bb89fca1
@ -290,7 +290,7 @@ void EnsureDocumentParsed(ClangCompleteManager* manager,
|
||||
std::cerr << "[complete] Done creating active; did_fail=" << (*tu)->did_fail << std::endl;
|
||||
|
||||
// Build diagnostics.
|
||||
if (!(*tu)->did_fail) {
|
||||
if (manager->config_->diagnosticsOnParse && !(*tu)->did_fail) {
|
||||
NonElidedVector<lsDiagnostic> ls_diagnostics;
|
||||
unsigned num_diagnostics = clang_getNumDiagnostics((*tu)->cx_tu);
|
||||
for (unsigned i = 0; i < num_diagnostics; ++i) {
|
||||
@ -449,23 +449,26 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
|
||||
timer.ResetAndPrint("[complete] Running user-given completion func");
|
||||
}
|
||||
|
||||
unsigned num_diagnostics = clang_codeCompleteGetNumDiagnostics(cx_results);
|
||||
NonElidedVector<lsDiagnostic> ls_diagnostics;
|
||||
for (unsigned i = 0; i < num_diagnostics; ++i) {
|
||||
CXDiagnostic cx_diag = clang_codeCompleteGetDiagnostic(cx_results, i);
|
||||
optional<lsDiagnostic> diagnostic = BuildAndDisposeDiagnostic(cx_diag, path);
|
||||
if (diagnostic)
|
||||
ls_diagnostics.push_back(*diagnostic);
|
||||
if (completion_manager->config_->diagnosticsOnCodeCompletion) {
|
||||
unsigned num_diagnostics = clang_codeCompleteGetNumDiagnostics(cx_results);
|
||||
NonElidedVector<lsDiagnostic> ls_diagnostics;
|
||||
for (unsigned i = 0; i < num_diagnostics; ++i) {
|
||||
CXDiagnostic cx_diag = clang_codeCompleteGetDiagnostic(cx_results, i);
|
||||
optional<lsDiagnostic> diagnostic = BuildAndDisposeDiagnostic(cx_diag, path);
|
||||
if (diagnostic)
|
||||
ls_diagnostics.push_back(*diagnostic);
|
||||
}
|
||||
completion_manager->on_diagnostic_(session->file.filename, ls_diagnostics);
|
||||
timer.ResetAndPrint("[complete] Build diagnostics");
|
||||
}
|
||||
completion_manager->on_diagnostic_(session->file.filename, ls_diagnostics);
|
||||
timer.ResetAndPrint("[complete] Build diagnostics");
|
||||
}
|
||||
|
||||
// Make sure |ls_results| is destroyed before clearing |cx_results|.
|
||||
clang_disposeCodeCompleteResults(cx_results);
|
||||
timer.ResetAndPrint("[complete] clang_disposeCodeCompleteResults");
|
||||
|
||||
if (request->is_user_completion) {
|
||||
if (completion_manager->config_->diagnosticsOnCodeCompletion &&
|
||||
request->is_user_completion) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(completion_manager->delayed_diagnostic_wakeup_mtx_);
|
||||
completion_manager->delayed_diagnostic_last_completion_position_ = request->location;
|
||||
|
@ -902,7 +902,7 @@ void ParseFile(Config* config,
|
||||
}
|
||||
|
||||
// Publish diagnostics for non-interactive index.
|
||||
else {
|
||||
else if (config->diagnosticsOnParse) {
|
||||
EmitDiagnostics(working_files, new_index->path, new_index->diagnostics_);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
struct Config {
|
||||
// Root directory of the project. **Not serialized**
|
||||
std::string projectRoot;
|
||||
// Cache directory for indexed files.
|
||||
std::string cacheDirectory;
|
||||
|
||||
std::vector<std::string> extraClangArguments;
|
||||
@ -50,6 +51,11 @@ struct Config {
|
||||
std::vector<std::string> includeCompletionWhitelist;
|
||||
std::vector<std::string> includeCompletionBlacklist;
|
||||
|
||||
// If true, diagnostics from a full document parse will be reported.
|
||||
bool diagnosticsOnParse = true;
|
||||
// If true, diagnostics from code completion will be reported.
|
||||
bool diagnosticsOnCodeCompletion = true;
|
||||
|
||||
// Enables code lens on parameter and function variables.
|
||||
bool codeLensOnLocalVariables = true;
|
||||
|
||||
@ -74,6 +80,9 @@ MAKE_REFLECT_STRUCT(Config,
|
||||
|
||||
showDocumentLinksOnIncludes,
|
||||
|
||||
diagnosticsOnParse,
|
||||
diagnosticsOnCodeCompletion,
|
||||
|
||||
codeLensOnLocalVariables,
|
||||
|
||||
clientVersion);
|
Loading…
Reference in New Issue
Block a user