Skip to content

Commit 891ebba

Browse files
committed
fix: resolve imports at the end
1 parent d529ee0 commit 891ebba

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

crates/compilers/src/compilers/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ pub trait SourceParser: Clone + Debug + Send + Sync {
166166
})
167167
.collect::<Result<_>>()
168168
}
169+
170+
fn finalize_imports(&mut self, _include_paths: &BTreeSet<PathBuf>) -> Result<()> {
171+
Ok(())
172+
}
169173
}
170174

171175
/// Parser of the source files which is used to identify imports and version requirements of the

crates/compilers/src/compilers/multi.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ impl SourceParser for MultiCompilerParser {
412412
)
413413
.collect())
414414
}
415+
416+
fn finalize_imports(&mut self, include_paths: &BTreeSet<PathBuf>) -> Result<()> {
417+
self.solc.finalize_imports(include_paths)?;
418+
self.vyper.finalize_imports(include_paths)?;
419+
Ok(())
420+
}
415421
}
416422

417423
impl ParsedSource for MultiCompilerParsedSource {

crates/compilers/src/compilers/solc/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ impl SourceParser for SolParser {
401401
) -> Result<Vec<(PathBuf, Node<Self::ParsedSource>)>> {
402402
self.compiler_mut().enter_mut(|compiler| {
403403
let mut pcx = compiler.parse();
404+
pcx.set_resolve_imports(false);
404405
let files = sources
405406
.par_iter()
406407
.map(|(path, source)| {
@@ -447,6 +448,16 @@ impl SourceParser for SolParser {
447448
Ok(parsed)
448449
})
449450
}
451+
452+
fn finalize_imports(&mut self, include_paths: &BTreeSet<PathBuf>) -> Result<()> {
453+
self.compiler_mut().sess_mut().opts.include_paths.extend(include_paths.iter().cloned());
454+
self.compiler_mut().enter_mut(|compiler| {
455+
let mut pcx = compiler.parse();
456+
pcx.set_resolve_imports(true);
457+
pcx.force_resolve_all_imports();
458+
});
459+
Ok(())
460+
}
450461
}
451462

452463
impl ParsedSource for SolData {

crates/compilers/src/resolver/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ impl<P: SourceParser> Graph<P> {
484484
);
485485
}
486486

487+
parser.finalize_imports(&resolved_solc_include_paths)?;
488+
487489
let edges = GraphEdges {
488490
edges,
489491
rev_edges,

0 commit comments

Comments
 (0)