aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-11 13:52:20 +0100
committerGitHub <[email protected]>2020-07-11 13:52:20 +0100
commit607d99fa8435523121c442c45653f0a430567c62 (patch)
tree5b39f39acd93780faa5809dda2b11cec106ad182 /crates/ra_hir
parent87ddcba05fe1a80e293565cd09a61c83adc6bc7d (diff)
parente1d6b7f7c48d82c3c03550bc702e64cd7d079c99 (diff)
Merge #5314
5314: Use dedicated semantic highlight tag for parameters r=matklad a=matklad closes #5106 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-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());