Skip to content

Commit ebb76b7

Browse files
mmahroussfda-odoo
authored andcommitted
[FIX] server: find_module should only return modules
1 parent 572c462 commit ebb76b7

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

server/src/core/import_resolver.rs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use glob::glob;
22
use lsp_types::{Diagnostic, DiagnosticSeverity, DiagnosticTag, NumberOrString, Position, Range};
3-
use tracing::{error, info};
3+
use tracing::error;
44
use std::collections::{HashMap, HashSet};
55
use std::rc::Rc;
66
use std::cell::RefCell;
@@ -12,8 +12,8 @@ use crate::{constants::*, oyarn, Sy, S};
1212
use crate::threads::SessionInfo;
1313
use crate::utils::{is_dir_cs, is_file_cs, PathSanitizer};
1414

15-
use super::entry_point::{self, EntryPoint, EntryPointType};
16-
use super::file_mgr::{add_diagnostic, NoqaInfo};
15+
use super::entry_point::{EntryPoint, EntryPointType};
16+
use super::file_mgr::add_diagnostic;
1717
use super::odoo::SyncOdoo;
1818
use super::symbols::symbol::Symbol;
1919

@@ -185,24 +185,15 @@ pub fn find_module(session: &mut SessionInfo, odoo_addons: Rc<RefCell<Symbol>>,
185185
let paths = (*odoo_addons).borrow().paths().clone();
186186
for path in paths.iter() {
187187
let full_path = Path::new(path.as_str()).join(name.as_str());
188-
if is_dir_cs(full_path.sanitize()) {
189-
let _arc_symbol = Symbol::create_from_path(session, &full_path, odoo_addons.clone(), false);
190-
if _arc_symbol.is_some() {
191-
let typ = _arc_symbol.as_ref().unwrap().borrow().typ();
192-
match typ {
193-
SymType::NAMESPACE => {
194-
return Some(_arc_symbol.as_ref().unwrap().clone());
195-
},
196-
SymType::PACKAGE(_) => {
197-
let _arc_symbol = _arc_symbol.as_ref().unwrap().clone();
198-
session.sync_odoo.modules.insert(name.clone(), Rc::downgrade(&_arc_symbol));
199-
session.sync_odoo.add_to_rebuild_arch(_arc_symbol.clone());
200-
return Some(_arc_symbol);
201-
},
202-
_ => {return None}
203-
}
204-
}
188+
if !is_dir_cs(full_path.sanitize()) {
189+
continue;
205190
}
191+
let Some(module_symbol) = Symbol::create_from_path(session, &full_path, odoo_addons.clone(), true) else {
192+
continue;
193+
};
194+
session.sync_odoo.modules.insert(name.clone(), Rc::downgrade(&module_symbol));
195+
session.sync_odoo.add_to_rebuild_arch(module_symbol.clone());
196+
return Some(module_symbol.clone());
206197
}
207198
None
208199
}

0 commit comments

Comments
 (0)