diff options
author | Florian Diebold <[email protected]> | 2018-12-23 16:13:11 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2018-12-23 16:13:11 +0000 |
commit | ef67581104eb00a0c199f0b2a3b558da8a6f90a2 (patch) | |
tree | b6cf180b26152fa06ec4b2d02e22221fb7ba7fad /crates/ra_hir/src/lib.rs | |
parent | 93ffbf80c632a7d38fc8bbdf6357bfd26a96a35a (diff) |
Resolve paths to defs (functions currently) during type inference
Diffstat (limited to 'crates/ra_hir/src/lib.rs')
-rw-r--r-- | crates/ra_hir/src/lib.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index e84f44675..a0d99a84d 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -29,7 +29,7 @@ mod ty; | |||
29 | 29 | ||
30 | use std::ops::Index; | 30 | use std::ops::Index; |
31 | 31 | ||
32 | use ra_syntax::{SyntaxNodeRef, SyntaxNode}; | 32 | use ra_syntax::{SyntaxNodeRef, SyntaxNode, SyntaxKind}; |
33 | use ra_db::{LocationIntener, SourceRootId, FileId, Cancelable}; | 33 | use ra_db::{LocationIntener, SourceRootId, FileId, Cancelable}; |
34 | 34 | ||
35 | use crate::{ | 35 | use crate::{ |
@@ -67,6 +67,23 @@ pub struct DefLoc { | |||
67 | source_item_id: SourceItemId, | 67 | source_item_id: SourceItemId, |
68 | } | 68 | } |
69 | 69 | ||
70 | impl DefKind { | ||
71 | pub(crate) fn for_syntax_kind(kind: SyntaxKind) -> Option<DefKind> { | ||
72 | match kind { | ||
73 | SyntaxKind::FN_DEF => Some(DefKind::Function), | ||
74 | SyntaxKind::MODULE => Some(DefKind::Module), | ||
75 | // These define items, but don't have their own DefKinds yet: | ||
76 | SyntaxKind::STRUCT_DEF => Some(DefKind::Item), | ||
77 | SyntaxKind::ENUM_DEF => Some(DefKind::Item), | ||
78 | SyntaxKind::TRAIT_DEF => Some(DefKind::Item), | ||
79 | SyntaxKind::TYPE_DEF => Some(DefKind::Item), | ||
80 | SyntaxKind::CONST_DEF => Some(DefKind::Item), | ||
81 | SyntaxKind::STATIC_DEF => Some(DefKind::Item), | ||
82 | _ => None, | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
70 | impl DefId { | 87 | impl DefId { |
71 | pub(crate) fn loc(self, db: &impl AsRef<LocationIntener<DefLoc, DefId>>) -> DefLoc { | 88 | pub(crate) fn loc(self, db: &impl AsRef<LocationIntener<DefLoc, DefId>>) -> DefLoc { |
72 | db.as_ref().id2loc(self) | 89 | db.as_ref().id2loc(self) |