From b6560e3ebb80a7a96b3c3598ecba232f799fe93f Mon Sep 17 00:00:00 2001 From: adamrk Date: Tue, 28 Apr 2020 10:23:45 +0200 Subject: Treat comments beginning with four slashes as regular line comments --- crates/ra_syntax/src/ast/tokens.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_syntax/src/ast/tokens.rs') diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs index 3865729b8..481813e38 100644 --- a/crates/ra_syntax/src/ast/tokens.rs +++ b/crates/ra_syntax/src/ast/tokens.rs @@ -48,6 +48,7 @@ pub enum CommentPlacement { const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = { use {CommentPlacement::*, CommentShape::*}; &[ + ("////", CommentKind { shape: Line, doc: None }), ("///", CommentKind { shape: Line, doc: Some(Outer) }), ("//!", CommentKind { shape: Line, doc: Some(Inner) }), ("/**", CommentKind { shape: Block, doc: Some(Outer) }), -- cgit v1.2.3 From 0bd7d81805df16c8d1f200b13e485f6dda22f104 Mon Sep 17 00:00:00 2001 From: adamrk Date: Tue, 28 Apr 2020 21:13:37 +0200 Subject: Fix comment prefix method for four slash comments --- crates/ra_syntax/src/ast/tokens.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'crates/ra_syntax/src/ast/tokens.rs') 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 { } pub fn prefix(&self) -> &'static str { - prefix_by_kind(self.kind()) + for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() { + if *k == self.kind() && self.text().starts_with(prefix) { + return prefix; + } + } + unreachable!() } } @@ -70,15 +75,6 @@ fn kind_by_prefix(text: &str) -> CommentKind { panic!("bad comment text: {:?}", text) } -fn prefix_by_kind(kind: CommentKind) -> &'static str { - for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() { - if *k == kind { - return prefix; - } - } - unreachable!() -} - impl Whitespace { pub fn spans_multiple_lines(&self) -> bool { let text = self.text(); -- cgit v1.2.3