From 757e593b253b4df7e6fc8bf15a4d4f34c9d484c5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 27 Nov 2019 21:32:33 +0300 Subject: rename ra_ide_api -> ra_ide --- crates/ra_ide_api/src/display/short_label.rs | 97 ---------------------------- 1 file changed, 97 deletions(-) delete mode 100644 crates/ra_ide_api/src/display/short_label.rs (limited to 'crates/ra_ide_api/src/display/short_label.rs') diff --git a/crates/ra_ide_api/src/display/short_label.rs b/crates/ra_ide_api/src/display/short_label.rs deleted file mode 100644 index 9ffc9b980..000000000 --- a/crates/ra_ide_api/src/display/short_label.rs +++ /dev/null @@ -1,97 +0,0 @@ -//! FIXME: write short doc here - -use format_buf::format; -use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; - -pub(crate) trait ShortLabel { - fn short_label(&self) -> Option; -} - -impl ShortLabel for ast::FnDef { - fn short_label(&self) -> Option { - Some(crate::display::function_label(self)) - } -} - -impl ShortLabel for ast::StructDef { - fn short_label(&self) -> Option { - short_label_from_node(self, "struct ") - } -} - -impl ShortLabel for ast::UnionDef { - fn short_label(&self) -> Option { - short_label_from_node(self, "union ") - } -} - -impl ShortLabel for ast::EnumDef { - fn short_label(&self) -> Option { - short_label_from_node(self, "enum ") - } -} - -impl ShortLabel for ast::TraitDef { - fn short_label(&self) -> Option { - short_label_from_node(self, "trait ") - } -} - -impl ShortLabel for ast::Module { - fn short_label(&self) -> Option { - short_label_from_node(self, "mod ") - } -} - -impl ShortLabel for ast::TypeAliasDef { - fn short_label(&self) -> Option { - short_label_from_node(self, "type ") - } -} - -impl ShortLabel for ast::ConstDef { - fn short_label(&self) -> Option { - short_label_from_ascribed_node(self, "const ") - } -} - -impl ShortLabel for ast::StaticDef { - fn short_label(&self) -> Option { - short_label_from_ascribed_node(self, "static ") - } -} - -impl ShortLabel for ast::RecordFieldDef { - fn short_label(&self) -> Option { - short_label_from_ascribed_node(self, "") - } -} - -impl ShortLabel for ast::EnumVariant { - fn short_label(&self) -> Option { - Some(self.name()?.text().to_string()) - } -} - -fn short_label_from_ascribed_node(node: &T, prefix: &str) -> Option -where - T: NameOwner + VisibilityOwner + TypeAscriptionOwner, -{ - let mut buf = short_label_from_node(node, prefix)?; - - if let Some(type_ref) = node.ascribed_type() { - format!(buf, ": {}", type_ref.syntax()); - } - - Some(buf) -} - -fn short_label_from_node(node: &T, label: &str) -> Option -where - T: NameOwner + VisibilityOwner, -{ - let mut buf = node.visibility().map(|v| format!("{} ", v.syntax())).unwrap_or_default(); - buf.push_str(label); - buf.push_str(node.name()?.text().as_str()); - Some(buf) -} -- cgit v1.2.3