mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Introduce anchored_path
They allow to represent paths like `#[path = "C:\path.rs"] mod foo;` in a lossless cross-platform & network-transparent way.
This commit is contained in:
parent
5e3891c255
commit
6e24321e45
13 changed files with 79 additions and 65 deletions
|
@ -13,6 +13,7 @@ use lsp_types::{SemanticTokens, Url};
|
|||
use parking_lot::{Mutex, RwLock};
|
||||
use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
||||
use rustc_hash::FxHashMap;
|
||||
use vfs::AnchoredPathBuf;
|
||||
|
||||
use crate::{
|
||||
config::Config,
|
||||
|
@ -268,10 +269,10 @@ impl GlobalStateSnapshot {
|
|||
Some(self.mem_docs.get(&path)?.version)
|
||||
}
|
||||
|
||||
pub(crate) fn anchored_path(&self, file_id: FileId, path: &str) -> Url {
|
||||
let mut base = self.vfs.read().0.file_path(file_id);
|
||||
pub(crate) fn anchored_path(&self, path: &AnchoredPathBuf) -> Url {
|
||||
let mut base = self.vfs.read().0.file_path(path.anchor);
|
||||
base.pop();
|
||||
let path = base.join(path).unwrap();
|
||||
let path = base.join(&path.path).unwrap();
|
||||
let path = path.as_path().unwrap();
|
||||
url_from_abs_path(&path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue