mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Resolve paths to defs (functions currently) during type inference
This commit is contained in:
parent
93ffbf80c6
commit
ef67581104
17 changed files with 215 additions and 87 deletions
|
@ -29,7 +29,7 @@ mod ty;
|
|||
|
||||
use std::ops::Index;
|
||||
|
||||
use ra_syntax::{SyntaxNodeRef, SyntaxNode};
|
||||
use ra_syntax::{SyntaxNodeRef, SyntaxNode, SyntaxKind};
|
||||
use ra_db::{LocationIntener, SourceRootId, FileId, Cancelable};
|
||||
|
||||
use crate::{
|
||||
|
@ -67,6 +67,23 @@ pub struct DefLoc {
|
|||
source_item_id: SourceItemId,
|
||||
}
|
||||
|
||||
impl DefKind {
|
||||
pub(crate) fn for_syntax_kind(kind: SyntaxKind) -> Option<DefKind> {
|
||||
match kind {
|
||||
SyntaxKind::FN_DEF => Some(DefKind::Function),
|
||||
SyntaxKind::MODULE => Some(DefKind::Module),
|
||||
// These define items, but don't have their own DefKinds yet:
|
||||
SyntaxKind::STRUCT_DEF => Some(DefKind::Item),
|
||||
SyntaxKind::ENUM_DEF => Some(DefKind::Item),
|
||||
SyntaxKind::TRAIT_DEF => Some(DefKind::Item),
|
||||
SyntaxKind::TYPE_DEF => Some(DefKind::Item),
|
||||
SyntaxKind::CONST_DEF => Some(DefKind::Item),
|
||||
SyntaxKind::STATIC_DEF => Some(DefKind::Item),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DefId {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<LocationIntener<DefLoc, DefId>>) -> DefLoc {
|
||||
db.as_ref().id2loc(self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue