Skip to content

Commit

Permalink
Spelling changes (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
siefkenj authored Dec 20, 2023
1 parent 007189a commit 289a1b9
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComponentInd> {
fn get_parent(&self) -> Option<ComponentIdx> {
self.parent
}
fn set_parent(&mut self, parent: Option<ComponentInd>) {
fn set_parent(&mut self, parent: Option<ComponentIdx>) {
self.parent = parent;
}
fn get_children(&self) -> &Vec<ComponentChild> {
Expand All @@ -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<ComponentInd>, position: Option<DastPosition>) {
self.ind = ind;
fn initialize(&mut self, idx: ComponentIdx, parent: Option<ComponentIdx>, position: Option<DastPosition>) {
self.idx = idx;
self.parent = parent;
self.position = position;
}
Expand All @@ -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<ComponentInd>> {
fn get_descendant_matches(&self, name: &str) -> Option<&Vec<ComponentIdx>> {
self.descendant_names.get(name)
}
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentInd>>) {
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentIdx>>) {
self.descendant_names = descendant_names;
}

Expand Down Expand Up @@ -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();
Expand All @@ -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);
},
});

Expand Down Expand Up @@ -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);
},
});

Expand Down Expand Up @@ -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<ComponentInd> {
fn get_parent(&self) -> Option<ComponentIdx> {
match self {
#(#get_parent_variant_arms)*
}
}

fn set_parent(&mut self, parent: Option<ComponentInd>){
fn set_parent(&mut self, parent: Option<ComponentIdx>){
match self {
#(#set_parent_variant_arms)*
}
Expand All @@ -293,7 +293,7 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream {
}
}

fn initialize(&mut self, ind: ComponentInd, parent: Option<ComponentInd>, position: Option<DastPosition>) {
fn initialize(&mut self, idx: ComponentIdx, parent: Option<ComponentIdx>, position: Option<DastPosition>) {
match self {
#(#initialize_variant_arms)*
}
Expand All @@ -317,13 +317,13 @@ pub fn component_node_derive(input: TokenStream) -> TokenStream {
}
}

fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentInd>>) {
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentIdx>>) {
match self {
#(#set_descendant_names_variant_arms)*
}
}

fn get_descendant_matches(&self, name: &str) -> Option<&Vec<ComponentInd>> {
fn get_descendant_matches(&self, name: &str) -> Option<&Vec<ComponentIdx>> {
match self {
#(#get_descendant_matches_variant_arms)*
}
Expand Down
30 changes: 15 additions & 15 deletions packages/doenetml-worker-rust/doenetml-core/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ComponentInd>;
fn set_parent(&mut self, parent: Option<ComponentInd>);
fn get_idx(&self) -> ComponentIdx;
fn set_idx(&mut self, idx: ComponentIdx);
fn get_parent(&self) -> Option<ComponentIdx>;
fn set_parent(&mut self, parent: Option<ComponentIdx>);
fn get_children(&self) -> &Vec<ComponentChild>;
fn set_children(&mut self, children: Vec<ComponentChild>);
fn replace_children(&mut self, new_children: Vec<ComponentChild>) -> Vec<ComponentChild>;

fn initialize(
&mut self,
ind: ComponentInd,
parent: Option<ComponentInd>,
idx: ComponentIdx,
parent: Option<ComponentIdx>,
position: Option<DastPosition>,
);

Expand All @@ -54,8 +54,8 @@ pub trait ComponentNode {

fn get_component_type(&self) -> &str;

fn get_descendant_matches(&self, name: &str) -> Option<&Vec<ComponentInd>>;
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentInd>>);
fn get_descendant_matches(&self, name: &str) -> Option<&Vec<ComponentIdx>>;
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentIdx>>);

fn get_position(&self) -> &Option<DastPosition>;
fn set_position(&mut self, position: Option<DastPosition>);
Expand All @@ -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()
}
Expand All @@ -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,
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ComponentInd>,
pub idx: ComponentIdx,
pub parent: Option<ComponentIdx>,
pub children: Vec<ComponentChild>,

pub extend: Option<ExtendSource>,

// map of descendant names to their indices
pub descendant_names: HashMap<String, Vec<ComponentInd>>,
pub descendant_names: HashMap<String, Vec<ComponentIdx>>,

pub position: Option<DastPosition>,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
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<ComponentInd>,
pub idx: ComponentIdx,
pub parent: Option<ComponentIdx>,
pub children: Vec<ComponentChild>,

pub extend: Option<ExtendSource>,

// map of descendant names to their indices
pub descendant_names: HashMap<String, Vec<ComponentInd>>,
pub descendant_names: HashMap<String, Vec<ComponentIdx>>,

pub position: Option<DastPosition>,

pub name: String,
}

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<ComponentInd> {
fn get_parent(&self) -> Option<ComponentIdx> {
self.parent
}
fn set_parent(&mut self, parent: Option<ComponentInd>) {
fn set_parent(&mut self, parent: Option<ComponentIdx>) {
self.parent = parent;
}
fn get_children(&self) -> &Vec<ComponentChild> {
Expand All @@ -46,11 +46,11 @@ impl ComponentNode for _External {

fn initialize(
&mut self,
ind: ComponentInd,
parent: Option<ComponentInd>,
idx: ComponentIdx,
parent: Option<ComponentIdx>,
position: Option<DastPosition>,
) {
self.ind = ind;
self.idx = idx;
self.parent = parent;
self.position = position;
}
Expand All @@ -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<ComponentInd>> {
fn get_descendant_matches(&self, name: &str) -> Option<&Vec<ComponentIdx>> {
self.descendant_names.get(name)
}
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentInd>>) {
fn set_descendant_names(&mut self, descendant_names: HashMap<String, Vec<ComponentIdx>>) {
self.descendant_names = descendant_names;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ComponentInd>,
pub idx: ComponentIdx,
pub parent: Option<ComponentIdx>,
pub children: Vec<ComponentChild>,

pub extend: Option<ExtendSource>,

// map of descendant names to their indices
pub descendant_names: HashMap<String, Vec<ComponentInd>>,
pub descendant_names: HashMap<String, Vec<ComponentIdx>>,

pub position: Option<DastPosition>,
}
Original file line number Diff line number Diff line change
@@ -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<ComponentInd>,
pub idx: ComponentIdx,
pub parent: Option<ComponentIdx>,
pub children: Vec<ComponentChild>,

pub extend: Option<ExtendSource>,

// map of descendant names to their indices
pub descendant_names: HashMap<String, Vec<ComponentInd>>,
pub descendant_names: HashMap<String, Vec<ComponentIdx>>,

pub position: Option<DastPosition>,
}
Loading

0 comments on commit 289a1b9

Please sign in to comment.