diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 1b3525011..04fd335fe 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -33,7 +33,10 @@ use hir_ty::{ | |||
33 | }; | 33 | }; |
34 | use ra_db::{CrateId, Edition, FileId}; | 34 | use ra_db::{CrateId, Edition, FileId}; |
35 | use ra_prof::profile; | 35 | use ra_prof::profile; |
36 | use ra_syntax::ast::{self, AttrsOwner, NameOwner}; | 36 | use ra_syntax::{ |
37 | ast::{self, AttrsOwner, NameOwner}, | ||
38 | AstNode, | ||
39 | }; | ||
37 | use rustc_hash::FxHashSet; | 40 | use rustc_hash::FxHashSet; |
38 | 41 | ||
39 | use crate::{ | 42 | use crate::{ |
@@ -955,6 +958,16 @@ pub struct Local { | |||
955 | } | 958 | } |
956 | 959 | ||
957 | impl Local { | 960 | impl Local { |
961 | pub fn is_param(self, db: &dyn HirDatabase) -> bool { | ||
962 | let src = self.source(db); | ||
963 | match src.value { | ||
964 | Either::Left(bind_pat) => { | ||
965 | bind_pat.syntax().ancestors().any(|it| ast::Param::can_cast(it.kind())) | ||
966 | } | ||
967 | Either::Right(_self_param) => true, | ||
968 | } | ||
969 | } | ||
970 | |||
958 | // FIXME: why is this an option? It shouldn't be? | 971 | // FIXME: why is this an option? It shouldn't be? |
959 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { | 972 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { |
960 | let body = db.body(self.parent.into()); | 973 | let body = db.body(self.parent.into()); |