This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add a NewName optional parameter to clangdServer::prepareRename.
ClosedPublic

Authored by hokein on Oct 6 2020, 2:25 AM.

Details

Summary

If the NewName is provided, prepareRename would perform a name validation.

The motivation is to allow our internal embedder to implement the customized
"canRenameInto" functionality on top of prepareRename.

Diff Detail

Event Timeline

hokein created this revision.Oct 6 2020, 2:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2020, 2:25 AM
hokein requested review of this revision.Oct 6 2020, 2:25 AM
sammccall accepted this revision.Oct 6 2020, 2:46 AM
sammccall added inline comments.
clang-tools-extra/clangd/ClangdLSPServer.cpp
797–798

please make this optional rather than using "" as a sentinel value. The empty string is a plausible value here (though of course will always fail)

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

we can fail already here if the name is specified and empty

This revision is now accepted and ready to land.Oct 6 2020, 2:46 AM

Can you add a bit more context to the commit message?

And should we expose this as an extension on textDocument/prepareRename?

hokein updated this revision to Diff 296622.Oct 7 2020, 2:03 AM
hokein marked an inline comment as done.

make NewName optional.

hokein added a comment.Oct 7 2020, 2:04 AM

Can you add a bit more context to the commit message?

And should we expose this as an extension on textDocument/prepareRename?

no needed right now. AFAIK, there are no lsp clients that would use that.

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

yeah, we could do that, but not sure this is a good idea:

  • adding special-case code (I'd like to avoid)
  • error-message might be re-prioritized -- if an invalid pos, and empty new name are passed through this API, we will emit error message "the name is empty" rather than "no symbol was found", I think "no symbol was found" is slightly more important than the "name is empty";
hokein edited the summary of this revision. (Show Details)Oct 7 2020, 2:05 AM
hokein edited the summary of this revision. (Show Details)
danielmartin added inline comments.
clang-tools-extra/clangd/ClangdServer.h
277
hokein added inline comments.Oct 8 2020, 12:36 AM
clang-tools-extra/clangd/ClangdServer.h
277