feat: rename modules by path (#645)

* dev: update new changes

* feat: rename modules

* dev: skip abs test
This commit is contained in:
Myriad-Dreamin 2024-10-09 14:22:23 +08:00 committed by GitHub
parent df5dafbf75
commit 5ae003efcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 498 additions and 163 deletions

View file

@ -314,6 +314,8 @@ pub static REDACT_LOC: Lazy<RedactFields> = Lazy::new(|| {
RedactFields::from_iter([
"location",
"uri",
"oldUri",
"newUri",
"range",
"changes",
"selectionRange",
@ -332,11 +334,6 @@ impl JsonRepr {
Self(s)
}
// pub fn new(v: impl serde::Serialize) -> Self {
// let s = serde_json::to_value(v).unwrap();
// Self(REDACT_URI.redact(s))
// }
pub fn new_redacted(v: impl serde::Serialize, rm: &RedactFields) -> Self {
let s = serde_json::to_value(v).unwrap();
Self(rm.redact(s))
@ -387,28 +384,17 @@ impl Redact for RedactFields {
match k {
"changes" => {
// object range => v
let obj = t.as_object().unwrap();
m.insert(
k.to_owned(),
Value::Object(
t.as_object()
.unwrap()
.iter()
.map(|(k, v)| {
(
Path::new(k)
.file_name()
.unwrap()
.to_str()
.unwrap()
.to_owned(),
v.clone(),
)
})
.collect(),
obj.iter().map(|(k, v)| (file_name(k), v.clone())).collect(),
),
);
}
"uri" | "oldUri" | "newUri" | "targetUri" => {
m.insert(k.to_owned(), file_name(t.as_str().unwrap()).into());
}
"range"
| "selectionRange"
| "originSelectionRange"
@ -436,6 +422,11 @@ impl Redact for RedactFields {
}
}
fn file_name(k: &str) -> String {
let name = Path::new(k).file_name().unwrap();
name.to_str().unwrap().to_owned()
}
pub struct HashRepr<T>(pub T);
// sha256