1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::lang::Java;
use crate::tokens;
use crate::Tokens;

/// Format a block comment, starting with `/**`, and ending in `*/`.
///
/// This struct is created by the [block_comment][super::block_comment()] function.
pub struct BlockComment<T>(pub(super) T);

impl<T> tokens::FormatInto<Java> for BlockComment<T>
where
    T: IntoIterator,
    T::Item: Into<tokens::ItemStr>,
{
    fn format_into(self, tokens: &mut Tokens<Java>) {
        let mut it = self.0.into_iter().peekable();

        if it.peek().is_none() {
            return;
        }

        tokens.push();
        tokens.append(tokens::static_literal("/**"));
        tokens.push();

        for line in it {
            tokens.space();
            tokens.append(tokens::static_literal("*"));
            tokens.space();
            tokens.append(line.into());
            tokens.push();
        }

        tokens.space();
        tokens.append("*/");
    }
}