Use dedicated semantic highlight tag for parameters

closes #5106
This commit is contained in:
Aleksey Kladov 2020-07-11 14:50:00 +02:00
parent 87ddcba05f
commit e1d6b7f7c4
11 changed files with 44 additions and 20 deletions

View file

@ -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<Name> {
let body = db.body(self.parent.into());