aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs15
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};
34use ra_db::{CrateId, Edition, FileId}; 34use ra_db::{CrateId, Edition, FileId};
35use ra_prof::profile; 35use ra_prof::profile;
36use ra_syntax::ast::{self, AttrsOwner, NameOwner}; 36use ra_syntax::{
37 ast::{self, AttrsOwner, NameOwner},
38 AstNode,
39};
37use rustc_hash::FxHashSet; 40use rustc_hash::FxHashSet;
38 41
39use crate::{ 42use crate::{
@@ -955,6 +958,16 @@ pub struct Local {
955} 958}
956 959
957impl Local { 960impl 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());