mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Use rbx_reflection to allow type inference on projects (#130)
* Start dependency on rbx_reflection * Alive and working, all tests pass * Update CHANGELOG
This commit is contained in:
committed by
GitHub
parent
be81de74cd
commit
93349ae2dc
@@ -9,7 +9,7 @@ use std::{
|
||||
use log::warn;
|
||||
use failure::Fail;
|
||||
use maplit::hashmap;
|
||||
use rbx_dom_weak::RbxValue;
|
||||
use rbx_dom_weak::{UnresolvedRbxValue, RbxValue};
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
|
||||
pub static PROJECT_FILENAME: &'static str = "default.project.json";
|
||||
@@ -64,7 +64,7 @@ struct SourceProjectNode {
|
||||
class_name: Option<String>,
|
||||
|
||||
#[serde(rename = "$properties", default = "HashMap::new", skip_serializing_if = "HashMap::is_empty")]
|
||||
properties: HashMap<String, RbxValue>,
|
||||
properties: HashMap<String, UnresolvedRbxValue>,
|
||||
|
||||
#[serde(rename = "$ignoreUnknownInstances", skip_serializing_if = "Option::is_none")]
|
||||
ignore_unknown_instances: Option<bool>,
|
||||
@@ -188,7 +188,7 @@ pub enum ProjectSaveError {
|
||||
pub struct ProjectNode {
|
||||
pub class_name: Option<String>,
|
||||
pub children: HashMap<String, ProjectNode>,
|
||||
pub properties: HashMap<String, RbxValue>,
|
||||
pub properties: HashMap<String, UnresolvedRbxValue>,
|
||||
pub ignore_unknown_instances: Option<bool>,
|
||||
|
||||
#[serde(serialize_with = "crate::path_serializer::serialize_option")]
|
||||
@@ -284,7 +284,7 @@ impl Project {
|
||||
properties: hashmap! {
|
||||
String::from("HttpEnabled") => RbxValue::Bool {
|
||||
value: true,
|
||||
},
|
||||
}.into(),
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
|
||||
@@ -15,6 +15,7 @@ use log::info;
|
||||
use maplit::hashmap;
|
||||
use rbx_dom_weak::{RbxTree, RbxValue, RbxInstanceProperties};
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use rbx_reflection::{try_resolve_value, ValueResolveError};
|
||||
|
||||
use crate::{
|
||||
imfs::{
|
||||
@@ -119,6 +120,19 @@ pub enum SnapshotError {
|
||||
ProjectNodeInvalidTransmute {
|
||||
partition_path: PathBuf,
|
||||
},
|
||||
|
||||
PropertyResolveError {
|
||||
#[fail(cause)]
|
||||
inner: ValueResolveError,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<ValueResolveError> for SnapshotError {
|
||||
fn from(inner: ValueResolveError) -> SnapshotError {
|
||||
SnapshotError::PropertyResolveError {
|
||||
inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SnapshotError {
|
||||
@@ -147,6 +161,7 @@ impl fmt::Display for SnapshotError {
|
||||
writeln!(output, "")?;
|
||||
writeln!(output, "Partition target ($path): {}", partition_path.display())
|
||||
},
|
||||
SnapshotError::PropertyResolveError { inner } => write!(output, "{}", inner),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,7 +241,8 @@ pub fn snapshot_project_node<'source>(
|
||||
}
|
||||
|
||||
for (key, value) in &node.properties {
|
||||
snapshot.properties.insert(key.clone(), value.clone());
|
||||
let resolved_value = try_resolve_value(&snapshot.class_name, key, value)?;
|
||||
snapshot.properties.insert(key.clone(), resolved_value);
|
||||
}
|
||||
|
||||
if let Some(ignore_unknown_instances) = node.ignore_unknown_instances {
|
||||
|
||||
Reference in New Issue
Block a user