use ec4rs::{
PropertyKey,
property::{IndentSize, IndentStyle, TabWidth},
rawvalue::RawValue,
};
use super::super::IndentationHandler;
pub fn build_indentation_handler(
indent_style: Option<IndentStyle>,
indent_size: Option<IndentSize>,
tab_width: Option<TabWidth>,
) -> IndentationHandler {
let mut properties = ec4rs::Properties::new();
add_property_option(&mut properties, indent_style);
add_property_option(&mut properties, indent_size);
add_property_option(&mut properties, tab_width);
IndentationHandler::build(&properties)
.expect("Every test case lead to properties, which needs to be handled")
}
fn add_property_option<P: PropertyKey + Into<RawValue>>(
properties: &mut ec4rs::Properties,
property: Option<P>,
) {
if let Some(value) = property {
properties.insert::<P>(value);
}
}