Skip to content

Commit 6b85032

Browse files
committed
[clangd] Update TUStatus api to accommodate preamble thread
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
1 parent 276a95b commit 6b85032

File tree

4 files changed

+184
-121
lines changed

4 files changed

+184
-121
lines changed

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Protocol.h"
1616
#include "SemanticHighlighting.h"
1717
#include "SourceCode.h"
18+
#include "TUScheduler.h"
1819
#include "Trace.h"
1920
#include "URI.h"
2021
#include "refactor/Tweak.h"
@@ -1368,7 +1369,8 @@ ClangdLSPServer::ClangdLSPServer(
13681369
// clang-format on
13691370
}
13701371

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

0 commit comments

Comments
 (0)