Skip to content

[ra_ap_vfs] Provide fallible API to fetch file path from file ID #19280

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

Closed
snprajwal opened this issue Mar 4, 2025 · 4 comments
Closed

[ra_ap_vfs] Provide fallible API to fetch file path from file ID #19280

snprajwal opened this issue Mar 4, 2025 · 4 comments
Labels
C-feature Category: feature request

Comments

@snprajwal
Copy link
Contributor

Currently, the API to retrieve a file path from the VFS with a file ID (https://docs.rs/ra_ap_vfs/latest/ra_ap_vfs/struct.Vfs.html#method.file_path) panics if the file does not exist in the VFS. An exists() boolean method allows a preliminary check, but it would be great to have a fallible API that returns an Option<&VfsPath> and saves the user from having to do an existential check every time. Maybe it can be named file_path_if_exists()? I'm open to ideas, and am happy to contribute this addition!

@snprajwal snprajwal added the C-feature Category: feature request label Mar 4, 2025
@lnicola
Copy link
Member

lnicola commented Mar 4, 2025

How are you getting a FileId that doesn't exist? We seem to use exists in a single place in the entirety of r-a, for an id that's passed back by the client (in a /resolve request).

@snprajwal
Copy link
Contributor Author

I am writing an analysis engine that builds a Cargo project, and then retrieves individual file IDs while walking the HIR. Building the project returns a (db, vfs): (RootDatabase, Vfs) tuple, but I wasn't sure if the two are guaranteed to be in sync across edits. If that is the case, then a fallible method would not be necessary.

@davidbarsky
Copy link
Contributor

They're not guaranteed to be sync across edits (see #15837), but they will be in sync with the changes planned in #18948.

@snprajwal
Copy link
Contributor Author

Got it, thank you! Looking forward to seeing the new reworked VFS API. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

3 participants