Skip to content

Commit

Permalink
Refactor: always use our database of partial paths with extensions
Browse files Browse the repository at this point in the history
Only don't include extensions when recursion is not allowed in resolution.
  • Loading branch information
ggiraldez committed Jan 23, 2025
1 parent aca4ba3 commit 0dad66e
Showing 1 changed file with 22 additions and 36 deletions.
58 changes: 22 additions & 36 deletions crates/metaslang/bindings/src/graph/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use stack_graphs::arena::Handle;
use stack_graphs::graph::{Degree, Edge, StackGraph};
use stack_graphs::partial::{PartialPath, PartialPaths};
use stack_graphs::stitching::{
Database, DatabaseCandidates, ForwardCandidates, ForwardPartialPathStitcher, StitcherConfig,
ToAppendable,
Database, ForwardCandidates, ForwardPartialPathStitcher, StitcherConfig, ToAppendable,
};
use stack_graphs::{CancellationError, NoCancellation};

Expand Down Expand Up @@ -105,7 +104,7 @@ impl Resolver {
let checkpoint = self.partials.save_checkpoint();
let mut reference_paths = Vec::new();

if allow_recursion {
let extensions = if allow_recursion {
// look for extension scopes to apply to the reference
let ref_parents = self.resolve_parents(owner, reference);
let mut extensions = HashSet::new();
Expand All @@ -123,40 +122,27 @@ impl Resolver {
}
}
}
let extensions = extensions.drain().collect::<Vec<_>>();
let mut database = ExtendedDatabase::new(&mut self.database);

ForwardPartialPathStitcher::find_all_complete_partial_paths(
&mut DatabaseCandidatesExtended::new(
owner,
&mut self.partials,
&mut database,
extensions,
),
once(reference),
StitcherConfig::default(),
&NoCancellation,
|_graph, _partials, path| {
reference_paths.push(path.clone());
},
)
.expect("not cancelled");
extensions.drain().collect::<Vec<_>>()
} else {
ForwardPartialPathStitcher::find_all_complete_partial_paths(
&mut DatabaseCandidates::new(
&owner.stack_graph,
&mut self.partials,
&mut self.database,
),
once(reference),
StitcherConfig::default(),
&NoCancellation,
|_graph, _partials, path| {
reference_paths.push(path.clone());
},
)
.expect("not cancelled");
}
Vec::new()
};
let mut database = ExtendedDatabase::new(&mut self.database);

ForwardPartialPathStitcher::find_all_complete_partial_paths(
&mut DatabaseCandidatesExtended::new(
owner,
&mut self.partials,
&mut database,
extensions,
),
once(reference),
StitcherConfig::default(),
&NoCancellation,
|_graph, _partials, path| {
reference_paths.push(path.clone());
},
)
.expect("not cancelled");

let mut results = Vec::new();
for reference_path in &reference_paths {
Expand Down

0 comments on commit 0dad66e

Please sign in to comment.