mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Flesh out use of PathMap Entry API
This commit is contained in:
parent
dcac9773fb
commit
f2dc1d8898
2 changed files with 17 additions and 12 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::{
|
||||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
path::{Path, PathBuf},
|
||||
path::Path,
|
||||
str,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
|
@ -29,6 +29,12 @@ pub struct MetadataPerPath {
|
|||
pub instance_name: Option<String>,
|
||||
}
|
||||
|
||||
// #[derive(Debug, Default, Serialize, Deserialize)]
|
||||
// pub struct MetadataPerInstance {
|
||||
// pub source_path: Option<PathBuf>,
|
||||
// pub ignore_unknown_instances: bool,
|
||||
// }
|
||||
|
||||
pub struct RbxSession {
|
||||
tree: RbxTree,
|
||||
|
||||
|
|
@ -36,7 +42,8 @@ pub struct RbxSession {
|
|||
// path aliasing.
|
||||
metadata_per_path: PathMap<MetadataPerPath>,
|
||||
|
||||
// TODO: Track map from RbxId to PathBuf to support two-way sync
|
||||
// TODO: Hold this map, inverted from metadata_per_path
|
||||
// metadata_per_instance: PathMap<MetadataPerInstance>,
|
||||
|
||||
instance_metadata_map: HashMap<RbxId, InstanceProjectNodeMetadata>,
|
||||
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ pub struct RbxSnapshotInstance<'a> {
|
|||
pub class_name: Cow<'a, str>,
|
||||
pub properties: HashMap<String, RbxValue>,
|
||||
pub children: Vec<RbxSnapshotInstance<'a>>,
|
||||
|
||||
// TODO: Replace source_path and metadata with MetadataPerInstance
|
||||
pub source_path: Option<PathBuf>,
|
||||
pub metadata: Option<InstanceProjectNodeMetadata>,
|
||||
}
|
||||
|
|
@ -96,12 +98,8 @@ pub fn reify_root(
|
|||
let root_id = tree.get_root_id();
|
||||
|
||||
if let Some(source_path) = &snapshot.source_path {
|
||||
// TODO: Use entry API instead?
|
||||
// metadata_per_path.entry()
|
||||
metadata_per_path.insert(source_path.clone(), MetadataPerPath {
|
||||
instance_id: Some(root_id),
|
||||
instance_name: None,
|
||||
});
|
||||
let path_meta = metadata_per_path.entry(source_path.to_owned()).or_default();
|
||||
path_meta.instance_id = Some(root_id);
|
||||
}
|
||||
|
||||
if let Some(metadata) = &snapshot.metadata {
|
||||
|
|
@ -129,8 +127,8 @@ pub fn reify_subtree(
|
|||
let id = tree.insert_instance(instance, parent_id);
|
||||
|
||||
if let Some(source_path) = &snapshot.source_path {
|
||||
// TODO: Entry API
|
||||
// let metadata = metadata_per_path.entry(source_path.clone(), id);
|
||||
let path_meta = metadata_per_path.entry(source_path.clone()).or_default();
|
||||
path_meta.instance_id = Some(id);
|
||||
}
|
||||
|
||||
if let Some(metadata) = &snapshot.metadata {
|
||||
|
|
@ -153,8 +151,8 @@ pub fn reconcile_subtree(
|
|||
changes: &mut InstanceChanges,
|
||||
) {
|
||||
if let Some(source_path) = &snapshot.source_path {
|
||||
// TODO: use entry API
|
||||
// metadata_per_path.insert(source_path.clone(), id);
|
||||
let path_meta = metadata_per_path.entry(source_path.to_owned()).or_default();
|
||||
path_meta.instance_id = Some(id);
|
||||
}
|
||||
|
||||
if let Some(metadata) = &snapshot.metadata {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue