mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Goto type definition works for self
This commit is contained in:
parent
5fa8f8e376
commit
b85042601d
5 changed files with 51 additions and 8 deletions
|
@ -115,6 +115,7 @@ impl SourceAnalyzer {
|
|||
Some(res)
|
||||
}
|
||||
|
||||
// TODO: rename
|
||||
pub(crate) fn type_of(&self, db: &dyn HirDatabase, expr: &ast::Expr) -> Option<Type> {
|
||||
let expr_id = self.expr_id(db, expr)?;
|
||||
let ty = self.infer.as_ref()?[expr_id].clone();
|
||||
|
@ -127,6 +128,17 @@ impl SourceAnalyzer {
|
|||
Type::new_with_resolver(db, &self.resolver, ty)
|
||||
}
|
||||
|
||||
pub(crate) fn type_of_self(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
param: &ast::SelfParam,
|
||||
) -> Option<Type> {
|
||||
let src = InFile { file_id: self.file_id, value: param };
|
||||
let pat_id = self.body_source_map.as_ref()?.node_self_param(src)?;
|
||||
let ty = self.infer.as_ref()?[pat_id].clone();
|
||||
Type::new_with_resolver(db, &self.resolver, ty)
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_method_call(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue