diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting.rs')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index c0f7c1c9f..b94b6a022 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -7,7 +7,7 @@ mod tests; | |||
7 | 7 | ||
8 | use hir::{Name, Semantics}; | 8 | use hir::{Name, Semantics}; |
9 | use ra_ide_db::{ | 9 | use ra_ide_db::{ |
10 | defs::{classify_name, NameDefinition}, | 10 | defs::{classify_name, NameClass, NameDefinition}, |
11 | RootDatabase, | 11 | RootDatabase, |
12 | }; | 12 | }; |
13 | use ra_prof::profile; | 13 | use ra_prof::profile; |
@@ -169,7 +169,7 @@ fn highlight_element( | |||
169 | let name = element.into_node().and_then(ast::Name::cast).unwrap(); | 169 | let name = element.into_node().and_then(ast::Name::cast).unwrap(); |
170 | let name_kind = classify_name(sema, &name); | 170 | let name_kind = classify_name(sema, &name); |
171 | 171 | ||
172 | if let Some(NameDefinition::Local(local)) = &name_kind { | 172 | if let Some(NameClass::NameDefinition(NameDefinition::Local(local))) = &name_kind { |
173 | if let Some(name) = local.name(db) { | 173 | if let Some(name) = local.name(db) { |
174 | let shadow_count = bindings_shadow_count.entry(name.clone()).or_default(); | 174 | let shadow_count = bindings_shadow_count.entry(name.clone()).or_default(); |
175 | *shadow_count += 1; | 175 | *shadow_count += 1; |
@@ -177,11 +177,13 @@ fn highlight_element( | |||
177 | } | 177 | } |
178 | }; | 178 | }; |
179 | 179 | ||
180 | let h = match name_kind { | 180 | match name_kind { |
181 | Some(name_kind) => highlight_name(db, name_kind), | 181 | Some(NameClass::NameDefinition(def)) => { |
182 | None => highlight_name_by_syntax(name), | 182 | highlight_name(db, def) | HighlightModifier::Definition |
183 | }; | 183 | } |
184 | h | HighlightModifier::Definition | 184 | Some(NameClass::ConstReference(def)) => highlight_name(db, def), |
185 | None => highlight_name_by_syntax(name) | HighlightModifier::Definition, | ||
186 | } | ||
185 | } | 187 | } |
186 | 188 | ||
187 | // Highlight references like the definitions they resolve to | 189 | // Highlight references like the definitions they resolve to |
@@ -212,8 +214,13 @@ fn highlight_element( | |||
212 | INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), | 214 | INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), |
213 | BYTE => HighlightTag::ByteLiteral.into(), | 215 | BYTE => HighlightTag::ByteLiteral.into(), |
214 | CHAR => HighlightTag::CharLiteral.into(), | 216 | CHAR => HighlightTag::CharLiteral.into(), |
215 | // FIXME: set Declaration for decls | 217 | LIFETIME => { |
216 | LIFETIME => HighlightTag::Lifetime.into(), | 218 | let h = Highlight::new(HighlightTag::Lifetime); |
219 | dbg!(match element.parent().map(|it| it.kind()) { | ||
220 | Some(LIFETIME_PARAM) | Some(LABEL) => h | HighlightModifier::Definition, | ||
221 | _ => h, | ||
222 | }) | ||
223 | } | ||
217 | 224 | ||
218 | k if k.is_keyword() => { | 225 | k if k.is_keyword() => { |
219 | let h = Highlight::new(HighlightTag::Keyword); | 226 | let h = Highlight::new(HighlightTag::Keyword); |