This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Support multiple cursors in selectionRange.
ClosedPublic

Authored by sammccall on Mar 24 2020, 4:56 PM.

Details

Summary

One change: because there's no way to signal failure individually for
each cursor, we now "succeed" with an empty range with no parent if a
cursor doesn't point at anything.

Diff Detail

Event Timeline

sammccall created this revision.Mar 24 2020, 4:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2020, 4:56 PM

Mostly looks good. Few nits. Thanks.

clang-tools-extra/clangd/ClangdLSPServer.cpp
1193–1194

You can remove this check now.

clang-tools-extra/clangd/ClangdServer.cpp
671

nit: return statement can be omitted.

clang-tools-extra/clangd/SemanticSelection.cpp
65

nit: s/Dummy/Empty ?

74

nit:Range can be made a const ref.

clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
175

I think it would be better to name the two points in the test and explicitly specify their order in the request (instead of relying on SourceAnnotations.points()).
Annotations::points doesn't guarantee order in its contract. Even if the current implementation does, it would be better to be explicit and not rely on it.

sammccall updated this revision to Diff 252545.Mar 25 2020, 5:04 AM
sammccall marked 8 inline comments as done.

Address comments

clang-tools-extra/clangd/ClangdLSPServer.cpp
1193–1194

Oops!

clang-tools-extra/clangd/SemanticSelection.cpp
74

Oops, fixed to actually move.

clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
175

Good point. I updated the documentation on Annotations instead to make this guarantee, this was always the intent.

usaxena95 accepted this revision.Mar 25 2020, 6:19 AM

Thanks. LG.

This revision is now accepted and ready to land.Mar 25 2020, 6:19 AM
This revision was automatically updated to reflect the committed changes.