mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Add diagnostics.onSave
This commit is contained in:
parent
1df131d411
commit
68a27e746d
@ -142,6 +142,9 @@ struct Config {
|
|||||||
// If true, diagnostics will be reported for textDocument/didOpen.
|
// If true, diagnostics will be reported for textDocument/didOpen.
|
||||||
bool onOpen = true;
|
bool onOpen = true;
|
||||||
|
|
||||||
|
// If true, diagnostics will be reported for textDocument/didSave.
|
||||||
|
bool onSave = true;
|
||||||
|
|
||||||
bool spellChecking = true;
|
bool spellChecking = true;
|
||||||
|
|
||||||
std::vector<std::string> whitelist;
|
std::vector<std::string> whitelist;
|
||||||
@ -228,7 +231,7 @@ MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, dropOldRequests,
|
|||||||
includeMaxPathSize, includeSuffixWhitelist,
|
includeMaxPathSize, includeSuffixWhitelist,
|
||||||
includeWhitelist);
|
includeWhitelist);
|
||||||
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, frequencyMs, onChange,
|
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, frequencyMs, onChange,
|
||||||
onOpen, spellChecking, whitelist)
|
onOpen, onSave, spellChecking, whitelist)
|
||||||
MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist)
|
MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist)
|
||||||
MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled, multiVersion,
|
MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled, multiVersion,
|
||||||
multiVersionBlacklist, multiVersionWhitelist, onChange,
|
multiVersionBlacklist, multiVersionWhitelist, onChange,
|
||||||
|
@ -484,8 +484,7 @@ struct Handler_Initialize : BaseMessageHandler<In_InitializeRequest> {
|
|||||||
g_thread_id = i + 1;
|
g_thread_id = i + 1;
|
||||||
std::string name = "indexer" + std::to_string(i);
|
std::string name = "indexer" + std::to_string(i);
|
||||||
set_thread_name(name.c_str());
|
set_thread_name(name.c_str());
|
||||||
pipeline::Indexer_Main(clang_complete, diag_pub, vfs, project,
|
pipeline::Indexer_Main(clang_complete, vfs, project, working_files);
|
||||||
working_files);
|
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ struct Handler_TextDocumentDidSave
|
|||||||
Project::Entry entry = project->FindCompilationEntryForFile(path);
|
Project::Entry entry = project->FindCompilationEntryForFile(path);
|
||||||
pipeline::Index(entry.filename, entry.args, IndexMode::Normal);
|
pipeline::Index(entry.filename, entry.args, IndexMode::Normal);
|
||||||
clang_complete->NotifySave(path);
|
clang_complete->NotifySave(path);
|
||||||
|
if (g_config->diagnostics.onSave)
|
||||||
|
clang_complete->DiagnosticsUpdate(params.textDocument);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidSave);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidSave);
|
||||||
|
@ -153,8 +153,7 @@ std::unique_ptr<IndexFile> RawCacheLoad(const std::string &path) {
|
|||||||
IndexFile::kMajorVersion);
|
IndexFile::kMajorVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Indexer_Parse(CompletionManager *completion,
|
bool Indexer_Parse(CompletionManager *completion, WorkingFiles *wfiles,
|
||||||
DiagnosticsPublisher *diag_pub, WorkingFiles *wfiles,
|
|
||||||
Project *project, VFS *vfs, const GroupMatch &matcher) {
|
Project *project, VFS *vfs, const GroupMatch &matcher) {
|
||||||
std::optional<Index_Request> opt_request = index_request->TryPopFront();
|
std::optional<Index_Request> opt_request = index_request->TryPopFront();
|
||||||
if (!opt_request)
|
if (!opt_request)
|
||||||
@ -337,13 +336,11 @@ void Init() {
|
|||||||
for_stdout = new ThreadedQueue<Stdout_Request>(stdout_waiter);
|
for_stdout = new ThreadedQueue<Stdout_Request>(stdout_waiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Indexer_Main(CompletionManager *completion,
|
void Indexer_Main(CompletionManager *completion, VFS *vfs, Project *project,
|
||||||
DiagnosticsPublisher *diag_pub, VFS *vfs, Project *project,
|
WorkingFiles *wfiles) {
|
||||||
WorkingFiles *working_files) {
|
|
||||||
GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist);
|
GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist);
|
||||||
while (true)
|
while (true)
|
||||||
if (!Indexer_Parse(completion, diag_pub, working_files, project, vfs,
|
if (!Indexer_Parse(completion, wfiles, project, vfs, matcher))
|
||||||
matcher))
|
|
||||||
indexer_waiter->Wait(index_request);
|
indexer_waiter->Wait(index_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +41,8 @@ namespace pipeline {
|
|||||||
void Init();
|
void Init();
|
||||||
void LaunchStdin();
|
void LaunchStdin();
|
||||||
void LaunchStdout();
|
void LaunchStdout();
|
||||||
void Indexer_Main(CompletionManager *complete,
|
void Indexer_Main(CompletionManager *completion, VFS *vfs, Project *project,
|
||||||
DiagnosticsPublisher *diag_pub, VFS *vfs, Project *project,
|
WorkingFiles *wfiles);
|
||||||
WorkingFiles *working_files);
|
|
||||||
void MainLoop();
|
void MainLoop();
|
||||||
|
|
||||||
void Index(const std::string &path, const std::vector<std::string> &args,
|
void Index(const std::string &path, const std::vector<std::string> &args,
|
||||||
|
Loading…
Reference in New Issue
Block a user