pub struct CodeBlock { /* private fields */ }
Expand description
Plain list of nodes that can be rendered to a Kotlin code.
Implementations§
Source§impl CodeBlock
impl CodeBlock
Sourcepub fn atom(text: &str) -> CodeBlock
pub fn atom(text: &str) -> CodeBlock
Creates code block with a single atom node. Please avoid using it in [RenderKotlin::render], prefer CodeBlock::empty and CodeBlock::push_atom instead.
Sourcepub fn statement(text: &str) -> CodeBlock
pub fn statement(text: &str) -> CodeBlock
Creates code block with a single atom node and empty line.
Sourcepub fn push_statement(&mut self, text: &str)
pub fn push_statement(&mut self, text: &str)
Pushes [text] as atom and adds new line after it.
Sourcepub fn push_renderable<T: RenderKotlin>(&mut self, renderable: &T)
pub fn push_renderable<T: RenderKotlin>(&mut self, renderable: &T)
Embeds all node from [code_block] into [self].
Sourcepub fn push_indent(&mut self)
pub fn push_indent(&mut self)
Adds [CodeBlockNode::Indent] with value 1. In case there is already [CodeBlockNode::Indent] at the end of the list, increments its value.
Sourcepub fn push_unindent(&mut self)
pub fn push_unindent(&mut self)
Adds [CodeBlockNode::Unindent] with value 1 In case there is already [CodeBlockNode::Unindent] at the end of the list, increments its value.
Sourcepub fn push_new_line(&mut self)
pub fn push_new_line(&mut self)
Adds [CodeBlockNode::NewLine]
Sourcepub fn push_space(&mut self)
pub fn push_space(&mut self)
Adds [CodeBlockNode::Space]
Sourcepub fn push_curly_brackets<F>(&mut self, block: F)
pub fn push_curly_brackets<F>(&mut self, block: F)
Surrounds first parameter [block] with curly brackets + indent and adds it to [self].
Sourcepub fn push_round_brackets<F>(&mut self, block: F)
pub fn push_round_brackets<F>(&mut self, block: F)
Surrounds first parameter [block] with round brackets and adds it to [self].
Sourcepub fn push_angle_brackets<F>(&mut self, block: F)
pub fn push_angle_brackets<F>(&mut self, block: F)
Surrounds first parameter [block] with angle brackets and adds it to [self].
Sourcepub fn push_comma_separated<F>(&mut self, elements: &[F])where
F: RenderKotlin,
pub fn push_comma_separated<F>(&mut self, elements: &[F])where
F: RenderKotlin,
Adds all elements from [elements] with comma separation, except for last one