diff options
author | adamrk <[email protected]> | 2020-04-28 20:13:37 +0100 |
---|---|---|
committer | adamrk <[email protected]> | 2020-04-28 20:13:37 +0100 |
commit | 0bd7d81805df16c8d1f200b13e485f6dda22f104 (patch) | |
tree | 34009cc9dc3b541ddcc3047377eb497bae150bd4 /crates/ra_syntax/src/ast | |
parent | b6560e3ebb80a7a96b3c3598ecba232f799fe93f (diff) |
Fix comment prefix method for four slash comments
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/tokens.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs index 481813e38..74906d8a6 100644 --- a/crates/ra_syntax/src/ast/tokens.rs +++ b/crates/ra_syntax/src/ast/tokens.rs | |||
@@ -13,7 +13,12 @@ impl Comment { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | pub fn prefix(&self) -> &'static str { | 15 | pub fn prefix(&self) -> &'static str { |
16 | prefix_by_kind(self.kind()) | 16 | for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() { |
17 | if *k == self.kind() && self.text().starts_with(prefix) { | ||
18 | return prefix; | ||
19 | } | ||
20 | } | ||
21 | unreachable!() | ||
17 | } | 22 | } |
18 | } | 23 | } |
19 | 24 | ||
@@ -70,15 +75,6 @@ fn kind_by_prefix(text: &str) -> CommentKind { | |||
70 | panic!("bad comment text: {:?}", text) | 75 | panic!("bad comment text: {:?}", text) |
71 | } | 76 | } |
72 | 77 | ||
73 | fn prefix_by_kind(kind: CommentKind) -> &'static str { | ||
74 | for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() { | ||
75 | if *k == kind { | ||
76 | return prefix; | ||
77 | } | ||
78 | } | ||
79 | unreachable!() | ||
80 | } | ||
81 | |||
82 | impl Whitespace { | 78 | impl Whitespace { |
83 | pub fn spans_multiple_lines(&self) -> bool { | 79 | pub fn spans_multiple_lines(&self) -> bool { |
84 | let text = self.text(); | 80 | let text = self.text(); |