feat: lint on bug-like show/set rules (#1634)

* feat: init linter

* feat: init structure

* feat: init tests

* feat: warn on bad set rules

* feat: refactor struct

* feat: run check

* chore: update message

* chore: add hints
This commit is contained in:
Myriad-Dreamin 2025-04-08 07:36:03 +08:00 committed by GitHub
parent ac506dcc31
commit d6bce89e68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 664 additions and 51 deletions

View file

@ -477,12 +477,16 @@ impl Redact for RedactFields {
}
pub(crate) fn file_path(uri: &str) -> String {
file_path_(&lsp_types::Url::parse(uri).unwrap())
}
pub(crate) fn file_path_(uri: &lsp_types::Url) -> String {
let root = if cfg!(windows) {
PathBuf::from("C:\\root")
} else {
PathBuf::from("/root")
};
let uri = lsp_types::Url::parse(uri).unwrap().to_file_path().unwrap();
let uri = uri.to_file_path().unwrap();
let abs_path = Path::new(&uri).strip_prefix(root).map(|p| p.to_owned());
let rel_path =
abs_path.unwrap_or_else(|_| Path::new("-").join(Path::new(&uri).iter().last().unwrap()));