fix comment naming

This commit is contained in:
Aleksey Kladov 2019-04-02 10:48:59 +03:00
parent 99e6438660
commit 3f3ff2f0f4
2 changed files with 15 additions and 13 deletions

View File

@ -1,6 +1,6 @@
---
created: "2019-02-18T09:22:24.062138085Z"
creator: insta@0.6.2
created: "2019-04-02T07:43:12.954637543Z"
creator: insta@0.7.4
source: crates/ra_ide_api/src/completion/completion_item.rs
expression: kind_completions
---
@ -33,6 +33,9 @@ expression: kind_completions
delete: [180; 180),
insert: "S",
kind: EnumVariant,
detail: "(S)"
detail: "(S)",
documentation: Documentation(
""
)
}
]

View File

@ -24,9 +24,9 @@ impl<'a> Comment<'a> {
pub fn flavor(&self) -> CommentFlavor {
let text = self.text();
if text.starts_with("///") {
CommentFlavor::Doc
CommentFlavor::OuterDoc
} else if text.starts_with("//!") {
CommentFlavor::ModuleDoc
CommentFlavor::InnerDoc
} else if text.starts_with("//") {
CommentFlavor::Line
} else {
@ -46,25 +46,24 @@ impl<'a> Comment<'a> {
#[derive(Debug, PartialEq, Eq)]
pub enum CommentFlavor {
Line,
Doc,
ModuleDoc,
OuterDoc,
InnerDoc,
Multiline,
}
impl CommentFlavor {
pub fn prefix(&self) -> &'static str {
use self::CommentFlavor::*;
match *self {
Line => "//",
Doc => "///",
ModuleDoc => "//!",
Multiline => "/*",
CommentFlavor::Line => "//",
CommentFlavor::OuterDoc => "///",
CommentFlavor::InnerDoc => "//!",
CommentFlavor::Multiline => "/*",
}
}
pub fn is_doc_comment(&self) -> bool {
match self {
CommentFlavor::Doc | CommentFlavor::ModuleDoc => true,
CommentFlavor::OuterDoc | CommentFlavor::InnerDoc => true,
_ => false,
}
}