This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Client-side support for inactive regions
Needs ReviewPublic

Authored by nridge on Sep 12 2019, 10:35 PM.

Diff Detail

Event Timeline

nridge created this revision.Sep 12 2019, 10:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2019, 10:35 PM

This is not for review yet, I'm just posting it to illustrate the client side of D67536.

nridge planned changes to this revision.Sep 15 2019, 8:00 PM
nridge updated this revision to Diff 222337.Sep 29 2019, 5:18 PM

Update to reflect changes to server side in D67536

nridge updated this revision to Diff 224483.Oct 10 2019, 2:37 PM

Updated to reflect changes to server side in D67536

nridge updated this revision to Diff 230586.Nov 21 2019, 9:04 PM

Clean up patch a bit and update tests as well

nridge retitled this revision from [WIP] [clangd] Client-side support for inactive regions to [clangd] Client-side support for inactive regions.Nov 21 2019, 9:05 PM
nridge added a reviewer: hokein.
nridge marked an inline comment as done.Nov 21 2019, 10:26 PM
nridge added inline comments.
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
220

I'm open to suggestions for how we could avoid harcoding these colors. VSCode themes do not seem to include colors for "meta.disabled" or any similar scope that would fit this role.

Perhaps we can allow the user to define the colors in clangd-specifier setting names, e.g. clangd.inactiveHighlightColor.light?

Review ping :)

sorry for the looong delay, I was OOO for a few weeks before.

The patch looks fine, my concern is that how do we support this line extension when LSP provides a standard implementation -- there is some significant progress about semantic highlighting on VSCode, VSCode now provides an experimental semantic token API, but no LSP binding yet (is not far away I think). When it is ready, we'd like to switch to that and get rid of our own implementation. Looking at the API there, it seems like we could make the line-style scope name meta.disable clangd specific, and define our own style.

clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
288

another solution that requires minimal changes (but more hacky) is that, since clangd emits a meta.disabled token with line-set-only range, we could inject the inactiveCodeDecorationType to the meta.disabled slot of Highlighter::decorationTypes, and everything should work.

nridge added a comment.EditedJan 23 2020, 2:14 PM

there is some significant progress about semantic highlighting on VSCode, VSCode now provides an experimental semantic token API, but no LSP binding yet (is not far away I think). When it is ready, we'd like to switch to that and get rid of our own implementation.

Agreed.

(One potential issue is that vscode themes don't support background styling. However, that issue has been getting a lot of attention, hopefully it too will be fixed soon.)

I do think there's value in landing this patch in the interim.

Looking at the API there, it seems like we could make the line-style scope name meta.disable clangd specific, and define our own style.

Do you mean naming the scope something like clangd.meta.disable to make it clear it's a clangd extension?

(In that case, we might as well make it something more descriptive, like clangd.preprocessor.inactive. meta doesn't convey much information.)

nridge updated this revision to Diff 240026.Jan 23 2020, 3:17 PM
nridge marked an inline comment as done.

Inject the inactive code decoration type into Highligher.decorationTypes

Unit tests: fail. 62144 tests passed, 5 failed and 811 were skipped.

failed: libc++.std/language_support/cmp/cmp_partialord/partialord.pass.cpp
failed: libc++.std/language_support/cmp/cmp_strongeq/cmp.strongeq.pass.cpp
failed: libc++.std/language_support/cmp/cmp_strongord/strongord.pass.cpp
failed: libc++.std/language_support/cmp/cmp_weakeq/cmp.weakeq.pass.cpp
failed: libc++.std/language_support/cmp/cmp_weakord/weakord.pass.cpp

clang-tidy: fail. clang-tidy found 2 errors and 0 warnings. 0 of them are added as review comments below (why?).

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Do you mean naming the scope something like clangd.meta.disable to make it clear it's a clangd extension?

(In that case, we might as well make it something more descriptive, like clangd.preprocessor.inactive. meta doesn't convey much information.)

yes, this was my suggestion.

clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
193

hmm, looks like clangd omits the InactiveCode token.

I'd suggest we send it like other tokens, that will simplify the patch, we don't need the inactiveDecorationIndex and isInactive, I think it also helps when we migrate to the official implementation. WDYT?

nridge updated this revision to Diff 247077.Feb 27 2020, 12:56 PM

Update to use 'clangd.preprocessor.inactive' as the scope name for inactive lines

nridge marked an inline comment as done.Feb 27 2020, 12:58 PM
nridge added inline comments.
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
193

This was discussed fairly extensively in the server-side review (https://reviews.llvm.org/D67536).

In the end, we decided to go with this approach of having a separate field in the protocol for inactive lines, for a variety of reasons including the one discussed in https://reviews.llvm.org/D67536#inline-616346