aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-18 22:54:11 +0000
committerGitHub <[email protected]>2020-02-18 22:54:11 +0000
commit20252efb32bfdfe7392934a95a6c6d6b583d10e7 (patch)
treed7e650e4bbd80457bf4f7b3765ceae7745ec9aee /crates
parentf03404f6813e9651244aab87d22a137e5219ea0b (diff)
parentb4450b1043dd1a4baf0930efcaa897183b5720ef (diff)
Merge #3225
3225: Cleanup imports r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs40
1 files changed, 18 insertions, 22 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 1e5e0f420..8e793e479 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -1,7 +1,5 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use rustc_hash::FxHashMap;
4
5use hir::{HirFileId, InFile, Name, SourceAnalyzer, SourceBinder}; 3use hir::{HirFileId, InFile, Name, SourceAnalyzer, SourceBinder};
6use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
7use ra_ide_db::RootDatabase; 5use ra_ide_db::RootDatabase;
@@ -10,13 +8,11 @@ use ra_syntax::{
10 ast, AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxToken, TextRange, 8 ast, AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxToken, TextRange,
11 WalkEvent, T, 9 WalkEvent, T,
12}; 10};
11use rustc_hash::FxHashMap;
13 12
14use crate::{ 13use crate::{
15 expand::descend_into_macros_with_analyzer, 14 expand::descend_into_macros_with_analyzer,
16 references::{ 15 references::{classify_name, classify_name_ref, NameKind},
17 classify_name, classify_name_ref,
18 NameKind::{self, *},
19 },
20 FileId, 16 FileId,
21}; 17};
22 18
@@ -193,7 +189,7 @@ fn highlight_node(
193 let name_kind = classify_name_ref(sb, node.with_value(&name_ref)).map(|d| d.kind); 189 let name_kind = classify_name_ref(sb, node.with_value(&name_ref)).map(|d| d.kind);
194 match name_kind { 190 match name_kind {
195 Some(name_kind) => { 191 Some(name_kind) => {
196 if let Local(local) = &name_kind { 192 if let NameKind::Local(local) = &name_kind {
197 if let Some(name) = local.name(db) { 193 if let Some(name) = local.name(db) {
198 let shadow_count = 194 let shadow_count =
199 bindings_shadow_count.entry(name.clone()).or_default(); 195 bindings_shadow_count.entry(name.clone()).or_default();
@@ -211,7 +207,7 @@ fn highlight_node(
211 let name = node.value.as_node().cloned().and_then(ast::Name::cast).unwrap(); 207 let name = node.value.as_node().cloned().and_then(ast::Name::cast).unwrap();
212 let name_kind = classify_name(sb, node.with_value(&name)).map(|d| d.kind); 208 let name_kind = classify_name(sb, node.with_value(&name)).map(|d| d.kind);
213 209
214 if let Some(Local(local)) = &name_kind { 210 if let Some(NameKind::Local(local)) = &name_kind {
215 if let Some(name) = local.name(db) { 211 if let Some(name) = local.name(db) {
216 let shadow_count = bindings_shadow_count.entry(name.clone()).or_default(); 212 let shadow_count = bindings_shadow_count.entry(name.clone()).or_default();
217 *shadow_count += 1; 213 *shadow_count += 1;
@@ -316,20 +312,20 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
316 312
317fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str { 313fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
318 match name_kind { 314 match name_kind {
319 Macro(_) => tags::MACRO, 315 NameKind::Macro(_) => tags::MACRO,
320 StructField(_) => tags::FIELD, 316 NameKind::StructField(_) => tags::FIELD,
321 ModuleDef(hir::ModuleDef::Module(_)) => tags::MODULE, 317 NameKind::ModuleDef(hir::ModuleDef::Module(_)) => tags::MODULE,
322 ModuleDef(hir::ModuleDef::Function(_)) => tags::FUNCTION, 318 NameKind::ModuleDef(hir::ModuleDef::Function(_)) => tags::FUNCTION,
323 ModuleDef(hir::ModuleDef::Adt(_)) => tags::TYPE, 319 NameKind::ModuleDef(hir::ModuleDef::Adt(_)) => tags::TYPE,
324 ModuleDef(hir::ModuleDef::EnumVariant(_)) => tags::CONSTANT, 320 NameKind::ModuleDef(hir::ModuleDef::EnumVariant(_)) => tags::CONSTANT,
325 ModuleDef(hir::ModuleDef::Const(_)) => tags::CONSTANT, 321 NameKind::ModuleDef(hir::ModuleDef::Const(_)) => tags::CONSTANT,
326 ModuleDef(hir::ModuleDef::Static(_)) => tags::CONSTANT, 322 NameKind::ModuleDef(hir::ModuleDef::Static(_)) => tags::CONSTANT,
327 ModuleDef(hir::ModuleDef::Trait(_)) => tags::TYPE, 323 NameKind::ModuleDef(hir::ModuleDef::Trait(_)) => tags::TYPE,
328 ModuleDef(hir::ModuleDef::TypeAlias(_)) => tags::TYPE, 324 NameKind::ModuleDef(hir::ModuleDef::TypeAlias(_)) => tags::TYPE,
329 ModuleDef(hir::ModuleDef::BuiltinType(_)) => tags::TYPE_BUILTIN, 325 NameKind::ModuleDef(hir::ModuleDef::BuiltinType(_)) => tags::TYPE_BUILTIN,
330 SelfType(_) => tags::TYPE_SELF, 326 NameKind::SelfType(_) => tags::TYPE_SELF,
331 TypeParam(_) => tags::TYPE_PARAM, 327 NameKind::TypeParam(_) => tags::TYPE_PARAM,
332 Local(local) => { 328 NameKind::Local(local) => {
333 if local.is_mut(db) || local.ty(db).is_mutable_reference() { 329 if local.is_mut(db) || local.ty(db).is_mutable_reference() {
334 tags::VARIABLE_MUT 330 tags::VARIABLE_MUT
335 } else { 331 } else {