mirror of https://github.com/mtshiba/pylyzer
fix: filename escaping bug
This commit is contained in:
parent
ced5490fdb
commit
2ea00bf6c1
|
|
@ -253,7 +253,7 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
|||
[[package]]
|
||||
name = "els"
|
||||
version = "0.1.19-nightly.2"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#c3511a1e0395824cb0d9eccbed1ebb5ad79f5777"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#228a74d29d83907ffcb62dd849036200bd167c06"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
@ -274,7 +274,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "erg_common"
|
||||
version = "0.6.7-nightly.2"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#c3511a1e0395824cb0d9eccbed1ebb5ad79f5777"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#228a74d29d83907ffcb62dd849036200bd167c06"
|
||||
dependencies = [
|
||||
"backtrace-on-stack-overflow",
|
||||
"hermit-abi",
|
||||
|
|
@ -285,7 +285,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "erg_compiler"
|
||||
version = "0.6.7-nightly.2"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#c3511a1e0395824cb0d9eccbed1ebb5ad79f5777"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#228a74d29d83907ffcb62dd849036200bd167c06"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_parser",
|
||||
|
|
@ -294,7 +294,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "erg_parser"
|
||||
version = "0.6.7-nightly.2"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#c3511a1e0395824cb0d9eccbed1ebb5ad79f5777"
|
||||
source = "git+https://github.com/erg-lang/erg?branch=main#228a74d29d83907ffcb62dd849036200bd167c06"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"unicode-xid 0.2.4",
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ While pytype/pyright's error reports are illegible, pylyzer shows where the erro
|
|||
|
||||
* Rich LSP support 📝
|
||||
|
||||
pylyzer as a language server supports various features, such as completion and renaming.
|
||||
pylyzer as a language server supports various features, such as completion and renaming (The language server is an adaptation of the Erg Language Server (ELS). For more information on the implemented features, please see [here](https://github.com/erg-lang/erg/tree/main/crates/els#readme)).
|
||||
|
||||

|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use erg_common::config::Input;
|
||||
use erg_common::log;
|
||||
|
|
@ -41,7 +40,7 @@ pub fn gen_decl_er(input: &Input, hir: HIR, status: CheckStatus) -> DeclFile {
|
|||
};
|
||||
let status = PylyzerStatus {
|
||||
succeed: status.is_succeed(),
|
||||
file: input.full_path(),
|
||||
file: input.unescaped_path().into(),
|
||||
timestamp,
|
||||
};
|
||||
let mut code = format!("{status}\n");
|
||||
|
|
@ -64,20 +63,15 @@ pub fn gen_decl_er(input: &Input, hir: HIR, status: CheckStatus) -> DeclFile {
|
|||
code.push('\n');
|
||||
}
|
||||
log!("code:\n{code}");
|
||||
let filename = hir.name.replace(".py", ".d.er");
|
||||
let filename = input.unescaped_filename().replace(".py", ".d.er");
|
||||
DeclFile { filename, code }
|
||||
}
|
||||
|
||||
pub fn dump_decl_er(input: Input, hir: HIR, status: CheckStatus) {
|
||||
let file = gen_decl_er(&input, hir, status);
|
||||
let mut path = if let Some(path) = input.path() {
|
||||
PathBuf::from(path)
|
||||
} else {
|
||||
PathBuf::new()
|
||||
};
|
||||
path.pop();
|
||||
path.push("__pycache__");
|
||||
let pycache_dir = path.as_path();
|
||||
let mut dir = input.dir();
|
||||
dir.push("__pycache__");
|
||||
let pycache_dir = dir.as_path();
|
||||
if !pycache_dir.exists() {
|
||||
std::fs::create_dir(pycache_dir).unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ impl PythonAnalyzer {
|
|||
|
||||
pub fn run(&mut self) {
|
||||
let py_code = self.cfg.input.read();
|
||||
let filename = self.cfg.input.filename();
|
||||
let filename = self.cfg.input.unescaped_filename();
|
||||
println!("{BLUE}Start checking{RESET}: {filename}");
|
||||
match self.analyze(py_code, "exec") {
|
||||
Ok(artifact) => {
|
||||
|
|
@ -146,7 +146,10 @@ impl PythonAnalyzer {
|
|||
);
|
||||
artifact.warns.fmt_all_stderr();
|
||||
}
|
||||
println!("{GREEN}All checks OK{RESET}: {}", self.cfg.input.filename());
|
||||
println!(
|
||||
"{GREEN}All checks OK{RESET}: {}",
|
||||
self.cfg.input.unescaped_filename()
|
||||
);
|
||||
if self.cfg.output_dir.is_some() {
|
||||
dump_decl_er(
|
||||
self.cfg.input.clone(),
|
||||
|
|
@ -167,7 +170,10 @@ impl PythonAnalyzer {
|
|||
artifact.warns.fmt_all_stderr();
|
||||
}
|
||||
let code = if artifact.errors.is_empty() {
|
||||
println!("{GREEN}All checks OK{RESET}: {}", self.cfg.input.filename());
|
||||
println!(
|
||||
"{GREEN}All checks OK{RESET}: {}",
|
||||
self.cfg.input.unescaped_filename()
|
||||
);
|
||||
0
|
||||
} else {
|
||||
println!(
|
||||
|
|
|
|||
Loading…
Reference in New Issue