diff options
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/defs.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index 9d7dce1d4..d33a6cb86 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs | |||
@@ -6,8 +6,8 @@ | |||
6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). | 6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). |
7 | 7 | ||
8 | use hir::{ | 8 | use hir::{ |
9 | db::HirDatabase, Crate, Field, HasVisibility, Impl, LifetimeParam, Local, MacroDef, Module, | 9 | db::HirDatabase, Crate, Field, HasVisibility, Impl, Label, LifetimeParam, Local, MacroDef, |
10 | ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, | 10 | Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, |
11 | }; | 11 | }; |
12 | use syntax::{ | 12 | use syntax::{ |
13 | ast::{self, AstNode}, | 13 | ast::{self, AstNode}, |
@@ -26,7 +26,7 @@ pub enum Definition { | |||
26 | Local(Local), | 26 | Local(Local), |
27 | TypeParam(TypeParam), | 27 | TypeParam(TypeParam), |
28 | LifetimeParam(LifetimeParam), | 28 | LifetimeParam(LifetimeParam), |
29 | // FIXME: Label | 29 | Label(Label), |
30 | } | 30 | } |
31 | 31 | ||
32 | impl Definition { | 32 | impl Definition { |
@@ -39,6 +39,7 @@ impl Definition { | |||
39 | Definition::Local(it) => Some(it.module(db)), | 39 | Definition::Local(it) => Some(it.module(db)), |
40 | Definition::TypeParam(it) => Some(it.module(db)), | 40 | Definition::TypeParam(it) => Some(it.module(db)), |
41 | Definition::LifetimeParam(it) => Some(it.module(db)), | 41 | Definition::LifetimeParam(it) => Some(it.module(db)), |
42 | Definition::Label(it) => Some(it.module(db)), | ||
42 | } | 43 | } |
43 | } | 44 | } |
44 | 45 | ||
@@ -51,6 +52,7 @@ impl Definition { | |||
51 | Definition::Local(_) => None, | 52 | Definition::Local(_) => None, |
52 | Definition::TypeParam(_) => None, | 53 | Definition::TypeParam(_) => None, |
53 | Definition::LifetimeParam(_) => None, | 54 | Definition::LifetimeParam(_) => None, |
55 | Definition::Label(_) => None, | ||
54 | } | 56 | } |
55 | } | 57 | } |
56 | 58 | ||
@@ -77,6 +79,7 @@ impl Definition { | |||
77 | Definition::Local(it) => it.name(db)?, | 79 | Definition::Local(it) => it.name(db)?, |
78 | Definition::TypeParam(it) => it.name(db), | 80 | Definition::TypeParam(it) => it.name(db), |
79 | Definition::LifetimeParam(it) => it.name(db), | 81 | Definition::LifetimeParam(it) => it.name(db), |
82 | Definition::Label(it) => it.name(db), | ||
80 | }; | 83 | }; |
81 | Some(name) | 84 | Some(name) |
82 | } | 85 | } |
@@ -248,7 +251,10 @@ impl NameClass { | |||
248 | let def = sema.to_def(&it)?; | 251 | let def = sema.to_def(&it)?; |
249 | Some(NameClass::Definition(Definition::LifetimeParam(def))) | 252 | Some(NameClass::Definition(Definition::LifetimeParam(def))) |
250 | }, | 253 | }, |
251 | ast::Label(_it) => None, | 254 | ast::Label(it) => { |
255 | let def = sema.to_def(&it)?; | ||
256 | Some(NameClass::Definition(Definition::Label(def))) | ||
257 | }, | ||
252 | _ => None, | 258 | _ => None, |
253 | } | 259 | } |
254 | } | 260 | } |
@@ -370,6 +376,9 @@ impl NameRefClass { | |||
370 | let _p = profile::span("classify_lifetime_ref").detail(|| lifetime.to_string()); | 376 | let _p = profile::span("classify_lifetime_ref").detail(|| lifetime.to_string()); |
371 | let parent = lifetime.syntax().parent()?; | 377 | let parent = lifetime.syntax().parent()?; |
372 | match parent.kind() { | 378 | match parent.kind() { |
379 | SyntaxKind::BREAK_EXPR | SyntaxKind::CONTINUE_EXPR => { | ||
380 | sema.resolve_label(lifetime).map(Definition::Label).map(NameRefClass::Definition) | ||
381 | } | ||
373 | SyntaxKind::LIFETIME_ARG | 382 | SyntaxKind::LIFETIME_ARG |
374 | | SyntaxKind::SELF_PARAM | 383 | | SyntaxKind::SELF_PARAM |
375 | | SyntaxKind::TYPE_BOUND | 384 | | SyntaxKind::TYPE_BOUND |
@@ -387,7 +396,6 @@ impl NameRefClass { | |||
387 | .map(Definition::LifetimeParam) | 396 | .map(Definition::LifetimeParam) |
388 | .map(NameRefClass::Definition) | 397 | .map(NameRefClass::Definition) |
389 | } | 398 | } |
390 | SyntaxKind::BREAK_EXPR | SyntaxKind::CONTINUE_EXPR => None, | ||
391 | _ => None, | 399 | _ => None, |
392 | } | 400 | } |
393 | } | 401 | } |