validator: write and use tragic script name function
This commit is contained in:
parent
cd82954b73
commit
123bc8af47
@ -118,7 +118,7 @@ impl Validator{
|
||||
// associate a name and policy with the source code
|
||||
// policy will be fetched from the database to replace the default policy
|
||||
script_map.insert(source.clone(),NamePolicy{
|
||||
name:script.name.clone(),
|
||||
name:get_partial_path(&dom,script),
|
||||
policy:Policy::None,
|
||||
});
|
||||
}
|
||||
@ -309,6 +309,25 @@ fn recursive_collect_superclass(objects:&mut std::vec::Vec<rbx_dom_weak::types::
|
||||
}
|
||||
}
|
||||
|
||||
fn get_partial_path(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)->String{
|
||||
struct ParentIter<'a>{
|
||||
dom:&'a rbx_dom_weak::WeakDom,
|
||||
instance:Option<&'a rbx_dom_weak::Instance>,
|
||||
}
|
||||
impl<'a> Iterator for ParentIter<'a>{
|
||||
type Item=&'a rbx_dom_weak::Instance;
|
||||
fn next(&mut self)->Option<Self::Item>{
|
||||
let parent=self.instance.map(|i|i.parent()).and_then(|p|self.dom.get_by_ref(p));
|
||||
core::mem::replace(&mut self.instance,parent)
|
||||
}
|
||||
}
|
||||
|
||||
let mut tragic:Vec<_>=ParentIter{dom,instance:Some(instance)}.map(|i|i.name.as_str()).collect();
|
||||
tragic.pop();
|
||||
tragic.reverse();
|
||||
tragic.join(".")
|
||||
}
|
||||
|
||||
fn get_script_refs(dom:&rbx_dom_weak::WeakDom)->Vec<rbx_dom_weak::types::Ref>{
|
||||
let mut scripts=std::vec::Vec::new();
|
||||
recursive_collect_superclass(&mut scripts,dom,dom.root(),"LuaSourceContainer");
|
||||
|
Loading…
x
Reference in New Issue
Block a user