aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/syntax_highlighting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/syntax_highlighting.rs')
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 1d290387c..33f3caceb 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -14,7 +14,7 @@ use ra_syntax::{
14 14
15use crate::{ 15use crate::{
16 db::RootDatabase, 16 db::RootDatabase,
17 name_ref_kind::{classify_name_ref, NameRefKind::*}, 17 references::{classify_name_ref, NameKind::*},
18 FileId, 18 FileId,
19}; 19};
20 20
@@ -101,12 +101,10 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
101 continue; 101 continue;
102 } 102 }
103 if let Some(name_ref) = node.as_node().cloned().and_then(ast::NameRef::cast) { 103 if let Some(name_ref) = node.as_node().cloned().and_then(ast::NameRef::cast) {
104 // FIXME: try to reuse the SourceAnalyzers 104 let name_kind = classify_name_ref(db, file_id, &name_ref).map(|d| d.kind);
105 let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); 105 match name_kind {
106 match classify_name_ref(db, &analyzer, &name_ref) {
107 Some(Method(_)) => "function",
108 Some(Macro(_)) => "macro", 106 Some(Macro(_)) => "macro",
109 Some(FieldAccess(_)) => "field", 107 Some(Field(_)) => "field",
110 Some(AssocItem(hir::AssocItem::Function(_))) => "function", 108 Some(AssocItem(hir::AssocItem::Function(_))) => "function",
111 Some(AssocItem(hir::AssocItem::Const(_))) => "constant", 109 Some(AssocItem(hir::AssocItem::Const(_))) => "constant",
112 Some(AssocItem(hir::AssocItem::TypeAlias(_))) => "type", 110 Some(AssocItem(hir::AssocItem::TypeAlias(_))) => "type",
@@ -120,7 +118,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
120 Some(Def(hir::ModuleDef::TypeAlias(_))) => "type", 118 Some(Def(hir::ModuleDef::TypeAlias(_))) => "type",
121 Some(Def(hir::ModuleDef::BuiltinType(_))) => "type", 119 Some(Def(hir::ModuleDef::BuiltinType(_))) => "type",
122 Some(SelfType(_)) => "type", 120 Some(SelfType(_)) => "type",
123 Some(Pat(ptr)) => { 121 Some(Pat((_, ptr))) => {
124 let pat = ptr.to_node(&root); 122 let pat = ptr.to_node(&root);
125 if let Some(name) = pat.name() { 123 if let Some(name) = pat.name() {
126 let text = name.text(); 124 let text = name.text();
@@ -130,6 +128,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
130 Some(calc_binding_hash(file_id, &text, *shadow_count)) 128 Some(calc_binding_hash(file_id, &text, *shadow_count))
131 } 129 }
132 130
131 let analyzer =
132 hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None);
133 if is_variable_mutable(db, &analyzer, ptr.to_node(&root)) { 133 if is_variable_mutable(db, &analyzer, ptr.to_node(&root)) {
134 "variable.mut" 134 "variable.mut"
135 } else { 135 } else {