This is an archive of the discontinued LLVM Phabricator instance.

[clangd:vscode] Resolve symlinks for file paths from clangd.
ClosedPublic

Authored by ioeric on Mar 6 2018, 8:46 AM.

Details

Summary

For features like go-to-definition, clangd can point clients to symlink paths
(e.g. in bazel execroot) which might not be desired if the symlink points to a
file in the workspace. Clangd might not be able to build the file, and users
might prefer to edit the file on the real path.

This change converts file paths from clangd to real path (e.g. resolving symlinks).
Long term, we might want to the symlink handling logic to clangd where clangd
can better decide whether symlinks should be resolved according to e.g. compile
commands.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric created this revision.Mar 6 2018, 8:46 AM
sammccall accepted this revision.Mar 8 2018, 5:41 AM

LG. Can you expand the comment and fix the formatting changes?

clangd/clients/clangd-vscode/src/extension.ts
3 ↗(On Diff #137211)

nit: the braces don't do anything here, right?

28 ↗(On Diff #137211)

(this is an unrelated formatting change, so consider reverting anyway)
My clang-format doesn't add the whitespace inside {}, and the indentation change seems just wrong... what are you using to format?

41 ↗(On Diff #137211)

I think this comment needs to be more precise, because it's important we know when to remove this.

This is a workaround for a bazel + clangd issue - bazel produces a symlink tree to build in, and when navigating to the included file, clangd passes its path inside the symlink tree rather than its filesystem path. We work around this by resolving all symlinks on the client.
We should remove this once clangd knows enough about bazel to resolve the symlinks where needed (or if this causes problems for other workflows).

(that's not necessarily text that needs to go into the comment, but I think all the information does...)

This revision is now accepted and ready to land.Mar 8 2018, 5:41 AM
ioeric updated this revision to Diff 137564.Mar 8 2018, 6:51 AM
ioeric marked an inline comment as done.
  • add context about the workaround.
ioeric added inline comments.Mar 8 2018, 6:52 AM
clangd/clients/clangd-vscode/src/extension.ts
3 ↗(On Diff #137211)

I'm not sure... this was added by vscode.

28 ↗(On Diff #137211)

This was also vscode which formats a whole file by default. Yeah, it's unrelated, but it's a bit annoying to revert all formatting changes...

Regarding the indentation, I think it just follows the current indentation in the file.

41 ↗(On Diff #137211)

Done. Thanks!

This revision was automatically updated to reflect the committed changes.