Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ebresafegaga committed Dec 23, 2022
1 parent 859ea52 commit 6101754
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
4 changes: 1 addition & 3 deletions lsp/nls/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ impl CacheExt for Cache {
}

if let Ok(CacheOp::Done(ids)) = self.resolve_imports(file_id) {
// TODO: we need a way to stop infite recursion with imports
for id in ids {
if id == file_id {
// Avoid infinite recursion
continue;
}
// Linearize all imports in this file
// NOTE: This only goes down one level
self.typecheck_with_analysis(id, initial_ctxt, initial_env, lin_cache)
.unwrap();
}
Expand Down
8 changes: 2 additions & 6 deletions lsp/nls/src/linearization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod interface;
// Cache of completed items
static mut LIN_CACHE: Option<HashMap<FileId, Completed>> = None;

fn update(file: FileId, value: Completed) {
fn update_lin_cache(file: FileId, value: Completed) {
unsafe {
match &mut LIN_CACHE {
Some(table) => {
Expand Down Expand Up @@ -239,8 +239,6 @@ impl<'a> Linearizer for AnalysisHost<'a> {
for matched in destruct.to_owned().inner() {
let (ident, term) = matched.as_meta_field();

// self.add_term(lin, term.as_ref(), pos, ty);

let id = ItemId {
file_id: self.file,
index: id_gen.get_and_advance(),
Expand All @@ -255,8 +253,6 @@ impl<'a> Linearizer for AnalysisHost<'a> {
kind: TermKind::Declaration(
ident.to_owned(),
Vec::new(),
// This id is supposed to be the id from the
// linearized `term`
ValueState::Known(id),
),
meta: match &*term.term {
Expand Down Expand Up @@ -556,7 +552,7 @@ impl<'a> Linearizer for AnalysisHost<'a> {
.collect();

let c = Completed::new(lin_, id_mapping);
update(self.file, c.clone());
update_lin_cache(self.file, c.clone());
Linearization::new(c)
}

Expand Down
14 changes: 4 additions & 10 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,14 @@ impl Cache {
Some(state) if state >= EntryState::ImportsResolved => Ok(CacheOp::Cached(Vec::new())),
Some(state) if state >= EntryState::Parsed => {
let pending = if state < EntryState::ImportsResolving {
// let CachedTerm {
// term, parse_errs, ..
// } = self.terms.remove(&file_id).unwrap();
let CachedTerm {
term, parse_errs, ..
} = self.terms.get(&file_id).unwrap();
// The current solution is not to remove the item from the cache
// in order to keep it, in the case where we fail.
// okay, for now these clones are here becuase the function call below
// is faillible, and then we don't put back the item in cache
// A better way is to put it back before we fail.
// short circuts, and then we don't put back the item in cache, so the
// linearization of a file fails if we can't resolve any of it's imports
// The current solution is not to remove the item from the cache, and
// put it back when done, but to get a reference and clone it.
let term = term.clone();
let parse_errs = parse_errs.clone();
let (term, pending) = import_resolution::resolve_imports(term, self)?;
Expand All @@ -666,9 +663,6 @@ impl Cache {
},
);

// for id in &pending {
// if let CacheOp::Done(ps) = self.resolve_imports(*id)? {}
// }
pending
.iter()
.flat_map(|id| {
Expand Down

0 comments on commit 6101754

Please sign in to comment.