From 289a1b904d642b11a77c4c50886ca1e6682ba1c3 Mon Sep 17 00:00:00 2001 From: Jason Siefken Date: Wed, 20 Dec 2023 14:42:19 -0500 Subject: [PATCH] Spelling changes (#81) --- .../doenetml-core/doenetml-derive/src/lib.rs | 52 +++++++++---------- .../doenetml-core/src/component.rs | 30 +++++------ .../doenetml-core/src/component/_error.rs | 8 +-- .../doenetml-core/src/component/_external.rs | 30 +++++------ .../doenetml-core/src/component/document.rs | 8 +-- .../doenetml-core/src/component/p.rs | 8 +-- .../doenetml-core/src/component/section.rs | 8 +-- .../doenetml-core/src/component/text.rs | 8 +-- .../doenetml-core/src/lib.rs | 40 +++++++------- packages/test-viewer/package.json | 1 - 10 files changed, 96 insertions(+), 97 deletions(-) diff --git a/packages/doenetml-worker-rust/doenetml-core/doenetml-derive/src/lib.rs b/packages/doenetml-worker-rust/doenetml-core/doenetml-derive/src/lib.rs index 57170e94a..eaea8acc6 100644 --- a/packages/doenetml-worker-rust/doenetml-core/doenetml-derive/src/lib.rs +++ b/packages/doenetml-worker-rust/doenetml-core/doenetml-derive/src/lib.rs @@ -42,16 +42,16 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { quote! { impl ComponentNode for #name { - fn get_ind(&self) -> ComponentInd { - self.ind + fn get_idx(&self) -> ComponentIdx { + self.idx } - fn set_ind(&mut self, ind: ComponentInd) { - self.ind = ind; + fn set_idx(&mut self, idx: ComponentIdx) { + self.idx = idx; } - fn get_parent(&self) -> Option { + fn get_parent(&self) -> Option { self.parent } - fn set_parent(&mut self, parent: Option) { + fn set_parent(&mut self, parent: Option) { self.parent = parent; } fn get_children(&self) -> &Vec { @@ -64,8 +64,8 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { std::mem::replace(&mut self.children, new_children) } - fn initialize(&mut self, ind: ComponentInd, parent: Option, position: Option) { - self.ind = ind; + fn initialize(&mut self, idx: ComponentIdx, parent: Option, position: Option) { + self.idx = idx; self.parent = parent; self.position = position; } @@ -80,10 +80,10 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { fn get_component_type(&self) -> &str { #component_string } - fn get_descendant_matches(&self, name: &str) -> Option<&Vec> { + fn get_descendant_matches(&self, name: &str) -> Option<&Vec> { self.descendant_names.get(name) } - fn set_descendant_names(&mut self, descendant_names: HashMap>) { + fn set_descendant_names(&mut self, descendant_names: HashMap>) { self.descendant_names = descendant_names; } @@ -118,8 +118,8 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { let enum_ident = name; let mut create_object_variant_arms = Vec::new(); - let mut get_ind_variant_arms = Vec::new(); - let mut set_ind_variant_arms = Vec::new(); + let mut get_idx_variant_arms = Vec::new(); + let mut set_idx_variant_arms = Vec::new(); let mut get_parent_variant_arms = Vec::new(); let mut set_parent_variant_arms = Vec::new(); let mut get_children_variant_arms = Vec::new(); @@ -142,15 +142,15 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { #enum_ident::#variant_ident(comp) => Box::new(comp), }); - get_ind_variant_arms.push(quote! { + get_idx_variant_arms.push(quote! { #enum_ident::#variant_ident(comp) => { - comp.get_ind() + comp.get_idx() }, }); - set_ind_variant_arms.push(quote! { + set_idx_variant_arms.push(quote! { #enum_ident::#variant_ident(ref mut comp) => { - comp.set_ind(ind); + comp.set_idx(idx); }, }); @@ -186,7 +186,7 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { initialize_variant_arms.push(quote! { #enum_ident::#variant_ident(ref mut comp) => { - comp.initialize(ind, parent, position); + comp.initialize(idx, parent, position); }, }); @@ -251,25 +251,25 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { impl ComponentNode for #enum_ident { - fn get_ind(&self) -> ComponentInd { + fn get_idx(&self) -> ComponentIdx { match self { - #(#get_ind_variant_arms)* + #(#get_idx_variant_arms)* } } - fn set_ind(&mut self, ind: ComponentInd){ + fn set_idx(&mut self, idx: ComponentIdx){ match self { - #(#set_ind_variant_arms)* + #(#set_idx_variant_arms)* } } - fn get_parent(&self) -> Option { + fn get_parent(&self) -> Option { match self { #(#get_parent_variant_arms)* } } - fn set_parent(&mut self, parent: Option){ + fn set_parent(&mut self, parent: Option){ match self { #(#set_parent_variant_arms)* } @@ -293,7 +293,7 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { } } - fn initialize(&mut self, ind: ComponentInd, parent: Option, position: Option) { + fn initialize(&mut self, idx: ComponentIdx, parent: Option, position: Option) { match self { #(#initialize_variant_arms)* } @@ -317,13 +317,13 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream { } } - fn set_descendant_names(&mut self, descendant_names: HashMap>) { + fn set_descendant_names(&mut self, descendant_names: HashMap>) { match self { #(#set_descendant_names_variant_arms)* } } - fn get_descendant_matches(&self, name: &str) -> Option<&Vec> { + fn get_descendant_matches(&self, name: &str) -> Option<&Vec> { match self { #(#get_descendant_matches_variant_arms)* } diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component.rs b/packages/doenetml-worker-rust/doenetml-core/src/component.rs index c4a58be13..f780d1eec 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component.rs @@ -13,7 +13,7 @@ use doenetml_derive::ComponentNode; use strum_macros::EnumString; use crate::dast::{ElementData, FlatDastElement, FlatDastElementContent, Position as DastPosition}; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use self::_error::_Error; use self::_external::_External; @@ -34,18 +34,18 @@ pub enum ComponentEnum { } pub trait ComponentNode { - fn get_ind(&self) -> ComponentInd; - fn set_ind(&mut self, ind: ComponentInd); - fn get_parent(&self) -> Option; - fn set_parent(&mut self, parent: Option); + fn get_idx(&self) -> ComponentIdx; + fn set_idx(&mut self, idx: ComponentIdx); + fn get_parent(&self) -> Option; + fn set_parent(&mut self, parent: Option); fn get_children(&self) -> &Vec; fn set_children(&mut self, children: Vec); fn replace_children(&mut self, new_children: Vec) -> Vec; fn initialize( &mut self, - ind: ComponentInd, - parent: Option, + idx: ComponentIdx, + parent: Option, position: Option, ); @@ -54,8 +54,8 @@ pub trait ComponentNode { fn get_component_type(&self) -> &str; - fn get_descendant_matches(&self, name: &str) -> Option<&Vec>; - fn set_descendant_names(&mut self, descendant_names: HashMap>); + fn get_descendant_matches(&self, name: &str) -> Option<&Vec>; + fn set_descendant_names(&mut self, descendant_names: HashMap>); fn get_position(&self) -> &Option; fn set_position(&mut self, position: Option); @@ -65,12 +65,12 @@ pub trait ComponentNode { // add children from that source first let mut children = if let Some(extend_source) = self.get_extend() { match extend_source { - ExtendSource::Component(source_ind) => { - let source_dast = components[*source_ind].borrow().to_flat_dast(components); + ExtendSource::Component(source_idx) => { + let source_dast = components[*source_idx].borrow().to_flat_dast(components); source_dast.children } - ExtendSource::StateVar((_source_ind, _source_var_ind)) => { + ExtendSource::StateVar((_source_idx, _source_var_idx)) => { // TODO: state variable extend source Vec::new() } @@ -84,8 +84,8 @@ pub trait ComponentNode { .get_children() .iter() .filter_map(|child| match child { - ComponentChild::Component(comp_ind) => { - Some(FlatDastElementContent::Element(*comp_ind)) + ComponentChild::Component(comp_idx) => { + Some(FlatDastElementContent::Element(*comp_idx)) } ComponentChild::Text(s) => Some(FlatDastElementContent::Text(s.to_string())), ComponentChild::Macro(_the_macro) => None, @@ -102,7 +102,7 @@ pub trait ComponentNode { attributes: HashMap::new(), children, data: Some(ElementData { - id: self.get_ind(), + id: self.get_idx(), ..Default::default() }), position: self.get_position().clone(), diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component/_error.rs b/packages/doenetml-worker-rust/doenetml-core/src/component/_error.rs index 399b36d22..c5df97f1a 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component/_error.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component/_error.rs @@ -1,20 +1,20 @@ use std::collections::HashMap; use crate::dast::Position as DastPosition; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use super::ComponentNode; #[derive(Debug, Default, ComponentNode)] pub struct _Error { - pub ind: ComponentInd, - pub parent: Option, + pub idx: ComponentIdx, + pub parent: Option, pub children: Vec, pub extend: Option, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component/_external.rs b/packages/doenetml-worker-rust/doenetml-core/src/component/_external.rs index 0f1ebb21d..d4f79b444 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component/_external.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component/_external.rs @@ -1,20 +1,20 @@ use std::collections::HashMap; use crate::dast::Position as DastPosition; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use super::ComponentNode; #[derive(Debug, Default)] pub struct _External { - pub ind: ComponentInd, - pub parent: Option, + pub idx: ComponentIdx, + pub parent: Option, pub children: Vec, pub extend: Option, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, @@ -22,16 +22,16 @@ pub struct _External { } impl ComponentNode for _External { - fn get_ind(&self) -> ComponentInd { - self.ind + fn get_idx(&self) -> ComponentIdx { + self.idx } - fn set_ind(&mut self, ind: ComponentInd) { - self.ind = ind; + fn set_idx(&mut self, idx: ComponentIdx) { + self.idx = idx; } - fn get_parent(&self) -> Option { + fn get_parent(&self) -> Option { self.parent } - fn set_parent(&mut self, parent: Option) { + fn set_parent(&mut self, parent: Option) { self.parent = parent; } fn get_children(&self) -> &Vec { @@ -46,11 +46,11 @@ impl ComponentNode for _External { fn initialize( &mut self, - ind: ComponentInd, - parent: Option, + idx: ComponentIdx, + parent: Option, position: Option, ) { - self.ind = ind; + self.idx = idx; self.parent = parent; self.position = position; } @@ -67,10 +67,10 @@ impl ComponentNode for _External { fn get_component_type(&self) -> &str { &self.name } - fn get_descendant_matches(&self, name: &str) -> Option<&Vec> { + fn get_descendant_matches(&self, name: &str) -> Option<&Vec> { self.descendant_names.get(name) } - fn set_descendant_names(&mut self, descendant_names: HashMap>) { + fn set_descendant_names(&mut self, descendant_names: HashMap>) { self.descendant_names = descendant_names; } diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component/document.rs b/packages/doenetml-worker-rust/doenetml-core/src/component/document.rs index b04ded496..81e83e8ef 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component/document.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component/document.rs @@ -1,20 +1,20 @@ use std::collections::HashMap; use crate::dast::Position as DastPosition; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use super::ComponentNode; #[derive(Debug, Default, ComponentNode)] pub struct Document { - pub ind: ComponentInd, - pub parent: Option, + pub idx: ComponentIdx, + pub parent: Option, pub children: Vec, pub extend: Option, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, } diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component/p.rs b/packages/doenetml-worker-rust/doenetml-core/src/component/p.rs index 030cd2309..e92f4d22e 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component/p.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component/p.rs @@ -1,20 +1,20 @@ use std::collections::HashMap; use crate::dast::Position as DastPosition; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use super::ComponentNode; #[derive(Debug, Default, ComponentNode)] pub struct P { - pub ind: ComponentInd, - pub parent: Option, + pub idx: ComponentIdx, + pub parent: Option, pub children: Vec, pub extend: Option, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, } diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component/section.rs b/packages/doenetml-worker-rust/doenetml-core/src/component/section.rs index 246da8e0e..e9dec7c51 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component/section.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component/section.rs @@ -1,20 +1,20 @@ use std::collections::HashMap; use crate::dast::Position as DastPosition; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use super::ComponentNode; #[derive(Debug, Default, ComponentNode)] pub struct Section { - pub ind: ComponentInd, - pub parent: Option, + pub idx: ComponentIdx, + pub parent: Option, pub children: Vec, pub extend: Option, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, } diff --git a/packages/doenetml-worker-rust/doenetml-core/src/component/text.rs b/packages/doenetml-worker-rust/doenetml-core/src/component/text.rs index 4fed4317b..bd521fd89 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/component/text.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/component/text.rs @@ -1,20 +1,20 @@ use std::collections::HashMap; use crate::dast::Position as DastPosition; -use crate::{ComponentChild, ComponentInd, ExtendSource}; +use crate::{ComponentChild, ComponentIdx, ExtendSource}; use super::ComponentNode; #[derive(Debug, Default, ComponentNode)] pub struct Text { - pub ind: ComponentInd, - pub parent: Option, + pub idx: ComponentIdx, + pub parent: Option, pub children: Vec, pub extend: Option, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, } diff --git a/packages/doenetml-worker-rust/doenetml-core/src/lib.rs b/packages/doenetml-worker-rust/doenetml-core/src/lib.rs index 536cead62..370766234 100644 --- a/packages/doenetml-worker-rust/doenetml-core/src/lib.rs +++ b/packages/doenetml-worker-rust/doenetml-core/src/lib.rs @@ -16,12 +16,12 @@ use crate::utils::{log, log_debug, log_json}; #[derive(Debug, Clone)] pub struct ComponentState { - pub component_ind: ComponentInd, - pub state_var_ind: StateVarInd, + pub component_ind: ComponentIdx, + pub state_var_ind: StateVarIdx, } -pub type ComponentInd = usize; -pub type StateVarInd = usize; +pub type ComponentIdx = usize; +pub type StateVarIdx = usize; #[derive(Debug)] pub struct DoenetMLCore { @@ -63,7 +63,7 @@ pub struct DoenetMLRoot { pub children: Vec, // map of descendant names to their indices - pub descendant_names: HashMap>, + pub descendant_names: HashMap>, pub position: Option, } @@ -98,7 +98,7 @@ impl DoenetMLRoot { #[derive(Debug)] pub enum ComponentChild { - Component(ComponentInd), + Component(ComponentIdx), Text(String), Macro(DastMacro), FunctionMacro(DastFunctionMacro), @@ -106,9 +106,9 @@ pub enum ComponentChild { #[derive(Debug)] pub enum ExtendSource { - Component(ComponentInd), + Component(ComponentIdx), // TODO: what about array state variables? - StateVar((ComponentInd, StateVarInd)), + StateVar((ComponentIdx, StateVarIdx)), } pub fn create_doenetml_core( @@ -131,7 +131,7 @@ pub fn create_doenetml_core( position: dast_root.position.clone(), }; - replace_macro_referants(&mut components, 0); + replace_macro_referents(&mut components, 0); // log!("after replace macros {:#?}", components); @@ -150,9 +150,9 @@ fn create_component_children( components: &mut Vec>>, warnings: &mut Vec, dast_children: &Vec, - parent_ind: ComponentInd, -) -> (Vec, HashMap>) { - let mut descendant_names: HashMap> = HashMap::new(); + parent_ind: ComponentIdx, +) -> (Vec, HashMap>) { + let mut descendant_names: HashMap> = HashMap::new(); let mut component_children: Vec = Vec::new(); @@ -220,7 +220,7 @@ fn create_component_children( child_node.set_descendant_names(child_descendent_names.clone()); // merge in the descendant names found from the child - // into the overall descedant names for the parent + // into the overall descendant names for the parent for (comp_name, mut name_inds) in child_descendent_names { descendant_names .entry(comp_name) @@ -262,9 +262,9 @@ fn create_component_children( (component_children, descendant_names) } -fn replace_macro_referants( +fn replace_macro_referents( components: &mut Vec>>, - component_ind: ComponentInd, + component_ind: ComponentIdx, ) { // We need to temporarily put in an empty vector into the children field // and move the children into a separate vector. @@ -279,7 +279,7 @@ fn replace_macro_referants( match child { ComponentChild::Component(child_ind) => { // recurse on component children - replace_macro_referants(components, child_ind); + replace_macro_referents(components, child_ind); child } ComponentChild::Macro(ref dast_macro) => { @@ -321,8 +321,8 @@ fn replace_macro_referants( fn match_name_reference<'a>( components: &Vec>>, path: &'a Vec, - comp_ind: ComponentInd, -) -> Option<(ComponentInd, &'a [PathPart])> { + comp_ind: ComponentIdx, +) -> Option<(ComponentIdx, &'a [PathPart])> { let comp = &components[comp_ind].borrow(); // TODO: handle index of path @@ -352,8 +352,8 @@ fn match_name_reference<'a>( fn match_descendant_names<'a>( components: &Vec>>, path: &'a [PathPart], - comp_ind: ComponentInd, -) -> Option<(ComponentInd, &'a [PathPart])> { + comp_ind: ComponentIdx, +) -> Option<(ComponentIdx, &'a [PathPart])> { if path.len() > 0 { let comp = &components[comp_ind].borrow(); diff --git a/packages/test-viewer/package.json b/packages/test-viewer/package.json index dfedc766c..5be285bfc 100644 --- a/packages/test-viewer/package.json +++ b/packages/test-viewer/package.json @@ -30,7 +30,6 @@ ], "dependencies": [ "../doenetml-prototype:build", - "../doenetml:build", "../ui-components:build" ] }