mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Migrate from source_path to contributing_paths
This commit is contained in:
@@ -13,15 +13,27 @@ pub struct InstanceMetadata {
|
|||||||
/// manage.
|
/// manage.
|
||||||
pub ignore_unknown_instances: bool,
|
pub ignore_unknown_instances: bool,
|
||||||
|
|
||||||
// TODO: Make source_path a SmallVec<PathBuf> in order to support meta
|
/// The paths that, when changed, could cause the function that generated
|
||||||
// files? Maybe we should use another member of the snapshot middleware to
|
/// this snapshot to generate a different snapshot. Paths should be included
|
||||||
// support damage-painting
|
/// even if they don't exist, since the presence of a file can change the
|
||||||
/// The path that this file came from, if it's the top-level instance from a
|
/// outcome of a snapshot function.
|
||||||
/// model that came directly from disk.
|
///
|
||||||
|
/// For example, a file named foo.lua might have these contributing paths:
|
||||||
|
/// - foo.lua
|
||||||
|
/// - foo.meta.json (even if this file doesn't exist!)
|
||||||
|
///
|
||||||
|
/// A directory named bar/ included in the project file might have these:
|
||||||
|
/// - bar/
|
||||||
|
/// - bar/init.meta.json
|
||||||
|
/// - bar/init.lua
|
||||||
|
/// - bar/init.server.lua
|
||||||
|
/// - bar/init.client.lua
|
||||||
|
/// - default.project.json
|
||||||
///
|
///
|
||||||
/// This path is used to make sure that file changes update all instances
|
/// This path is used to make sure that file changes update all instances
|
||||||
/// that may need updates..
|
/// that may need updates.
|
||||||
pub source_path: Option<PathBuf>,
|
// TODO: Change this to be a SmallVec for performance in common cases?
|
||||||
|
pub contributing_paths: Vec<PathBuf>,
|
||||||
|
|
||||||
/// If this instance was defined in a project file, this is the name from
|
/// If this instance was defined in a project file, this is the name from
|
||||||
/// the project file and the node under it.
|
/// the project file and the node under it.
|
||||||
@@ -36,7 +48,7 @@ impl Default for InstanceMetadata {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
InstanceMetadata {
|
InstanceMetadata {
|
||||||
ignore_unknown_instances: false,
|
ignore_unknown_instances: false,
|
||||||
source_path: None,
|
contributing_paths: Vec::new(),
|
||||||
project_node: None,
|
project_node: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ properties:
|
|||||||
Value: Value of Foo
|
Value: Value of Foo
|
||||||
metadata:
|
metadata:
|
||||||
ignore_unknown_instances: false
|
ignore_unknown_instances: false
|
||||||
source_path: ~
|
contributing_paths: []
|
||||||
project_node: ~
|
project_node: ~
|
||||||
children: []
|
children: []
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ class_name: ROOT
|
|||||||
properties: {}
|
properties: {}
|
||||||
metadata:
|
metadata:
|
||||||
ignore_unknown_instances: false
|
ignore_unknown_instances: false
|
||||||
source_path: ~
|
contributing_paths: []
|
||||||
project_node: ~
|
project_node: ~
|
||||||
children: []
|
children: []
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ properties:
|
|||||||
Value: Should be removed
|
Value: Should be removed
|
||||||
metadata:
|
metadata:
|
||||||
ignore_unknown_instances: false
|
ignore_unknown_instances: false
|
||||||
source_path: ~
|
contributing_paths: []
|
||||||
project_node: ~
|
project_node: ~
|
||||||
children: []
|
children: []
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ class_name: Folder
|
|||||||
properties: {}
|
properties: {}
|
||||||
metadata:
|
metadata:
|
||||||
ignore_unknown_instances: false
|
ignore_unknown_instances: false
|
||||||
source_path: ~
|
contributing_paths: []
|
||||||
project_node: ~
|
project_node: ~
|
||||||
children: []
|
children: []
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ added_instances:
|
|||||||
snapshot_id: ~
|
snapshot_id: ~
|
||||||
metadata:
|
metadata:
|
||||||
ignore_unknown_instances: false
|
ignore_unknown_instances: false
|
||||||
source_path: ~
|
contributing_paths: []
|
||||||
project_node: ~
|
project_node: ~
|
||||||
name: New
|
name: New
|
||||||
class_name: Folder
|
class_name: Folder
|
||||||
|
|||||||
@@ -110,12 +110,12 @@ impl RojoTree {
|
|||||||
// If this instance's source path changed, we need to update our
|
// If this instance's source path changed, we need to update our
|
||||||
// path associations so that file changes will trigger updates
|
// path associations so that file changes will trigger updates
|
||||||
// to this instance correctly.
|
// to this instance correctly.
|
||||||
if existing_metadata.source_path != metadata.source_path {
|
if existing_metadata.contributing_paths != metadata.contributing_paths {
|
||||||
if let Some(existing_path) = &existing_metadata.source_path {
|
for existing_path in &existing_metadata.contributing_paths {
|
||||||
self.path_to_ids.remove(existing_path, id);
|
self.path_to_ids.remove(existing_path, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(new_path) = &metadata.source_path {
|
for new_path in &metadata.contributing_paths {
|
||||||
self.path_to_ids.insert(new_path.clone(), id);
|
self.path_to_ids.insert(new_path.clone(), id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,8 +140,8 @@ impl RojoTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn insert_metadata(&mut self, id: RbxId, metadata: InstanceMetadata) {
|
fn insert_metadata(&mut self, id: RbxId, metadata: InstanceMetadata) {
|
||||||
if let Some(source_path) = &metadata.source_path {
|
for path in &metadata.contributing_paths {
|
||||||
self.path_to_ids.insert(source_path.clone(), id);
|
self.path_to_ids.insert(path.clone(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.metadata_map.insert(id, metadata);
|
self.metadata_map.insert(id, metadata);
|
||||||
@@ -157,9 +157,9 @@ impl RojoTree {
|
|||||||
) {
|
) {
|
||||||
let metadata = self.metadata_map.remove(&id).unwrap();
|
let metadata = self.metadata_map.remove(&id).unwrap();
|
||||||
|
|
||||||
if let Some(source_path) = &metadata.source_path {
|
for path in &metadata.contributing_paths {
|
||||||
self.path_to_ids.remove(source_path, id);
|
self.path_to_ids.remove(path, id);
|
||||||
path_to_ids.insert(source_path.clone(), id);
|
path_to_ids.insert(path.clone(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata_map.insert(id, metadata);
|
metadata_map.insert(id, metadata);
|
||||||
|
|||||||
Reference in New Issue
Block a user