Skip to content

Commit

Permalink
Make some Workspace and Context fields public (#290)
Browse files Browse the repository at this point in the history
* Make Context#mode field pub instead of pub(crate)

This change will allow to locate the absolute paths to the generated files using Context#mode + Context#item_path

* Make WorkspaceInfo#dir pub

* Pub Context#split

* pub mod fmt

* add ordered duplicate name info

---------

Co-authored-by: Millione <[email protected]>
  • Loading branch information
missingdays and Millione authored Nov 25, 2024
1 parent c9e0f80 commit 0640477
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pilota-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod util;
pub mod codegen;
pub mod db;
pub(crate) mod errors;
mod fmt;
pub mod fmt;
mod index;
mod ir;
pub mod middle;
Expand Down
13 changes: 7 additions & 6 deletions pilota-build/src/middle/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum CollectMode {

#[derive(Debug)]
pub struct WorkspaceInfo {
pub(crate) dir: PathBuf,
pub dir: PathBuf,
pub(crate) location_map: FxHashMap<DefId, DefLocation>,
}

Expand All @@ -67,14 +67,14 @@ pub struct Context {
pub(crate) codegen_items: Arc<[DefId]>,
pub(crate) path_resolver: Arc<dyn PathResolver>,
pub mode: Arc<Mode>,
pub(crate) split: bool,
pub split: bool,
pub(crate) keep_unknown_fields: Arc<FxHashSet<DefId>>,
pub location_map: Arc<FxHashMap<DefId, DefLocation>>,
pub entry_map: Arc<HashMap<DefLocation, Vec<(DefId, DefLocation)>>>,
pub plugin_gen: Arc<DashMap<DefLocation, String>>,
pub(crate) dedups: Vec<FastStr>,
pub(crate) common_crate_name: FastStr,
pub names: FxHashSet<DefId>,
pub names: FxHashMap<DefId, usize>,
}

impl Clone for Context {
Expand Down Expand Up @@ -382,8 +382,9 @@ impl ContextBuilder {
cx.names.extend(
map.into_iter()
.filter(|(_, v)| v.len() > 1)
.flat_map(|(_, v)| v)
.collect::<HashSet<DefId>>(),
.map(|(_, v)| v)
.flat_map(|v| v.into_iter().enumerate().map(|(i, def_id)| (def_id, i)))
.collect::<HashMap<DefId, usize>>(),
);
cx
}
Expand Down Expand Up @@ -834,7 +835,7 @@ impl Context {
return name.0.into();
}

if !self.change_case || self.names.contains(&def_id) {
if !self.change_case || self.names.contains_key(&def_id) {
return node.name();
}

Expand Down

0 comments on commit 0640477

Please sign in to comment.