diff options
author | Jeremy A. Kolb <[email protected]> | 2019-01-22 23:20:40 +0000 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2019-01-22 23:20:40 +0000 |
commit | a3472f8fe16a359f9ea7a12e7b4920894921421e (patch) | |
tree | 6365cecd3c8e59246f22f7a10b86d96ae4462d8f /crates/ra_hir/src | |
parent | 070a9802246123c79709271c9ba6fddd6f888813 (diff) |
Move label from hir to ide_api
Diffstat (limited to 'crates/ra_hir/src')
-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)] |