Browse Source

Add diagnostics.onSave

pull/522/head
Fangrui Song 6 years ago
parent
commit
68a27e746d
  1. 5
      src/config.h
  2. 3
      src/messages/initialize.cc
  3. 2
      src/messages/textDocument_didSave.cc
  4. 11
      src/pipeline.cc
  5. 5
      src/pipeline.hh

5
src/config.h

@ -142,6 +142,9 @@ struct Config {
// If true, diagnostics will be reported for textDocument/didOpen.
bool onOpen = true;
// If true, diagnostics will be reported for textDocument/didSave.
bool onSave = true;
bool spellChecking = true;
std::vector<std::string> whitelist;
@ -228,7 +231,7 @@ MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, dropOldRequests,
includeMaxPathSize, includeSuffixWhitelist,
includeWhitelist);
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::Index, blacklist, comments, enabled, multiVersion,
multiVersionBlacklist, multiVersionWhitelist, onChange,

3
src/messages/initialize.cc

@ -484,8 +484,7 @@ struct Handler_Initialize : BaseMessageHandler<In_InitializeRequest> {
g_thread_id = i + 1;
std::string name = "indexer" + std::to_string(i);
set_thread_name(name.c_str());
pipeline::Indexer_Main(clang_complete, diag_pub, vfs, project,
working_files);
pipeline::Indexer_Main(clang_complete, vfs, project, working_files);
})
.detach();
}

2
src/messages/textDocument_didSave.cc

@ -37,6 +37,8 @@ struct Handler_TextDocumentDidSave
Project::Entry entry = project->FindCompilationEntryForFile(path);
pipeline::Index(entry.filename, entry.args, IndexMode::Normal);
clang_complete->NotifySave(path);
if (g_config->diagnostics.onSave)
clang_complete->DiagnosticsUpdate(params.textDocument);
}
};
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidSave);

11
src/pipeline.cc

@ -153,8 +153,7 @@ std::unique_ptr<IndexFile> RawCacheLoad(const std::string &path) {
IndexFile::kMajorVersion);
}
bool Indexer_Parse(CompletionManager *completion,
DiagnosticsPublisher *diag_pub, WorkingFiles *wfiles,
bool Indexer_Parse(CompletionManager *completion, WorkingFiles *wfiles,
Project *project, VFS *vfs, const GroupMatch &matcher) {
std::optional<Index_Request> opt_request = index_request->TryPopFront();
if (!opt_request)
@ -337,13 +336,11 @@ void Init() {
for_stdout = new ThreadedQueue<Stdout_Request>(stdout_waiter);
}
void Indexer_Main(CompletionManager *completion,
DiagnosticsPublisher *diag_pub, VFS *vfs, Project *project,
WorkingFiles *working_files) {
void Indexer_Main(CompletionManager *completion, VFS *vfs, Project *project,
WorkingFiles *wfiles) {
GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist);
while (true)
if (!Indexer_Parse(completion, diag_pub, working_files, project, vfs,
matcher))
if (!Indexer_Parse(completion, wfiles, project, vfs, matcher))
indexer_waiter->Wait(index_request);
}

5
src/pipeline.hh

@ -41,9 +41,8 @@ namespace pipeline {
void Init();
void LaunchStdin();
void LaunchStdout();
void Indexer_Main(CompletionManager *complete,
DiagnosticsPublisher *diag_pub, VFS *vfs, Project *project,
WorkingFiles *working_files);
void Indexer_Main(CompletionManager *completion, VFS *vfs, Project *project,
WorkingFiles *wfiles);
void MainLoop();
void Index(const std::string &path, const std::vector<std::string> &args,

Loading…
Cancel
Save