chore: add --use-pylyzer option

This commit is contained in:
Shunsuke Shibayama 2024-10-18 16:32:31 +09:00
parent e8d98e5431
commit e7bc8b10ae
3 changed files with 50 additions and 29 deletions

View file

@ -179,6 +179,7 @@ pub struct ErgConfig {
pub packages: ArcArray<Package>,
pub effect_check: bool,
pub ownership_check: bool,
pub use_pylyzer: bool,
}
impl Default for ErgConfig {
@ -206,6 +207,7 @@ impl Default for ErgConfig {
packages: ArcArray::from([]),
effect_check: true,
ownership_check: true,
use_pylyzer: false,
}
}
}
@ -340,6 +342,9 @@ impl ErgConfig {
None,
));
}
"--use-pylyzer" => {
cfg.use_pylyzer = true;
}
"--use-local-package" => {
let name = args
.next()

View file

@ -630,7 +630,9 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
if self.cfg.input.path() == path.as_path() {
return Ok(path);
}
let (out, err) = if self.cfg.mode == ErgMode::LanguageServer || self.cfg.quiet_repl {
if self.cfg.use_pylyzer {
let (out, err) = if self.cfg.mode == ErgMode::LanguageServer || self.cfg.quiet_repl
{
(Stdio::null(), Stdio::null())
} else {
(Stdio::inherit(), Stdio::inherit())
@ -664,6 +666,7 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
}
}
}
}
Err(())
}

View file

@ -1,5 +1,6 @@
use std::fmt;
use erg_common::consts::DEBUG_MODE;
use erg_common::pathutil::NormalizedPathBuf;
use erg_common::set;
use erg_common::set::Set;
@ -95,6 +96,12 @@ impl ModuleGraph {
}
pub fn add_node_if_none(&mut self, path: &NormalizedPathBuf) {
if path.is_dir() {
if DEBUG_MODE {
panic!("path is a directory: {path}");
}
return;
}
if self.0.iter().all(|n| &n.id != path) {
let node = Node::new(path.clone(), (), set! {});
self.0.push(node);
@ -107,6 +114,12 @@ impl ModuleGraph {
referrer: &NormalizedPathBuf,
depends_on: NormalizedPathBuf,
) -> Result<(), IncRefError> {
if depends_on.is_dir() {
if DEBUG_MODE {
panic!("path is a directory: {depends_on}");
}
return Ok(());
}
self.add_node_if_none(referrer);
if referrer == &depends_on {
return Ok(());