[PATCH] D76741: [clangd] Support multiple cursors in selectionRange.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 25 05:22:39 PDT 2020
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1194-1201
if (Params.positions.size() != 1) {
elog("{0} positions provided to SelectionRange. Supports exactly one "
"position.",
Params.positions.size());
return Reply(llvm::make_error<LSPError>(
"SelectionRange supports exactly one position",
ErrorCode::InvalidRequest));
----------------
usaxena95 wrote:
> You can remove this check now.
Oops!
================
Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:74
+ SelectionRange *Tail = &Head;
+ for (auto &Range : llvm::makeArrayRef(Ranges).drop_front()) {
+ Tail->parent = std::make_unique<SelectionRange>();
----------------
usaxena95 wrote:
> nit:`Range` can be made a `const` ref.
Oops, fixed to actually move.
================
Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:175
- auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.point());
+ auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.points());
ASSERT_TRUE(bool(Ranges))
----------------
usaxena95 wrote:
> 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.
Good point. I updated the documentation on Annotations instead to make this guarantee, this was always the intent.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76741/new/
https://reviews.llvm.org/D76741
More information about the cfe-commits
mailing list