Skip to content

Commit c495a0a

Browse files
committed
wip.
1 parent 24f3d01 commit c495a0a

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

Diff for: server/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ harness = false
4242
iai-callgrind = "0.14.0"
4343

4444
[features]
45-
default = []
45+
default = ["debug_yarn"]
4646
debug_yarn = [] # use a readable structure instead of Yarn for debug purpose

Diff for: server/src/constants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use byteyarn::{yarn, Yarn};
66
pub const EXTENSION_NAME: &str = "Odoo";
77
pub const EXTENSION_VERSION: &str = "0.4.1";
88

9-
pub const DEBUG_ODOO_BUILDER: bool = false;
9+
pub const DEBUG_ODOO_BUILDER: bool = true;
1010
pub const DEBUG_MEMORY: bool = false;
1111
pub const DEBUG_THREADS: bool = false;
12-
pub const DEBUG_STEPS: bool = false;
12+
pub const DEBUG_STEPS: bool = true;
1313

1414
pub type Tree = (Vec<OYarn>, Vec<OYarn>);
1515

Diff for: server/src/core/import_resolver.rs

+19
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ pub fn resolve_import_stmt(session: &mut SessionInfo, source_file_symbol: &Rc<Re
9797
let mut name_index: i32 = -1;
9898
for alias in name_aliases.iter() {
9999
let name = oyarn!("{}", alias.name);
100+
if name == "odoo.init" {
101+
println!("here");
102+
}
100103
name_index += 1;
101104
if let Some(hook_result) = resolve_import_stmt_hook(alias, &from_symbol, session, source_file_symbol, from_stmt, level, diagnostics){
102105
result[name_index as usize] = hook_result;
@@ -135,6 +138,19 @@ pub fn resolve_import_stmt(session: &mut SessionInfo, source_file_symbol: &Rc<Re
135138
result[name_index as usize].name = name.split(".").map(|s| oyarn!("{}", s)).next().unwrap();
136139
result[name_index as usize].found = true;
137140
result[name_index as usize].symbol = name_symbol.as_ref().unwrap().clone();
141+
//we found name_symbol and will return it. But in the case of "import A.B.C", even if we will return A, we need to effectively import B then
142+
//C as it can have effects on the codebase
143+
let name_split: Vec<OYarn> = name.split(".").map(|s| oyarn!("{}", s)).collect();
144+
if name_split.len() > 1 {
145+
_get_or_create_symbol(
146+
session,
147+
&entry,
148+
source_path.as_str(),
149+
Some(name_symbol.as_ref().unwrap().clone()),
150+
&Vec::from_iter(name_split[1..name_split.len()].iter().cloned()),
151+
None,
152+
None);
153+
}
138154
continue;
139155
}
140156
let name_split: Vec<OYarn> = name.split(".").map(|s| oyarn!("{}", s)).collect();
@@ -367,6 +383,9 @@ fn _resolve_new_symbol(session: &mut SessionInfo, parent: Rc<RefCell<Symbol>>, n
367383
let _arc_symbol = Symbol::create_from_path(session, &full_path.with_extension("py"), parent.clone(), false);
368384
if _arc_symbol.is_some() {
369385
let _arc_symbol = _arc_symbol.unwrap();
386+
if full_path.ends_with("init.py") {
387+
println!("here");
388+
}
370389
SyncOdoo::rebuild_arch_now(session, &_arc_symbol);
371390
return Ok(_arc_symbol);
372391
}

Diff for: server/src/core/odoo.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ impl SyncOdoo {
324324
panic!("Odoo root symbol not found")
325325
};
326326
odoo_sym.borrow_mut().set_is_external(false);
327-
let odoo_odoo = Symbol::create_from_path(session, &config_odoo_path.join("odoo"), odoo_sym.clone(), false);
328-
if odoo_odoo.is_none() {
329-
panic!("Not able to find odoo with given path. Aborting...");
330-
}
327+
//let odoo_odoo = Symbol::create_from_path(session, &config_odoo_path.join("odoo"), odoo_sym.clone(), false);
328+
//Force the creation of "odoo" to be a package, even if it is a namespace
329+
let path_str = config_odoo_path.join("odoo").sanitize();
330+
let odoo_odoo = Some(odoo_sym.borrow_mut().add_new_python_package(session, &S!("odoo"), &path_str));
331331
let odoo_typ = odoo_odoo.as_ref().unwrap().borrow().typ().clone();
332332
match odoo_typ {
333333
SymType::PACKAGE(PackageType::PYTHON_PACKAGE) => {

0 commit comments

Comments
 (0)