Skip to content

Commit

Permalink
[clangd] Update TUStatus api to accommodate preamble thread
Browse files Browse the repository at this point in the history
Summary:
TUStatus api had a single thread in mind. This introudces a section
action to represent state of the preamble thread. In the file status extension,
we keep old behavior almost the same. We only prepend current task with a
`parsing includes` if preamble thread is working. We omit the idle thread in the
output unless both threads are idle.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76304
  • Loading branch information
kadircet committed Apr 6, 2020
1 parent 276a95b commit 6b85032
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 121 deletions.
9 changes: 6 additions & 3 deletions clang-tools-extra/clangd/ClangdLSPServer.cpp
Expand Up @@ -15,6 +15,7 @@
#include "Protocol.h"
#include "SemanticHighlighting.h"
#include "SourceCode.h"
#include "TUScheduler.h"
#include "Trace.h"
#include "URI.h"
#include "refactor/Tweak.h"
Expand Down Expand Up @@ -1368,7 +1369,8 @@ ClangdLSPServer::ClangdLSPServer(
// clang-format on
}

ClangdLSPServer::~ClangdLSPServer() { IsBeingDestroyed = true;
ClangdLSPServer::~ClangdLSPServer() {
IsBeingDestroyed = true;
// Explicitly destroy ClangdServer first, blocking on threads it owns.
// This ensures they don't access any other members.
Server.reset();
Expand Down Expand Up @@ -1556,8 +1558,9 @@ void ClangdLSPServer::onFileUpdated(PathRef File, const TUStatus &Status) {
// two statuses are running faster in practice, which leads the UI constantly
// changing, and doesn't provide much value. We may want to emit status at a
// reasonable time interval (e.g. 0.5s).
if (Status.Action.S == TUAction::BuildingFile ||
Status.Action.S == TUAction::RunningAction)
if (Status.PreambleActivity == PreambleAction::Idle &&
(Status.ASTActivity.K == ASTAction::Building ||
Status.ASTActivity.K == ASTAction::RunningAction))
return;
notify("textDocument/clangd.fileStatus", Status.render(File));
}
Expand Down

0 comments on commit 6b85032

Please sign in to comment.