Skip to content

Commit 251570a

Browse files
authored
Merge pull request #310 from Pivot-Studio/fix/lsp_wasm_circle
fix: wasm circle
2 parents 0e2d9ac + a35d7e4 commit 251570a

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

.github/workflows/npmpkg.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/*
7+
- wasm/*
78
paths:
89
- '**.rs'
910
- '**/Cargo.*'

src/ast/compiler.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use inkwell::{
1717
passes::{PassManager, PassManagerBuilder},
1818
OptimizationLevel,
1919
};
20-
use log::{debug, trace, warn};
20+
use log::{trace, warn};
2121
#[cfg(feature = "llvm")]
2222
use pl_linker::{linker::create_with_target, mun_target::spec::Target};
2323
use rustc_hash::FxHashSet;
@@ -50,6 +50,7 @@ pub fn compile_dry(db: &dyn Db, docs: MemDocsInput) -> Option<ModWrapper> {
5050
let input = docs.get_file_params(db, docs.file(db).clone(), true);
5151
input?;
5252
let input = input.unwrap();
53+
log::trace!("entering compile_dry_file");
5354
let re = compile_dry_file(db, input);
5455
// calculate find references results
5556
if docs.action(db) != ActionType::FindReferences {
@@ -77,7 +78,7 @@ pub fn compile_dry_file(db: &dyn Db, docs: FileCompileInput) -> Option<ModWrappe
7778
let re = docs.get_file_content(db);
7879
re?;
7980
let src = re.unwrap();
80-
debug!("src {:#?} id {:?}", src.text(db), src);
81+
log::trace!("src {:#?} id {:?}", src.text(db), src.path(db));
8182
let parse_result = parse(db, src);
8283
if let Err(e) = parse_result {
8384
log::error!("source code parse failed {}", e);
@@ -91,6 +92,7 @@ pub fn compile_dry_file(db: &dyn Db, docs: FileCompileInput) -> Option<ModWrappe
9192
docs.docs(db),
9293
docs.config(db),
9394
);
95+
log::trace!("entering emit");
9496
Some(program.emit(db))
9597
}
9698

src/ast/node/program.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ impl Program {
235235
let wrapper = ConfigWrapper::new(db, self.config(db), u);
236236
let mut mod_id = wrapper.use_node(db).get_last_id();
237237
let path = wrapper.resolve_dep_path(db);
238+
let p = self.config(db).project;
239+
log::trace!("load dep {:?} for {:?} (project {:?})", path, pkgname, p);
238240
let f = path.to_str().unwrap().to_string();
239241
let mut f = self.docs(db).get_file_params(db, f, false);
240242
let mut symbol_opt = None;
@@ -291,6 +293,7 @@ impl Program {
291293
}
292294
modmap.insert(mod_id.unwrap(), module);
293295
}
296+
log::trace!("done deps compile");
294297
let filepath = Path::new(self.params(db).file(db));
295298
let abs = crate::utils::canonicalize(filepath).unwrap();
296299
let dir = abs.parent().unwrap().to_str().unwrap();
@@ -489,7 +492,7 @@ mod salsa_structs;
489492
/// compile a pi file to llvm ir, or do some lsp analysis
490493
#[salsa::tracked]
491494
pub fn emit_file(db: &dyn Db, params: ProgramEmitParam) -> ModWrapper {
492-
log::info!("emit_file: {}", params.fullpath(db),);
495+
log::trace!("emit_file: {}", params.fullpath(db),);
493496
let v = RefCell::new(FxHashSet::default());
494497
let mut ctx = ctx::Ctx::new(
495498
params.fullpath(db),

src/lsp/wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn add_pl_libs(db: &mut Database, docs: Arc<Mutex<RefCell<MemDocs>>>) {
174174
#[wasm_bindgen]
175175
pub fn set_init_content(content: &str) -> String {
176176
console_error_panic_hook::set_once();
177-
wasm_logger::init(wasm_logger::Config::new(log::Level::Error));
177+
wasm_logger::init(wasm_logger::Config::new(log::Level::Warn));
178178
let docin = *DOCIN;
179179
let binding = &DB.inner;
180180
let db = &mut *binding.borrow_mut();

src/utils/read_config.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ use crate::{
1111
};
1212

1313
pub fn get_config_path(current: String) -> Result<String, &'static str> {
14+
log::trace!("get_config_path: {:?}", current);
1415
#[cfg(target_arch = "wasm32")] // TODO support std on wasm
15-
return Ok("http://www.test.com/Kagari.toml".to_string());
16+
{
17+
if current.starts_with("http") {
18+
return Ok("http://www.test.com/Kagari.toml".to_string());
19+
}
20+
if current.starts_with("core") {
21+
return Ok("core/Kagari.toml".to_string());
22+
} else if current.starts_with("std") {
23+
return Ok("std/Kagari.toml".to_string());
24+
}
25+
}
1626

1727
let mut cur_path = PathBuf::from(current);
1828
if cur_path.is_file() && !cur_path.pop() {

0 commit comments

Comments
 (0)