-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
183 additions
and
187 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
crates/hir-analysis/src/name_resolution/import_resolver.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![allow(dead_code)] | ||
use hir::hir_def::scope_graph::{ScopeEdge, ScopeId}; | ||
use rustc_hash::FxHashMap; | ||
|
||
use crate::Spanned; | ||
|
||
use super::Importer; | ||
|
||
pub struct ResolvedImports { | ||
pub resolved: FxHashMap<ScopeId, ScopeEdge>, | ||
} | ||
|
||
pub struct ImportResolver { | ||
resolved: FxHashMap<ScopeId, Vec<Spanned<ScopeEdge>>>, | ||
glob_resolved: FxHashMap<ScopeId, Vec<Spanned<ScopeEdge>>>, | ||
states: FxHashMap<ScopeId, ScopeState>, | ||
} | ||
|
||
/// This is the state of import resolution for a given scope. | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
enum ScopeState { | ||
// The scope is open, meaning that the scope needs further processing. | ||
Open, | ||
// The scope is closed, meaning that the scope is fully resolved. | ||
Close, | ||
} | ||
|
||
impl Importer for ImportResolver { | ||
fn glob_imports(&self, scope: ScopeId) -> &[Spanned<ScopeEdge>] { | ||
&self.glob_resolved[&scope] | ||
} | ||
|
||
fn named_imports(&self, scope: ScopeId) -> &[Spanned<ScopeEdge>] { | ||
&self.resolved[&scope] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 23 additions & 19 deletions
42
crates/hir-analysis/src/name_resolution/visibility_checker.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.