mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 02:39:20 +00:00
chore: use NormalizedPathBuf
This commit is contained in:
parent
23b696ca1e
commit
e6a75e80df
10 changed files with 78 additions and 89 deletions
|
@ -1,6 +1,5 @@
|
|||
use std::collections::hash_map::{Iter, Keys, Values};
|
||||
use std::fmt;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use erg_common::dict::Dict;
|
||||
use erg_common::pathutil::NormalizedPathBuf;
|
||||
|
@ -103,7 +102,7 @@ impl ModuleIndex {
|
|||
self.members.clear();
|
||||
}
|
||||
|
||||
pub fn remove_path(&mut self, path: &Path) {
|
||||
pub fn remove_path(&mut self, path: &NormalizedPathBuf) {
|
||||
self.members.retain(|loc, value| {
|
||||
value
|
||||
.referrers
|
||||
|
@ -112,8 +111,7 @@ impl ModuleIndex {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn rename_path(&mut self, old: &Path, new: PathBuf) {
|
||||
let new = NormalizedPathBuf::new(new);
|
||||
pub fn rename_path(&mut self, old: &NormalizedPathBuf, new: NormalizedPathBuf) {
|
||||
let mut new_members = Dict::new();
|
||||
for (loc, mut value) in std::mem::take(&mut self.members) {
|
||||
if value.vi.def_loc.module.as_deref() == Some(old) {
|
||||
|
@ -190,11 +188,11 @@ impl SharedModuleIndex {
|
|||
self.0.borrow_mut().initialize();
|
||||
}
|
||||
|
||||
pub fn remove_path(&self, path: &Path) {
|
||||
pub fn remove_path(&self, path: &NormalizedPathBuf) {
|
||||
self.0.borrow_mut().remove_path(path);
|
||||
}
|
||||
|
||||
pub fn rename_path(&self, old: &Path, new: PathBuf) {
|
||||
pub fn rename_path(&self, old: &NormalizedPathBuf, new: NormalizedPathBuf) {
|
||||
self.0.borrow_mut().rename_path(old, new);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue