diff --git a/src/lang/abstractSyntaxTree.test.ts b/src/lang/abstractSyntaxTree.test.ts index 03214868b..162da20d3 100644 --- a/src/lang/abstractSyntaxTree.test.ts +++ b/src/lang/abstractSyntaxTree.test.ts @@ -1512,7 +1512,7 @@ const yo = { a: { b: { c: '123' } } } // this is a comment const key = 'c'` const nonCodeMetaInstance = { - type: 'NoneCodeNode', + type: 'NonCodeNode', start: code.indexOf('\n// this is a comment'), end: code.indexOf('const key'), value: { @@ -1521,17 +1521,17 @@ const key = 'c'` }, } const { nonCodeMeta } = parser_wasm(code) - expect(nonCodeMeta.noneCodeNodes[0]).toEqual(nonCodeMetaInstance) + expect(nonCodeMeta.nonCodeNodes[0]).toEqual(nonCodeMetaInstance) // extra whitespace won't change it's position (0) or value (NB the start end would have changed though) const codeWithExtraStartWhitespace = '\n\n\n' + code const { nonCodeMeta: nonCodeMeta2 } = parser_wasm( codeWithExtraStartWhitespace ) - expect(nonCodeMeta2.noneCodeNodes[0].value).toStrictEqual( + expect(nonCodeMeta2.nonCodeNodes[0].value).toStrictEqual( nonCodeMetaInstance.value ) - expect(nonCodeMeta2.noneCodeNodes[0].start).not.toBe( + expect(nonCodeMeta2.nonCodeNodes[0].start).not.toBe( nonCodeMetaInstance.start ) }) @@ -1548,9 +1548,9 @@ const key = 'c'` const { body } = parser_wasm(code) const indexOfSecondLineToExpression = 2 const sketchNonCodeMeta = (body as any)[0].declarations[0].init.nonCodeMeta - .noneCodeNodes + .nonCodeNodes expect(sketchNonCodeMeta[indexOfSecondLineToExpression]).toEqual({ - type: 'NoneCodeNode', + type: 'NonCodeNode', start: 106, end: 166, value: { @@ -1571,9 +1571,9 @@ const key = 'c'` const { body } = parser_wasm(code) const sketchNonCodeMeta = (body[0] as any).declarations[0].init.nonCodeMeta - .noneCodeNodes + .nonCodeNodes expect(sketchNonCodeMeta[3]).toEqual({ - type: 'NoneCodeNode', + type: 'NonCodeNode', start: 125, end: 141, value: { diff --git a/src/lang/abstractSyntaxTreeTypes.ts b/src/lang/abstractSyntaxTreeTypes.ts index 28c6a1562..559b06bee 100644 --- a/src/lang/abstractSyntaxTreeTypes.ts +++ b/src/lang/abstractSyntaxTreeTypes.ts @@ -33,5 +33,5 @@ export type SyntaxType = | 'PipeExpression' | 'PipeSubstitution' | 'Literal' - | 'NoneCodeNode' + | 'NonCodeNode' | 'UnaryExpression' diff --git a/src/lang/modifyAst.test.ts b/src/lang/modifyAst.test.ts index 8e6d8994f..2d51a2ed6 100644 --- a/src/lang/modifyAst.test.ts +++ b/src/lang/modifyAst.test.ts @@ -106,7 +106,7 @@ describe('Testing addSketchTo', () => { body: [], start: 0, end: 0, - nonCodeMeta: { noneCodeNodes: {}, start: null }, + nonCodeMeta: { nonCodeNodes: {}, start: null }, }, 'yz' ) diff --git a/src/lang/modifyAst.ts b/src/lang/modifyAst.ts index f94d47bd5..1cef78b85 100644 --- a/src/lang/modifyAst.ts +++ b/src/lang/modifyAst.ts @@ -537,7 +537,7 @@ export function createPipeExpression( start: 0, end: 0, body, - nonCodeMeta: { noneCodeNodes: {}, start: null }, + nonCodeMeta: { nonCodeNodes: {}, start: null }, } } diff --git a/src/useStore.ts b/src/useStore.ts index aaf16e883..24d19a6de 100644 --- a/src/useStore.ts +++ b/src/useStore.ts @@ -322,7 +322,7 @@ export const useStore = create()( end: 0, body: [], nonCodeMeta: { - noneCodeNodes: {}, + nonCodeNodes: {}, start: null, }, }, @@ -554,7 +554,7 @@ async function executeCode({ end: 0, body: [], nonCodeMeta: { - noneCodeNodes: {}, + nonCodeNodes: {}, start: null, }, }, diff --git a/src/wasm-lib/kcl/src/ast/types.rs b/src/wasm-lib/kcl/src/ast/types.rs index eed259623..9e874eb5c 100644 --- a/src/wasm-lib/kcl/src/ast/types.rs +++ b/src/wasm-lib/kcl/src/ast/types.rs @@ -23,7 +23,7 @@ pub struct Program { pub start: usize, pub end: usize, pub body: Vec, - pub non_code_meta: NoneCodeMeta, + pub non_code_meta: NonCodeMeta, } impl Program { @@ -81,7 +81,7 @@ impl Program { "\n".to_string() }; - let custom_white_space_or_comment = match self.non_code_meta.none_code_nodes.get(&index) { + let custom_white_space_or_comment = match self.non_code_meta.non_code_nodes.get(&index) { Some(custom_white_space_or_comment) => custom_white_space_or_comment.format(&indentation), None => String::new(), }; @@ -640,26 +640,26 @@ impl BinaryPart { #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[ts(export)] #[serde(tag = "type")] -pub struct NoneCodeNode { +pub struct NonCodeNode { pub start: usize, pub end: usize, - pub value: NoneCodeValue, + pub value: NonCodeValue, } -impl NoneCodeNode { +impl NonCodeNode { pub fn value(&self) -> String { match &self.value { - NoneCodeValue::InlineComment { value } => value.clone(), - NoneCodeValue::BlockComment { value } => value.clone(), - NoneCodeValue::NewLineBlockComment { value } => value.clone(), - NoneCodeValue::NewLine => "\n\n".to_string(), + NonCodeValue::InlineComment { value } => value.clone(), + NonCodeValue::BlockComment { value } => value.clone(), + NonCodeValue::NewLineBlockComment { value } => value.clone(), + NonCodeValue::NewLine => "\n\n".to_string(), } } pub fn format(&self, indentation: &str) -> String { match &self.value { - NoneCodeValue::InlineComment { value } => format!(" // {}\n", value), - NoneCodeValue::BlockComment { value } => { + NonCodeValue::InlineComment { value } => format!(" // {}\n", value), + NonCodeValue::BlockComment { value } => { let add_start_new_line = if self.start == 0 { "" } else { "\n" }; if value.contains('\n') { format!("{}{}/* {} */\n", add_start_new_line, indentation, value) @@ -667,7 +667,7 @@ impl NoneCodeNode { format!("{}{}// {}\n", add_start_new_line, indentation, value) } } - NoneCodeValue::NewLineBlockComment { value } => { + NonCodeValue::NewLineBlockComment { value } => { let add_start_new_line = if self.start == 0 { "" } else { "\n\n" }; if value.contains('\n') { format!("{}{}/* {} */\n", add_start_new_line, indentation, value) @@ -675,7 +675,7 @@ impl NoneCodeNode { format!("{}{}// {}\n", add_start_new_line, indentation, value) } } - NoneCodeValue::NewLine => "\n\n".to_string(), + NonCodeValue::NewLine => "\n\n".to_string(), } } } @@ -683,7 +683,7 @@ impl NoneCodeNode { #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[ts(export)] #[serde(tag = "type", rename_all = "camelCase")] -pub enum NoneCodeValue { +pub enum NonCodeValue { /// An inline comment. /// An example of this is the following: `1 + 1 // This is an inline comment`. InlineComment { @@ -715,32 +715,32 @@ pub enum NoneCodeValue { #[derive(Debug, Default, Clone, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[ts(export)] #[serde(rename_all = "camelCase")] -pub struct NoneCodeMeta { - pub none_code_nodes: HashMap, - pub start: Option, +pub struct NonCodeMeta { + pub non_code_nodes: HashMap, + pub start: Option, } -// implement Deserialize manually because we to force the keys of none_code_nodes to be usize -// and by default the ts type { [statementIndex: number]: NoneCodeNode } serializes to a string i.e. "0", "1", etc. -impl<'de> Deserialize<'de> for NoneCodeMeta { - fn deserialize(deserializer: D) -> Result +// implement Deserialize manually because we to force the keys of non_code_nodes to be usize +// and by default the ts type { [statementIndex: number]: NonCodeNode } serializes to a string i.e. "0", "1", etc. +impl<'de> Deserialize<'de> for NonCodeMeta { + fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] - struct NoneCodeMetaHelper { - none_code_nodes: HashMap, - start: Option, + struct NonCodeMetaHelper { + non_code_nodes: HashMap, + start: Option, } - let helper = NoneCodeMetaHelper::deserialize(deserializer)?; - let mut none_code_nodes = HashMap::new(); - for (key, value) in helper.none_code_nodes { - none_code_nodes.insert(key.parse().map_err(serde::de::Error::custom)?, value); + let helper = NonCodeMetaHelper::deserialize(deserializer)?; + let mut non_code_nodes = HashMap::new(); + for (key, value) in helper.non_code_nodes { + non_code_nodes.insert(key.parse().map_err(serde::de::Error::custom)?, value); } - Ok(NoneCodeMeta { - none_code_nodes, + Ok(NonCodeMeta { + non_code_nodes, start: helper.start, }) } @@ -2231,7 +2231,7 @@ pub struct PipeExpression { pub start: usize, pub end: usize, pub body: Vec, - pub non_code_meta: NoneCodeMeta, + pub non_code_meta: NonCodeMeta, } impl_value_meta!(PipeExpression); @@ -2276,7 +2276,7 @@ impl PipeExpression { let indentation = options.get_indentation(indentation_level + 1); let mut s = statement.recast(options, indentation_level + 1, true); let non_code_meta = self.non_code_meta.clone(); - if let Some(non_code_meta_value) = non_code_meta.none_code_nodes.get(&index) { + if let Some(non_code_meta_value) = non_code_meta.non_code_nodes.get(&index) { s += non_code_meta_value.format(&indentation).trim_end_matches('\n') } @@ -2673,7 +2673,7 @@ show(part001)"#; #[test] fn test_recast_with_std_and_non_stdlib() { - let some_program_string = r#"{"body":[{"type":"VariableDeclaration","start":0,"end":0,"declarations":[{"type":"VariableDeclarator","start":0,"end":0,"id":{"type":"Identifier","start":0,"end":0,"name":"part001"},"init":{"type":"PipeExpression","start":0,"end":0,"body":[{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"startSketchAt"},"function":{"type":"StdLib","func":{"name":"startSketchAt","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}},"optional":false,"arguments":[{"type":"Literal","start":0,"end":0,"value":"default","raw":"default"}]},{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"ry"},"function":{"type":"InMemory"},"optional":false,"arguments":[{"type":"Literal","start":0,"end":0,"value":90,"raw":"90"},{"type":"PipeSubstitution","start":0,"end":0}]},{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"line"},"function":{"type":"StdLib","func":{"name":"line","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}},"optional":false,"arguments":[{"type":"Literal","start":0,"end":0,"value":"default","raw":"default"},{"type":"PipeSubstitution","start":0,"end":0}]}],"nonCodeMeta":{"noneCodeNodes":{},"start":null}}}],"kind":"const"},{"type":"ExpressionStatement","start":0,"end":0,"expression":{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"show"},"function":{"type":"StdLib","func":{"name":"show","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}},"optional":false,"arguments":[{"type":"Identifier","start":0,"end":0,"name":"part001"}]}}],"start":0,"end":0,"nonCodeMeta":{"noneCodeNodes":{},"start":null}}"#; + let some_program_string = r#"{"body":[{"type":"VariableDeclaration","start":0,"end":0,"declarations":[{"type":"VariableDeclarator","start":0,"end":0,"id":{"type":"Identifier","start":0,"end":0,"name":"part001"},"init":{"type":"PipeExpression","start":0,"end":0,"body":[{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"startSketchAt"},"function":{"type":"StdLib","func":{"name":"startSketchAt","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}},"optional":false,"arguments":[{"type":"Literal","start":0,"end":0,"value":"default","raw":"default"}]},{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"ry"},"function":{"type":"InMemory"},"optional":false,"arguments":[{"type":"Literal","start":0,"end":0,"value":90,"raw":"90"},{"type":"PipeSubstitution","start":0,"end":0}]},{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"line"},"function":{"type":"StdLib","func":{"name":"line","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}},"optional":false,"arguments":[{"type":"Literal","start":0,"end":0,"value":"default","raw":"default"},{"type":"PipeSubstitution","start":0,"end":0}]}],"nonCodeMeta":{"nonCodeNodes":{},"start":null}}}],"kind":"const"},{"type":"ExpressionStatement","start":0,"end":0,"expression":{"type":"CallExpression","start":0,"end":0,"callee":{"type":"Identifier","start":0,"end":0,"name":"show"},"function":{"type":"StdLib","func":{"name":"show","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{}},"args":[],"unpublished":false,"deprecated":false}},"optional":false,"arguments":[{"type":"Identifier","start":0,"end":0,"name":"part001"}]}}],"start":0,"end":0,"nonCodeMeta":{"nonCodeNodes":{},"start":null}}"#; let some_program: crate::ast::types::Program = serde_json::from_str(some_program_string).unwrap(); let recasted = some_program.recast(&Default::default(), 0); @@ -2889,7 +2889,7 @@ const things = "things" let some_program_string = r#"let b = { "end": 141, "start": 125, - "type": "NoneCodeNode", + "type": "NonCodeNode", "value": " // a comment " diff --git a/src/wasm-lib/kcl/src/parser.rs b/src/wasm-lib/kcl/src/parser.rs index 82759b8e3..d427cde3d 100644 --- a/src/wasm-lib/kcl/src/parser.rs +++ b/src/wasm-lib/kcl/src/parser.rs @@ -3,8 +3,8 @@ use std::{collections::HashMap, str::FromStr}; use crate::{ ast::types::{ ArrayExpression, BinaryExpression, BinaryPart, BodyItem, CallExpression, ExpressionStatement, - FunctionExpression, Identifier, Literal, LiteralIdentifier, MemberExpression, MemberObject, NoneCodeMeta, - NoneCodeNode, NoneCodeValue, ObjectExpression, ObjectKeyInfo, ObjectProperty, PipeExpression, PipeSubstitution, + FunctionExpression, Identifier, Literal, LiteralIdentifier, MemberExpression, MemberObject, NonCodeMeta, + NonCodeNode, NonCodeValue, ObjectExpression, ObjectKeyInfo, ObjectProperty, PipeExpression, PipeSubstitution, Program, ReturnStatement, UnaryExpression, UnaryOperator, Value, VariableDeclaration, VariableDeclarator, VariableKind, }, @@ -26,7 +26,7 @@ struct TokenReturn { struct TokenReturnWithNonCode { token: Option, index: usize, - non_code_node: Option, + non_code_node: Option, } #[derive(Debug, PartialEq, Clone)] @@ -57,7 +57,7 @@ struct ArrayReturn { struct PipeBodyReturn { body: Vec, last_index: usize, - non_code_meta: NoneCodeMeta, + non_code_meta: NonCodeMeta, } #[derive(Debug, PartialEq, Clone)] @@ -136,7 +136,7 @@ struct ReturnStatementResult { struct BodyResult { body: Vec, last_index: usize, - non_code_meta: NoneCodeMeta, + non_code_meta: NonCodeMeta, } #[derive(Debug, PartialEq, Clone)] @@ -183,8 +183,8 @@ impl Parser { let body = self.make_body( 0, vec![], - NoneCodeMeta { - none_code_nodes: HashMap::new(), + NonCodeMeta { + non_code_nodes: HashMap::new(), start: None, }, )?; @@ -269,7 +269,7 @@ impl Parser { Ok(index + 1) } - fn make_none_code_node(&self, index: usize) -> Result<(Option, usize), KclError> { + fn make_non_code_node(&self, index: usize) -> Result<(Option, usize), KclError> { let end_index = self.find_end_of_non_code_node(index)?; let start_index = self.find_start_of_non_code_node(index)?; let non_code_tokens = self.tokens[index..end_index].to_vec(); @@ -286,10 +286,10 @@ impl Parser { .contains("\n\n") { return Ok(( - Some(NoneCodeNode { + Some(NonCodeNode { start: self.tokens[start_index].start, end: self.tokens[end_index - 1].end, - value: NoneCodeValue::NewLine, + value: NonCodeValue::NewLine, }), end_index - 1, )); @@ -330,17 +330,17 @@ impl Parser { let is_new_line_comment = start_end_string.starts_with('\n') || start_end_string.contains('\n') || start_index == 0 || index == 0; - let node = NoneCodeNode { + let node = NonCodeNode { start: self.tokens[start_index].start, end: self.tokens[end_index - 1].end, value: if start_end_string.starts_with("\n\n") && is_new_line_comment { // Preserve if they want a whitespace line before the comment. // But let's just allow one. - NoneCodeValue::NewLineBlockComment { value: full_string } + NonCodeValue::NewLineBlockComment { value: full_string } } else if is_new_line_comment { - NoneCodeValue::BlockComment { value: full_string } + NonCodeValue::BlockComment { value: full_string } } else { - NoneCodeValue::InlineComment { value: full_string } + NonCodeValue::InlineComment { value: full_string } }, }; Ok((Some(node), end_index - 1)) @@ -366,7 +366,7 @@ impl Parser { }; if is_not_code_token(token) { - let non_code_node = self.make_none_code_node(new_index)?; + let non_code_node = self.make_non_code_node(new_index)?; let new_new_index = non_code_node.1 + 1; let bonus_non_code_node = non_code_node.0; @@ -1027,13 +1027,13 @@ impl Parser { &self, index: usize, previous_values: Vec, - previous_non_code_meta: Option, + previous_non_code_meta: Option, ) -> Result { let non_code_meta = match previous_non_code_meta { Some(meta) => meta, - None => NoneCodeMeta { + None => NonCodeMeta { start: None, - none_code_nodes: HashMap::new(), + non_code_nodes: HashMap::new(), }, }; let current_token = self.get_token(index)?; @@ -1060,10 +1060,10 @@ impl Parser { non_code_meta, }); } - let mut _non_code_meta: NoneCodeMeta; + let mut _non_code_meta: NonCodeMeta; if let Some(node) = next_pipe.non_code_node { _non_code_meta = non_code_meta; - _non_code_meta.none_code_nodes.insert(previous_values.len(), node); + _non_code_meta.non_code_nodes.insert(previous_values.len(), node); } else { _non_code_meta = non_code_meta; } @@ -1587,7 +1587,7 @@ impl Parser { &self, token_index: usize, previous_body: Vec, - previous_non_code_meta: NoneCodeMeta, + previous_non_code_meta: NonCodeMeta, ) -> Result { let mut non_code_meta = previous_non_code_meta; if self.tokens.is_empty() { @@ -1620,7 +1620,7 @@ impl Parser { if previous_body.is_empty() { non_code_meta.start = next_token.non_code_node; } else { - non_code_meta.none_code_nodes.insert(previous_body.len(), node.clone()); + non_code_meta.non_code_nodes.insert(previous_body.len(), node.clone()); } } return self.make_body(next_token.index, previous_body, non_code_meta); @@ -1628,14 +1628,14 @@ impl Parser { let next = self.next_meaningful_token(token_index, None)?; if let Some(node) = &next.non_code_node { - non_code_meta.none_code_nodes.insert(previous_body.len(), node.clone()); + non_code_meta.non_code_nodes.insert(previous_body.len(), node.clone()); } if token.token_type == TokenType::Keyword && VariableKind::from_str(&token.value).is_ok() { let declaration = self.make_variable_declaration(token_index)?; let next_thing = self.next_meaningful_token(declaration.last_index, None)?; if let Some(node) = &next_thing.non_code_node { - non_code_meta.none_code_nodes.insert(previous_body.len(), node.clone()); + non_code_meta.non_code_nodes.insert(previous_body.len(), node.clone()); } let mut _previous_body = previous_body; _previous_body.push(BodyItem::VariableDeclaration(VariableDeclaration { @@ -1656,7 +1656,7 @@ impl Parser { let statement = self.make_return_statement(token_index)?; let next_thing = self.next_meaningful_token(statement.last_index, None)?; if let Some(node) = &next_thing.non_code_node { - non_code_meta.none_code_nodes.insert(previous_body.len(), node.clone()); + non_code_meta.non_code_nodes.insert(previous_body.len(), node.clone()); } let mut _previous_body = previous_body; _previous_body.push(BodyItem::ReturnStatement(ReturnStatement { @@ -1680,7 +1680,7 @@ impl Parser { let expression = self.make_expression_statement(token_index)?; let next_thing = self.next_meaningful_token(expression.last_index, None)?; if let Some(node) = &next_thing.non_code_node { - non_code_meta.none_code_nodes.insert(previous_body.len(), node.clone()); + non_code_meta.non_code_nodes.insert(previous_body.len(), node.clone()); } let mut _previous_body = previous_body; _previous_body.push(BodyItem::ExpressionStatement(ExpressionStatement { @@ -1703,7 +1703,7 @@ impl Parser { && next_thing_token.token_type == TokenType::Operator { if let Some(node) = &next_thing.non_code_node { - non_code_meta.none_code_nodes.insert(previous_body.len(), node.clone()); + non_code_meta.non_code_nodes.insert(previous_body.len(), node.clone()); } let expression = self.make_expression_statement(token_index)?; let mut _previous_body = previous_body; @@ -1734,8 +1734,8 @@ impl Parser { BodyResult { body: vec![], last_index: next_token_index, - non_code_meta: NoneCodeMeta { - none_code_nodes: HashMap::new(), + non_code_meta: NonCodeMeta { + non_code_nodes: HashMap::new(), start: None, }, } @@ -1743,8 +1743,8 @@ impl Parser { self.make_body( next_token_index, vec![], - NoneCodeMeta { - none_code_nodes: HashMap::new(), + NonCodeMeta { + non_code_nodes: HashMap::new(), start: None, }, )? @@ -1870,16 +1870,16 @@ mod tests { ); } #[test] - fn test_make_none_code_node() { + fn test_make_non_code_node() { let tokens = crate::tokeniser::lexer("log(5, \"hello\", aIdentifier)"); let parser = Parser::new(tokens); let index = 4; let expected_output = (None, 4); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); let index = 7; let expected_output = (None, 7); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); let tokens = crate::tokeniser::lexer( r#" const yo = { a: { b: { c: '123' } } } @@ -1889,28 +1889,28 @@ const key = 'c'"#, let parser = Parser::new(tokens); let index = 0; let expected_output = (None, 0); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); let index = 2; let expected_output = (None, 2); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); let index = 2; let expected_output = (None, 2); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); let index = 29; let expected_output = ( - Some(NoneCodeNode { + Some(NonCodeNode { start: 38, end: 60, - value: NoneCodeValue::BlockComment { + value: NonCodeValue::BlockComment { value: "this is a comment".to_string(), }, }), 31, ); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); let tokens = crate::tokeniser::lexer( r#"const mySketch = startSketchAt([0,0]) |> lineTo({ to: [0, 1], tag: 'myPath' }, %) @@ -1923,16 +1923,16 @@ const key = 'c'"#, let parser = Parser::new(tokens); let index = 57; let expected_output = ( - Some(NoneCodeNode { + Some(NonCodeNode { start: 106, end: 166, - value: NoneCodeValue::BlockComment { + value: NonCodeValue::BlockComment { value: "this is\n a comment\n spanning a few lines".to_string(), }, }), 59, ); - assert_eq!(parser.make_none_code_node(index).unwrap(), expected_output); + assert_eq!(parser.make_non_code_node(index).unwrap(), expected_output); } #[test] @@ -2905,8 +2905,8 @@ show(mySk1)"#; .make_body( 0, vec![], - NoneCodeMeta { - none_code_nodes: HashMap::new(), + NonCodeMeta { + non_code_nodes: HashMap::new(), start: None, }, ) @@ -2943,8 +2943,8 @@ show(mySk1)"#; })), })), })], - non_code_meta: NoneCodeMeta { - none_code_nodes: Default::default(), + non_code_meta: NonCodeMeta { + non_code_nodes: Default::default(), start: None, }, }; @@ -3278,8 +3278,8 @@ e }], kind: VariableKind::Const, })], - non_code_meta: NoneCodeMeta { - none_code_nodes: Default::default(), + non_code_meta: NonCodeMeta { + non_code_nodes: Default::default(), start: None, }, };