diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 21ca36265..9ae620efd 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -366,28 +366,6 @@ impl Function { | |||
366 | Some(comments) | 366 | Some(comments) |
367 | } | 367 | } |
368 | } | 368 | } |
369 | |||
370 | pub fn label(&self, db: &impl HirDatabase) -> Option<String> { | ||
371 | let def_loc = self.def_id.loc(db); | ||
372 | let syntax = db.file_item(def_loc.source_item_id); | ||
373 | let node = ast::FnDef::cast(&syntax).expect("fn def should point to FnDef node"); | ||
374 | |||
375 | let label: String = if let Some(body) = node.body() { | ||
376 | let body_range = body.syntax().range(); | ||
377 | let label: String = node | ||
378 | .syntax() | ||
379 | .children() | ||
380 | .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body | ||
381 | .filter(|child| ast::Comment::cast(child).is_none()) // Filter out comments | ||
382 | .map(|node| node.text().to_string()) | ||
383 | .collect(); | ||
384 | label | ||
385 | } else { | ||
386 | node.syntax().text().to_string() | ||
387 | }; | ||
388 | |||
389 | Some(label.trim().to_owned()) | ||
390 | } | ||
391 | } | 369 | } |
392 | 370 | ||
393 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |