forked from rojo-rbx/rojo
Update rbx-dom (#1023)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
use std::{borrow::Cow, collections::HashMap, path::Path};
|
||||
use std::{borrow::Cow, path::Path};
|
||||
|
||||
use anyhow::{bail, Context};
|
||||
use memofs::Vfs;
|
||||
use rbx_dom_weak::types::{Attributes, Ref};
|
||||
use rbx_dom_weak::{
|
||||
types::{Attributes, Ref},
|
||||
ustr, HashMapExt as _, Ustr, UstrMap,
|
||||
};
|
||||
use rbx_reflection::ClassTag;
|
||||
|
||||
use crate::{
|
||||
@@ -88,14 +91,10 @@ pub fn snapshot_project_node(
|
||||
) -> anyhow::Result<Option<InstanceSnapshot>> {
|
||||
let project_folder = project_path.parent().unwrap();
|
||||
|
||||
let class_name_from_project = node
|
||||
.class_name
|
||||
.as_ref()
|
||||
.map(|name| Cow::Owned(name.clone()));
|
||||
let mut class_name_from_path = None;
|
||||
|
||||
let name = Cow::Owned(instance_name.to_owned());
|
||||
let mut properties = HashMap::new();
|
||||
let mut properties = UstrMap::new();
|
||||
let mut children = Vec::new();
|
||||
let mut metadata = InstanceMetadata::new().context(context);
|
||||
|
||||
@@ -136,7 +135,7 @@ pub fn snapshot_project_node(
|
||||
let class_name_from_inference = infer_class_name(&name, parent_class);
|
||||
|
||||
let class_name = match (
|
||||
class_name_from_project,
|
||||
node.class_name,
|
||||
class_name_from_path,
|
||||
class_name_from_inference,
|
||||
&node.path,
|
||||
@@ -249,7 +248,7 @@ pub fn snapshot_project_node(
|
||||
_ => {}
|
||||
}
|
||||
|
||||
properties.insert(key.clone(), value);
|
||||
properties.insert(*key, value);
|
||||
}
|
||||
|
||||
if !node.attributes.is_empty() {
|
||||
@@ -304,7 +303,7 @@ pub fn snapshot_project_node(
|
||||
}))
|
||||
}
|
||||
|
||||
fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Cow<'static, str>> {
|
||||
fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Ustr> {
|
||||
// If className wasn't defined from another source, we may be able
|
||||
// to infer one.
|
||||
|
||||
@@ -317,18 +316,18 @@ fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Cow<'stati
|
||||
let descriptor = rbx_reflection_database::get().classes.get(name)?;
|
||||
|
||||
if descriptor.tags.contains(&ClassTag::Service) {
|
||||
return Some(Cow::Owned(name.to_owned()));
|
||||
return Some(ustr(name));
|
||||
}
|
||||
} else if parent_class == "StarterPlayer" {
|
||||
// StarterPlayer has two special members with their own classes.
|
||||
|
||||
if name == "StarterPlayerScripts" || name == "StarterCharacterScripts" {
|
||||
return Some(Cow::Owned(name.to_owned()));
|
||||
return Some(ustr(name));
|
||||
}
|
||||
} else if parent_class == "Workspace" {
|
||||
// Workspace has a special Terrain class inside it
|
||||
if name == "Terrain" {
|
||||
return Some(Cow::Owned(name.to_owned()));
|
||||
return Some(ustr(name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user