Clear diagnostics if previously reported

This commit is contained in:
Jacob Dufault 2017-05-10 18:44:39 -07:00
parent 7a6174e78a
commit 20429ed397
2 changed files with 12 additions and 10 deletions

View File

@ -990,14 +990,6 @@ void ParseFile(IndexerConfig* config,
for (std::unique_ptr<IndexedFile>& new_index : indexes) {
std::cerr << "Got index for " << new_index->path << std::endl;
// Publish diagnostics.
if (!new_index->diagnostics.empty()) {
Out_TextDocumentPublishDiagnostics diag;
diag.params.uri = lsDocumentUri::FromPath(new_index->path);
diag.params.diagnostics = new_index->diagnostics;
IpcManager::instance()->SendOutMessageToClient(IpcId::TextDocumentPublishDiagnostics, diag);
}
// Load the cached index.
std::unique_ptr<IndexedFile> cached_index;
if (cache_for_args && new_index->path == cache_for_args->path)
@ -1009,6 +1001,15 @@ void ParseFile(IndexerConfig* config,
time.ResetAndPrint("Loading cached index");
// Publish diagnostics.
if (!new_index->diagnostics.empty() || (cached_index && !cached_index->diagnostics.empty())) {
Out_TextDocumentPublishDiagnostics diag;
diag.params.uri = lsDocumentUri::FromPath(new_index->path);
diag.params.diagnostics = new_index->diagnostics;
IpcManager::instance()->SendOutMessageToClient(IpcId::TextDocumentPublishDiagnostics, diag);
}
// Any any existing dependencies to |new_index| that were there before,
// because we will not reparse them if they haven't changed.
// TODO: indexer should always include dependencies. This doesn't let us remove old dependencies.
@ -1542,7 +1543,7 @@ bool QueryDbMainLoop(
working_file->pending_new_index_content = working_file->buffer_content;
queue_do_index->Enqueue(Index_DoIndex(Index_DoIndex::Type::Parse, project->FindCompilationEntryForFile(path)));
}
completion_manager->DropAllSessionsExcept(path);
completion_manager->DropAllSessionsExcept("");
break;
}

View File

@ -232,6 +232,7 @@ void Reflect(TVisitor& visitor, IndexedFile& value) {
REFLECT_MEMBER(import_file);
REFLECT_MEMBER(args);
}
REFLECT_MEMBER(diagnostics);
REFLECT_MEMBER(dependencies);
REFLECT_MEMBER(types);
REFLECT_MEMBER(funcs);
@ -288,4 +289,4 @@ optional<IndexedFile> Deserialize(std::string path, std::string serialized) {
void SetTestOutputMode() {
gTestOutputMode = true;
}
}