aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmer Ben-Amram <[email protected]>2019-12-13 17:00:55 +0000
committerOmer Ben-Amram <[email protected]>2019-12-13 17:03:48 +0000
commit30672c420ee19faa1acc15ecc84ae8d17c309e95 (patch)
tree8e55559457b8c27fb4e33425a92644aa805209bf
parentebc95af2b5b91239fc1d8a5fc8344ded6f6ef3e4 (diff)
scopes resolution is more granular
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 7ecb1a027..cd9d8b058 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -108,14 +108,17 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
108 match name_kind { 108 match name_kind {
109 Some(name_kind) => highlight_name(db, name_kind), 109 Some(name_kind) => highlight_name(db, name_kind),
110 None => name.syntax().parent().map_or("function", |x| match x.kind() { 110 None => name.syntax().parent().map_or("function", |x| match x.kind() {
111 TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => "type", 111 STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => "type",
112 TYPE_PARAM => "type.param",
112 RECORD_FIELD_DEF => "field", 113 RECORD_FIELD_DEF => "field",
113 _ => "function", 114 _ => "function",
114 }), 115 }),
115 } 116 }
116 } 117 }
117 INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", 118 INT_NUMBER | FLOAT_NUMBER => "literal.numeric",
118 LIFETIME => "parameter", 119 BYTE => "literal.byte",
120 CHAR => "literal.char",
121 LIFETIME => "lifetime",
119 T![unsafe] => "keyword.unsafe", 122 T![unsafe] => "keyword.unsafe",
120 k if is_control_keyword(k) => "keyword.control", 123 k if is_control_keyword(k) => "keyword.control",
121 k if k.is_keyword() => "keyword", 124 k if k.is_keyword() => "keyword",
@@ -215,17 +218,18 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
215 Field(_) => "field", 218 Field(_) => "field",
216 AssocItem(hir::AssocItem::Function(_)) => "function", 219 AssocItem(hir::AssocItem::Function(_)) => "function",
217 AssocItem(hir::AssocItem::Const(_)) => "constant", 220 AssocItem(hir::AssocItem::Const(_)) => "constant",
218 AssocItem(hir::AssocItem::TypeAlias(_)) => "type", 221 AssocItem(hir::AssocItem::TypeAlias(_)) => "type.alias",
219 Def(hir::ModuleDef::Module(_)) => "module", 222 Def(hir::ModuleDef::Module(_)) => "module",
220 Def(hir::ModuleDef::Function(_)) => "function", 223 Def(hir::ModuleDef::Function(_)) => "function",
221 Def(hir::ModuleDef::Adt(_)) => "type", 224 Def(hir::ModuleDef::Adt(_)) => "type",
222 Def(hir::ModuleDef::EnumVariant(_)) => "constant", 225 Def(hir::ModuleDef::EnumVariant(_)) => "constant",
223 Def(hir::ModuleDef::Const(_)) => "constant", 226 Def(hir::ModuleDef::Const(_)) => "constant",
224 Def(hir::ModuleDef::Static(_)) => "constant", 227 Def(hir::ModuleDef::Static(_)) => "constant",
225 Def(hir::ModuleDef::Trait(_)) => "type", 228 Def(hir::ModuleDef::Trait(_)) => "type.trait",
226 Def(hir::ModuleDef::TypeAlias(_)) => "type", 229 Def(hir::ModuleDef::TypeAlias(_)) => "type.alias",
227 Def(hir::ModuleDef::BuiltinType(_)) => "type", 230 Def(hir::ModuleDef::BuiltinType(_)) => "type.builtin",
228 SelfType(_) | TypeParam(_) => "type", 231 SelfType(_) => "type.self",
232 TypeParam(_) => "type.param",
229 Local(local) => { 233 Local(local) => {
230 if local.is_mut(db) { 234 if local.is_mut(db) {
231 "variable.mut" 235 "variable.mut"