aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 448645bdc..b4dcdba39 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -45,6 +45,7 @@ pub(crate) fn highlight(
45 file_id: FileId, 45 file_id: FileId,
46 range_to_highlight: Option<TextRange>, 46 range_to_highlight: Option<TextRange>,
47 syntactic_name_ref_highlighting: bool, 47 syntactic_name_ref_highlighting: bool,
48 default_tag: Option<HighlightTag>,
48) -> Vec<HighlightedRange> { 49) -> Vec<HighlightedRange> {
49 let _p = profile("highlight"); 50 let _p = profile("highlight");
50 let sema = Semantics::new(db); 51 let sema = Semantics::new(db);
@@ -107,6 +108,7 @@ pub(crate) fn highlight(
107 &mut bindings_shadow_count, 108 &mut bindings_shadow_count,
108 syntactic_name_ref_highlighting, 109 syntactic_name_ref_highlighting,
109 name.syntax().clone().into(), 110 name.syntax().clone().into(),
111 default_tag,
110 ) { 112 ) {
111 stack.add(HighlightedRange { 113 stack.add(HighlightedRange {
112 range: name.syntax().text_range(), 114 range: name.syntax().text_range(),
@@ -206,6 +208,7 @@ pub(crate) fn highlight(
206 &mut bindings_shadow_count, 208 &mut bindings_shadow_count,
207 syntactic_name_ref_highlighting, 209 syntactic_name_ref_highlighting,
208 element_to_highlight.clone(), 210 element_to_highlight.clone(),
211 default_tag,
209 ) { 212 ) {
210 stack.add(HighlightedRange { range, highlight, binding_hash }); 213 stack.add(HighlightedRange { range, highlight, binding_hash });
211 if let Some(string) = 214 if let Some(string) =
@@ -430,13 +433,14 @@ fn highlight_element(
430 bindings_shadow_count: &mut FxHashMap<Name, u32>, 433 bindings_shadow_count: &mut FxHashMap<Name, u32>,
431 syntactic_name_ref_highlighting: bool, 434 syntactic_name_ref_highlighting: bool,
432 element: SyntaxElement, 435 element: SyntaxElement,
436 default_tag: Option<HighlightTag>,
433) -> Option<(Highlight, Option<u64>)> { 437) -> Option<(Highlight, Option<u64>)> {
434 let db = sema.db; 438 let db = sema.db;
435 let mut binding_hash = None; 439 let mut binding_hash = None;
436 let highlight: Highlight = match element.kind() { 440 let highlight: Highlight = match element.kind() {
437 FN_DEF => { 441 FN_DEF => {
438 bindings_shadow_count.clear(); 442 bindings_shadow_count.clear();
439 return None; 443 default_tag?.into()
440 } 444 }
441 445
442 // Highlight definitions depending on the "type" of the definition. 446 // Highlight definitions depending on the "type" of the definition.
@@ -515,12 +519,12 @@ fn highlight_element(
515 let expr = prefix_expr.expr()?; 519 let expr = prefix_expr.expr()?;
516 let ty = sema.type_of_expr(&expr)?; 520 let ty = sema.type_of_expr(&expr)?;
517 if !ty.is_raw_ptr() { 521 if !ty.is_raw_ptr() {
518 return None; 522 default_tag?.into()
523 } else {
524 let mut h = Highlight::new(HighlightTag::Operator);
525 h |= HighlightModifier::Unsafe;
526 h
519 } 527 }
520
521 let mut h = Highlight::new(HighlightTag::Operator);
522 h |= HighlightModifier::Unsafe;
523 h
524 } 528 }
525 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { 529 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
526 Highlight::new(HighlightTag::Macro) 530 Highlight::new(HighlightTag::Macro)
@@ -546,7 +550,7 @@ fn highlight_element(
546 } 550 }
547 } 551 }
548 552
549 _ => return None, 553 _ => default_tag?.into(),
550 }; 554 };
551 555
552 return Some((highlight, binding_hash)); 556 return Some((highlight, binding_hash));