-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DSLX:LS] Fix/tighten up URI/path conversions, use VirtualizableFilesystem pervasively in DSLX #1737
base: main
Are you sure you want to change the base?
Conversation
00b8dd2
to
eb5ebb5
Compare
Very nice! Running (I found that our current way of building the compilation DB has issues (at least on Linux) to properly succeed because it is confused about the dylib stuff, so I found on Linux I have to comment out in
) |
cdde564
to
06cf7bf
Compare
Fixed almost all actionable clang-tidies outside of contrib, PTAL. |
We now have a wrapper type to indicate when things have been checked to be in URI form, and that type offers convenience APIs for conversion to `string_view` for the underlying and to `std::filesystem::path` to strip off the URI prefix. We also add a hook to the virtual filesystem layer to allow the LSP filesystem implementation to validate that the "paths" being resolved are in fact all in canonical URI form. Previously we ran into trouble because the stdlib path was a relative path and pointed directly at the filesystem, and thus was clashing with the expectation that everything would be in URI form; i.e. a module would import a stdlib module and then that would have a filesystem (non-URI) path, and that would potentially import other stdlib modules with more filesystem (non-URI) paths. We check as invariant in the file table that no URIs are held there -- the conversion into and out of URI form happens on the import boundary. This PR also plumbs virtualizable filesystem into the error printing routines so they don't try to look at the real filesystem when they should be looking at the virtualized filesystem contents, e.g. in any error reporting done for parse errors encounterd by the LSP. Now that the LSP-parsed span filenames look indistinguishable from real filesystem filenames we have to be a bit more careful to use the virtual filesystem abstraction instead of the real filesystem in retrieving file contents. This also plumbs the virtual filesystem in everywhere to places that GetContents is called to ensure consistency across the DSLX facilities. In general we shouldn't need to rely on `//xls/common/file:filesystem` as a dep except in tools that write output files (as the VirtualizableFileSystem doesn't have SetContents). Ran clang-format and clang-tidy and bant
06cf7bf
to
95c6762
Compare
The github PR to google internal submission is already cumbersome so I think we should avoid adding the additional requirement of keeping things include clean. Include cleanliness, in general, is of small value (not zero, but small). I don't think it is worth people's time to either check for cleanliness on PR's or go much out of your way to fix them. We have tools internally which can better handle these cleanups such as automatically flagging them in code review and transforming the code automatically. We can do this on a regular cadence internally if we care enough. |
Review note:
UniformContentFilesystem
).We now have a wrapper type to indicate when things have been checked to be in URI form, and that type offers convenience APIs for conversion to
string_view
for the underlying and tostd::filesystem::path
to strip off the URI prefix.Previously we ran into trouble in #1731 because the stdlib path was a relative path and pointed directly at the filesystem, and thus was clashing with the expectation that everything would be in URI form; i.e. a module would import a stdlib module and then that would have a filesystem (non-URI) path, and that would potentially import other stdlib modules with more filesystem (non-URI) paths.
We check as invariant in the file table that no URIs are held there -- the conversion into and out of URI form happens on the import boundary.
This PR also plumbs virtualizable filesystem into the error printing routines so they don't try to look at the real filesystem when they should be looking at the virtualized filesystem contents, e.g. in any error reporting done for parse errors encounterd by the LSP. Now that the LSP-parsed span filenames look indistinguishable from real filesystem filenames we have to be more careful to always try to use the virtual filesystem abstraction instead of
xls/common/file/filesystem.h
routines in retrieving file contents.This, as a result, plumbs the virtual filesystem in everywhere to places that GetContents is called to ensure consistency across the DSLX facilities. In general we shouldn't need to rely on
//xls/common/file:filesystem
as a dep except in tools that write output files (as the VirtualizableFileSystem doesn't have SetContents). Note that usually there is an ImportData around somewhere, as it is a fairly primordial context-like object, and there is avfs()
hanging off of that.Ran clang-tidy and bant dwyu