use crate::io::RenderKotlin;
use crate::spec::CodeBlock;
use crate::tokens;
#[derive(Debug, Clone)]
pub enum AnnotationTarget {
File,
Property,
Field,
Get,
Set,
Receiver,
Param,
SetParam,
Delegate,
}
impl RenderKotlin for AnnotationTarget {
fn render_into(&self, block: &mut CodeBlock) {
let atom = match self {
AnnotationTarget::File => tokens::keyword::FILE,
AnnotationTarget::Property => tokens::keyword::PROPERTY,
AnnotationTarget::Field => tokens::keyword::FIELD,
AnnotationTarget::Get => tokens::keyword::GET,
AnnotationTarget::Set => tokens::keyword::SET,
AnnotationTarget::Receiver => tokens::keyword::RECEIVER,
AnnotationTarget::Param => tokens::keyword::PARAM,
AnnotationTarget::SetParam => tokens::keyword::SET_PARAM,
AnnotationTarget::Delegate => tokens::keyword::DELEGATE,
};
block.push_atom(atom)
}
}
#[cfg(test)]
mod tests {
use crate::io::RenderKotlin;
use crate::spec::AnnotationTarget;
#[test]
fn test_annotation_target() {
assert_eq!(AnnotationTarget::Field.render_string(), "field");
assert_eq!(AnnotationTarget::File.render_string(), "file");
assert_eq!(AnnotationTarget::Get.render_string(), "get");
assert_eq!(AnnotationTarget::Param.render_string(), "param");
assert_eq!(AnnotationTarget::Property.render_string(), "property");
assert_eq!(AnnotationTarget::Receiver.render_string(), "receiver");
assert_eq!(AnnotationTarget::Set.render_string(), "set");
assert_eq!(AnnotationTarget::SetParam.render_string(), "setparam");
assert_eq!(AnnotationTarget::Delegate.render_string(), "delegate");
}
}