This is an archive of the discontinued LLVM Phabricator instance.

[clangd][NFC] Rename FSProvider and getFileSystem
ClosedPublic

Authored by kadircet on Jun 17 2020, 2:55 AM.

Details

Summary

Clangd uses FSProvider to get threadsafe views into file systems. This
patch changes naming to make that more explicit.

Depends on D81920

Diff Detail

Event Timeline

kadircet created this revision.Jun 17 2020, 2:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2020, 2:55 AM
sammccall added inline comments.Jun 17 2020, 7:37 AM
clang-tools-extra/clangd/support/FSProvider.h
0

nit: can we have ThreadsafeFS without the extra capital S? it's about as common (when you can't have hyphens) and easier to parse (since "safe" more clearly binds to "thread" rather than "fs")

0

we should rename this file as well :-(

0

RealThreadsafeFS

0

Now that we know what this abstraction is, the comment seems a bit out of place layering-wise.

Maybe we should say something about context-sensitivity at the class level, but probably shouldn't describe clangd's context-propagation here.

e.g.

Implementations may choose to depend on Context::current() e.g. to implement snapshot semantics. clangd will not create vfs::FileSystems for use in different contexts, so either ThreadsafeFS::view or the returned FS may contain this logic.

whereas here maybe just

Obtain a vfs::FileSystem with an arbitrary initial working directory.

and below

Obtain a vfs::FileSystem with a specified working directory.
If the working directory can't be set (e.g. doesn't exist), logs and returns the FS anyway.
clang-tools-extra/clangd/tool/ClangdMain.cpp
723

we need a new conventional name for these variables.

Not sure if FS works, since we may have the vfs::FileSystem in the same scope. TFS?

Ultimately we should really get rid of any mention of FSProvider in the code, I don't think it's a good name for anything anymore.
Not sure if it's more/less painful to do this in separate patches... the inconsistent naming will be confusing.

kadircet marked 6 inline comments as done.Jun 17 2020, 9:14 AM
kadircet added inline comments.
clang-tools-extra/clangd/tool/ClangdMain.cpp
723

Sent out D82024

kadircet updated this revision to Diff 271386.Jun 17 2020, 9:14 AM
kadircet marked an inline comment as done.
  • Address comments
sammccall accepted this revision.Jun 17 2020, 10:54 AM
sammccall added inline comments.
clang-tools-extra/clangd/support/ThreadsafeFS.h
31

nit: blank line here

clang-tools-extra/clangd/unittests/TestFS.h
36

this looks out of place - should it be inlined or renamed?

This revision is now accepted and ready to land.Jun 17 2020, 10:54 AM
sammccall added inline comments.Jun 17 2020, 10:57 AM
clang-tools-extra/clangd/unittests/TestFS.h
34

we can rename just to MockFS?

kadircet updated this revision to Diff 271979.Jun 19 2020, 2:57 AM
kadircet marked 4 inline comments as done.
  • Address comments
kadircet added inline comments.Jun 19 2020, 2:59 AM
clang-tools-extra/clangd/unittests/TestFS.h
36

i thought this had a ton of usage in our tests, apparently that's not the case. changed those usages to view(llvm::None) instead and inlined this.

sammccall accepted this revision.Jun 19 2020, 3:28 AM

Thanks for this, and sympathies for inevitable merge conflicts.

This revision was automatically updated to reflect the committed changes.