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.rs | 15 +++++++++++++++ crates/ra_syntax/src/ast/tokens.rs | 1 + 2 files changed, 16 insertions(+) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 7fca5661e..a716e525b 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -242,6 +242,21 @@ fn test_comments_preserve_trailing_whitespace() { ); } +#[test] +fn test_four_slash_line_comment() { + let file = SourceFile::parse( + r#" + //// too many slashes to be a doc comment + /// doc comment + mod foo {} + "#, + ) + .ok() + .unwrap(); + let module = file.syntax().descendants().find_map(Module::cast).unwrap(); + assert_eq!("doc comment", module.doc_comment_text().unwrap()); +} + #[test] fn test_where_predicates() { fn assert_bound(text: &str, bound: Option) { 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