From e1d6b7f7c48d82c3c03550bc702e64cd7d079c99 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Jul 2020 14:50:00 +0200 Subject: Use dedicated semantic highlight tag for parameters closes #5106 --- crates/ra_hir/src/code_model.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir') 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::{ }; use ra_db::{CrateId, Edition, FileId}; use ra_prof::profile; -use ra_syntax::ast::{self, AttrsOwner, NameOwner}; +use ra_syntax::{ + ast::{self, AttrsOwner, NameOwner}, + AstNode, +}; use rustc_hash::FxHashSet; use crate::{ @@ -955,6 +958,16 @@ pub struct Local { } impl Local { + pub fn is_param(self, db: &dyn HirDatabase) -> bool { + let src = self.source(db); + match src.value { + Either::Left(bind_pat) => { + bind_pat.syntax().ancestors().any(|it| ast::Param::can_cast(it.kind())) + } + Either::Right(_self_param) => true, + } + } + // FIXME: why is this an option? It shouldn't be? pub fn name(self, db: &dyn HirDatabase) -> Option { let body = db.body(self.parent.into()); -- cgit v1.2.3