mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Highlight more cases of SyntaxKind when it is a punctuation
This commit is contained in:
parent
c9c518e5e9
commit
73bab32aef
1 changed files with 32 additions and 14 deletions
|
@ -539,21 +539,39 @@ fn highlight_element(
|
||||||
_ => h,
|
_ => h,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
T![*] => {
|
p if p.is_punct() => match p {
|
||||||
let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?;
|
T![::] | T![->] | T![=>] | T![&] => HighlightTag::Operator.into(),
|
||||||
|
T![@] => HighlightTag::Operator | HighlightModifier::ControlFlow,
|
||||||
let expr = prefix_expr.expr()?;
|
T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
|
||||||
let ty = sema.type_of_expr(&expr)?;
|
Highlight::new(HighlightTag::Macro)
|
||||||
if !ty.is_raw_ptr() {
|
|
||||||
return None;
|
|
||||||
} else {
|
|
||||||
HighlightTag::Operator | HighlightModifier::Unsafe
|
|
||||||
}
|
}
|
||||||
}
|
T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
||||||
T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
|
let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?;
|
||||||
Highlight::new(HighlightTag::Macro)
|
|
||||||
}
|
let expr = prefix_expr.expr()?;
|
||||||
p if p.is_punct() => HighlightTag::Punctuation.into(),
|
let ty = sema.type_of_expr(&expr)?;
|
||||||
|
if ty.is_raw_ptr() {
|
||||||
|
HighlightTag::Operator | HighlightModifier::Unsafe
|
||||||
|
} else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() {
|
||||||
|
HighlightTag::Operator.into()
|
||||||
|
} else {
|
||||||
|
HighlightTag::Punctuation.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
||||||
|
HighlightTag::NumericLiteral.into()
|
||||||
|
}
|
||||||
|
_ if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
||||||
|
HighlightTag::Operator.into()
|
||||||
|
}
|
||||||
|
_ if element.parent().and_then(ast::BinExpr::cast).is_some() => {
|
||||||
|
HighlightTag::Operator.into()
|
||||||
|
}
|
||||||
|
_ if element.parent().and_then(ast::RangeExpr::cast).is_some() => {
|
||||||
|
HighlightTag::Operator.into()
|
||||||
|
}
|
||||||
|
_ => HighlightTag::Punctuation.into(),
|
||||||
|
},
|
||||||
|
|
||||||
k if k.is_keyword() => {
|
k if k.is_keyword() => {
|
||||||
let h = Highlight::new(HighlightTag::Keyword);
|
let h = Highlight::new(HighlightTag::Keyword);
|
||||||
|
|
Loading…
Reference in a new issue