mxmlextrema_as3parser/compilation_unit/
comment.rs1use crate::ns::*;
2
3pub struct Comment {
4 pub(crate) multiline: bool,
5 pub(crate) content: RefCell<String>,
6 pub(crate) location: RefCell<Location>,
7}
8
9impl Comment {
10 pub fn new(multiline: bool, content: String, location: Location) -> Self {
11 Self {
12 multiline,
13 content: RefCell::new(content),
14 location: RefCell::new(location),
15 }
16 }
17
18 pub fn multiline(&self) -> bool {
19 self.multiline
20 }
21
22 pub fn content(&self) -> String {
27 self.content.borrow().clone()
28 }
29
30 pub fn set_content(&self, content: String) {
31 self.content.replace(content);
32 }
33
34 pub fn location(&self) -> Location {
35 self.location.borrow().clone()
36 }
37
38 pub fn set_location(&self, location: Location) {
39 self.location.replace(location);
40 }
41
42 pub fn is_asdoc(&self, location_to_precede: &Location) -> bool {
45 if self.multiline && self.content.borrow().starts_with('*') {
46 let mut i: usize = self.location.borrow().last_offset;
47 for (i_1, ch) in self.location.borrow().compilation_unit().text()[i..].char_indices() {
48 i = i_1;
49 if !(CharacterValidator::is_whitespace(ch) || CharacterValidator::is_line_terminator(ch)) {
50 break;
51 }
52 }
53 i += self.location.borrow().last_offset;
54 location_to_precede.first_offset == i
55 } else {
56 false
57 }
58 }
59}