aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrayJack <[email protected]>2020-07-20 13:46:50 +0100
committerGrayJack <[email protected]>2020-07-20 13:46:50 +0100
commit73bab32aef073a101854099d6ef193737cf2a4fe (patch)
tree6636603fd06fcb68a3473746fc56261e36cc8362
parentc9c518e5e9761bf35d466c47c57c3a1358b56b3c (diff)
Highlight more cases of SyntaxKind when it is a punctuation
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs46
1 files changed, 32 insertions, 14 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 6ac44c2c0..606637d11 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -539,21 +539,39 @@ fn highlight_element(
539 _ => h, 539 _ => h,
540 } 540 }
541 } 541 }
542 T![*] => { 542 p if p.is_punct() => match p {
543 let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?; 543 T![::] | T![->] | T![=>] | T![&] => HighlightTag::Operator.into(),
544 544 T![@] => HighlightTag::Operator | HighlightModifier::ControlFlow,
545 let expr = prefix_expr.expr()?; 545 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
546 let ty = sema.type_of_expr(&expr)?; 546 Highlight::new(HighlightTag::Macro)
547 if !ty.is_raw_ptr() {
548 return None;
549 } else {
550 HighlightTag::Operator | HighlightModifier::Unsafe
551 } 547 }
552 } 548 T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
553 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { 549 let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?;
554 Highlight::new(HighlightTag::Macro) 550
555 } 551 let expr = prefix_expr.expr()?;
556 p if p.is_punct() => HighlightTag::Punctuation.into(), 552 let ty = sema.type_of_expr(&expr)?;
553 if ty.is_raw_ptr() {
554 HighlightTag::Operator | HighlightModifier::Unsafe
555 } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() {
556 HighlightTag::Operator.into()
557 } else {
558 HighlightTag::Punctuation.into()
559 }
560 }
561 T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
562 HighlightTag::NumericLiteral.into()
563 }
564 _ if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
565 HighlightTag::Operator.into()
566 }
567 _ if element.parent().and_then(ast::BinExpr::cast).is_some() => {
568 HighlightTag::Operator.into()
569 }
570 _ if element.parent().and_then(ast::RangeExpr::cast).is_some() => {
571 HighlightTag::Operator.into()
572 }
573 _ => HighlightTag::Punctuation.into(),
574 },
557 575
558 k if k.is_keyword() => { 576 k if k.is_keyword() => {
559 let h = Highlight::new(HighlightTag::Keyword); 577 let h = Highlight::new(HighlightTag::Keyword);