This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Introduce client state invalidation
ClosedPublic

Authored by kadircet on Feb 26 2021, 5:46 AM.

Details

Summary

Clangd can invalidate client state of features like semantic higlighting
without client explicitly triggering, for example after a preamble build
caused by an onSave notification on a different file.

This patch introduces a mechanism to let client know of such actions,
and also calls the workspace/semanticTokens/refresh request to
demonstrate the situation after each preamble build.

Fixes https://github.com/clangd/clangd/issues/699

Diff Detail

Event Timeline

kadircet created this revision.Feb 26 2021, 5:46 AM
kadircet requested review of this revision.Feb 26 2021, 5:46 AM
kadircet added inline comments.Feb 26 2021, 5:48 AM
clang-tools-extra/clangd/test/semantic-tokens-refresh.test
13

lsp spec says params: none for this request. i am not sure if this is acceptable or if we should really change our transport layer to accommodate optional parameters. can't really test it on vscode atm unfortunately :/

kadircet edited the summary of this revision. (Show Details)Feb 26 2021, 5:49 AM
nridge added a subscriber: nridge.Feb 27 2021, 11:59 PM
sammccall accepted this revision.Mar 3 2021, 9:27 PM
sammccall added inline comments.
clang-tools-extra/clangd/ClangdServer.h
78

I think "state change", "client information" and "requesting it" might be a bit too vague.
Some ideas to take or leave...

"onSemanticsMaybeChanged"

Called when the meaning of a source code may have changed without an edit.
Usually clients assume that responses to requests are valid until they next
edit the file. If they're invalidated at other times, we should tell the client.
In particular, when an asynchronous preamble build finishes, we can provide
more accurate semantic tokens, so we should tell the client to refresh.

This revision is now accepted and ready to land.Mar 3 2021, 9:27 PM
kadircet updated this revision to Diff 328067.Mar 4 2021, 1:36 AM
kadircet marked an inline comment as done.
  • Rename method and update comment
This revision was landed with ongoing or failed builds.Mar 4 2021, 2:15 AM
This revision was automatically updated to reflect the committed changes.