pub struct Module {
pub name: String,
pub path: Vec<String>,
pub decls: Vec<Decl>,
pub imports: Vec<String>,
pub exports: Vec<String>,
pub import_specs: Vec<ImportSpec>,
pub export_spec: Option<ExportSpec>,
pub namespaces: Vec<NamespaceScope>,
pub opens: Vec<OpenDirective>,
pub visibility_map: HashMap<String, Visibility>,
pub config: ModuleConfig,
}Expand description
A module containing declarations.
Fields§
§name: StringModule name
path: Vec<String>Module path
decls: Vec<Decl>Declarations in this module
imports: Vec<String>Imported modules
exports: Vec<String>Exported names
import_specs: Vec<ImportSpec>Import specifications
export_spec: Option<ExportSpec>Export specification
namespaces: Vec<NamespaceScope>Namespace scopes
opens: Vec<OpenDirective>Open directives
visibility_map: HashMap<String, Visibility>Name visibility information
config: ModuleConfigModule configuration
Implementations§
Source§impl Module
impl Module
Sourcepub fn with_config(name: String, config: ModuleConfig) -> Self
pub fn with_config(name: String, config: ModuleConfig) -> Self
Create a module with configuration.
Sourcepub fn add_import(&mut self, module: String)
pub fn add_import(&mut self, module: String)
Add an import.
Sourcepub fn add_export(&mut self, name: String)
pub fn add_export(&mut self, name: String)
Add an export.
Sourcepub fn resolve_name(&self, name: &str) -> ResolvedName
pub fn resolve_name(&self, name: &str) -> ResolvedName
Resolve a name within this module.
Checks local declarations first, then imported modules via import specs, then namespace aliases.
Sourcepub fn visible_names(&self) -> Vec<String>
pub fn visible_names(&self) -> Vec<String>
Get all visible names (declared + imported).
Sourcepub fn exported_names(&self) -> Vec<String>
pub fn exported_names(&self) -> Vec<String>
Get names visible to importers of this module.
Sourcepub fn add_namespace(&mut self, ns: NamespaceScope)
pub fn add_namespace(&mut self, ns: NamespaceScope)
Add a namespace scope.
Sourcepub fn with_import_spec(&mut self, spec: ImportSpec)
pub fn with_import_spec(&mut self, spec: ImportSpec)
Apply an import specification.
Sourcepub fn set_visibility(&mut self, name: String, visibility: Visibility)
pub fn set_visibility(&mut self, name: String, visibility: Visibility)
Set visibility for a name.
Sourcepub fn get_visibility(&self, name: &str) -> Visibility
pub fn get_visibility(&self, name: &str) -> Visibility
Get visibility of a name.
Sourcepub fn resolve_with_opens(&self, name: &str) -> ResolvedName
pub fn resolve_with_opens(&self, name: &str) -> ResolvedName
Resolve a name considering all open modules and imports.
Sourcepub fn all_visible_names(&self) -> Vec<NameVisibility>
pub fn all_visible_names(&self) -> Vec<NameVisibility>
Get all visible names including from opens.
Sourcepub fn is_accessible(&self, name: &str, from_same_module: bool) -> bool
pub fn is_accessible(&self, name: &str, from_same_module: bool) -> bool
Check if a name is accessible with given visibility context.
Sourcepub fn get_dependencies(&self) -> HashSet<String>
pub fn get_dependencies(&self) -> HashSet<String>
Get all direct dependencies (imports and opens).
Sourcepub fn imports_module(&self, other: &str) -> bool
pub fn imports_module(&self, other: &str) -> bool
Check if this module directly imports another.
Sourcepub fn resolve_selective_import(
&self,
_module: &str,
selected: &[String],
) -> Vec<String>
pub fn resolve_selective_import( &self, _module: &str, selected: &[String], ) -> Vec<String>
Resolve a selective import to actual names.
Get all names hidden by a hiding import.
Sourcepub fn create_nested_namespace(&mut self, name: String, parent: NamespaceScope)
pub fn create_nested_namespace(&mut self, name: String, parent: NamespaceScope)
Create a nested namespace scope.
Sourcepub fn lookup_in_namespaces(&self, name: &str) -> Option<String>
pub fn lookup_in_namespaces(&self, name: &str) -> Option<String>
Look up a name in namespace hierarchy.
Sourcepub fn namespace_names(&self, ns_name: &str) -> Vec<String>
pub fn namespace_names(&self, ns_name: &str) -> Vec<String>
Get all names in a specific namespace.
Sourcepub fn set_default_visibility(&mut self, visibility: Visibility)
pub fn set_default_visibility(&mut self, visibility: Visibility)
Set default visibility for all names (for private_by_default config).