diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion.rs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index a846a7a3c..deff59cd3 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs | |||
@@ -13,7 +13,6 @@ mod complete_scope; | |||
13 | mod complete_postfix; | 13 | mod complete_postfix; |
14 | 14 | ||
15 | use ra_db::SourceDatabase; | 15 | use ra_db::SourceDatabase; |
16 | use ra_syntax::{ast::{self, AstNode}, SyntaxKind::{ATTR, COMMENT}}; | ||
17 | 16 | ||
18 | use crate::{ | 17 | use crate::{ |
19 | db, | 18 | db, |
@@ -70,43 +69,3 @@ pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Opti | |||
70 | complete_postfix::complete_postfix(&mut acc, &ctx); | 69 | complete_postfix::complete_postfix(&mut acc, &ctx); |
71 | Some(acc) | 70 | Some(acc) |
72 | } | 71 | } |
73 | |||
74 | pub fn function_label(node: &ast::FnDef) -> Option<String> { | ||
75 | let label: String = if let Some(body) = node.body() { | ||
76 | let body_range = body.syntax().range(); | ||
77 | let label: String = node | ||
78 | .syntax() | ||
79 | .children_with_tokens() | ||
80 | .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body | ||
81 | .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR)) // Filter out comments and attrs | ||
82 | .map(|node| node.to_string()) | ||
83 | .collect(); | ||
84 | label | ||
85 | } else { | ||
86 | node.syntax().text().to_string() | ||
87 | }; | ||
88 | |||
89 | Some(label.trim().to_owned()) | ||
90 | } | ||
91 | |||
92 | pub fn const_label(node: &ast::ConstDef) -> String { | ||
93 | let label: String = node | ||
94 | .syntax() | ||
95 | .children_with_tokens() | ||
96 | .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR)) | ||
97 | .map(|node| node.to_string()) | ||
98 | .collect(); | ||
99 | |||
100 | label.trim().to_owned() | ||
101 | } | ||
102 | |||
103 | pub fn type_label(node: &ast::TypeAliasDef) -> String { | ||
104 | let label: String = node | ||
105 | .syntax() | ||
106 | .children_with_tokens() | ||
107 | .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR)) | ||
108 | .map(|node| node.to_string()) | ||
109 | .collect(); | ||
110 | |||
111 | label.trim().to_owned() | ||
112 | } | ||