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::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
path::{Path, PathBuf},
|
path::Path,
|
||||||
str,
|
str,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
@ -29,6 +29,12 @@ pub struct MetadataPerPath {
|
||||||
pub instance_name: Option<String>,
|
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 {
|
pub struct RbxSession {
|
||||||
tree: RbxTree,
|
tree: RbxTree,
|
||||||
|
|
||||||
|
|
@ -36,7 +42,8 @@ pub struct RbxSession {
|
||||||
// path aliasing.
|
// path aliasing.
|
||||||
metadata_per_path: PathMap<MetadataPerPath>,
|
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>,
|
instance_metadata_map: HashMap<RbxId, InstanceProjectNodeMetadata>,
|
||||||
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ pub struct RbxSnapshotInstance<'a> {
|
||||||
pub class_name: Cow<'a, str>,
|
pub class_name: Cow<'a, str>,
|
||||||
pub properties: HashMap<String, RbxValue>,
|
pub properties: HashMap<String, RbxValue>,
|
||||||
pub children: Vec<RbxSnapshotInstance<'a>>,
|
pub children: Vec<RbxSnapshotInstance<'a>>,
|
||||||
|
|
||||||
|
// TODO: Replace source_path and metadata with MetadataPerInstance
|
||||||
pub source_path: Option<PathBuf>,
|
pub source_path: Option<PathBuf>,
|
||||||
pub metadata: Option<InstanceProjectNodeMetadata>,
|
pub metadata: Option<InstanceProjectNodeMetadata>,
|
||||||
}
|
}
|
||||||
|
|
@ -96,12 +98,8 @@ pub fn reify_root(
|
||||||
let root_id = tree.get_root_id();
|
let root_id = tree.get_root_id();
|
||||||
|
|
||||||
if let Some(source_path) = &snapshot.source_path {
|
if let Some(source_path) = &snapshot.source_path {
|
||||||
// TODO: Use entry API instead?
|
let path_meta = metadata_per_path.entry(source_path.to_owned()).or_default();
|
||||||
// metadata_per_path.entry()
|
path_meta.instance_id = Some(root_id);
|
||||||
metadata_per_path.insert(source_path.clone(), MetadataPerPath {
|
|
||||||
instance_id: Some(root_id),
|
|
||||||
instance_name: None,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(metadata) = &snapshot.metadata {
|
if let Some(metadata) = &snapshot.metadata {
|
||||||
|
|
@ -129,8 +127,8 @@ pub fn reify_subtree(
|
||||||
let id = tree.insert_instance(instance, parent_id);
|
let id = tree.insert_instance(instance, parent_id);
|
||||||
|
|
||||||
if let Some(source_path) = &snapshot.source_path {
|
if let Some(source_path) = &snapshot.source_path {
|
||||||
// TODO: Entry API
|
let path_meta = metadata_per_path.entry(source_path.clone()).or_default();
|
||||||
// let metadata = metadata_per_path.entry(source_path.clone(), id);
|
path_meta.instance_id = Some(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(metadata) = &snapshot.metadata {
|
if let Some(metadata) = &snapshot.metadata {
|
||||||
|
|
@ -153,8 +151,8 @@ pub fn reconcile_subtree(
|
||||||
changes: &mut InstanceChanges,
|
changes: &mut InstanceChanges,
|
||||||
) {
|
) {
|
||||||
if let Some(source_path) = &snapshot.source_path {
|
if let Some(source_path) = &snapshot.source_path {
|
||||||
// TODO: use entry API
|
let path_meta = metadata_per_path.entry(source_path.to_owned()).or_default();
|
||||||
// metadata_per_path.insert(source_path.clone(), id);
|
path_meta.instance_id = Some(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(metadata) = &snapshot.metadata {
|
if let Some(metadata) = &snapshot.metadata {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue