Assign mutable semantic token modifier to assignment operators

This commit is contained in:
Lukas Wirth 2021-07-13 18:32:02 +02:00
parent b3337c26db
commit d1256a3709
3 changed files with 10 additions and 7 deletions

View file

@ -55,7 +55,6 @@ pub(super) fn element(
name_ref,
)
}
// Simple token-based highlighting
COMMENT => {
let comment = element.into_token().and_then(ast::Comment::cast)?;
@ -132,16 +131,18 @@ pub(super) fn element(
.into()
}
_ if parent_matches::<ast::PrefixExpr>(&element) => HlOperator::Other.into(),
T![+] | T![-] | T![*] | T![/] | T![+=] | T![-=] | T![*=] | T![/=]
if parent_matches::<ast::BinExpr>(&element) =>
{
T![+] | T![-] | T![*] | T![/] if parent_matches::<ast::BinExpr>(&element) => {
HlOperator::Arithmetic.into()
}
T![|] | T![&] | T![!] | T![^] | T![|=] | T![&=] | T![^=]
if parent_matches::<ast::BinExpr>(&element) =>
{
T![+=] | T![-=] | T![*=] | T![/=] if parent_matches::<ast::BinExpr>(&element) => {
Highlight::from(HlOperator::Arithmetic) | HlMod::Mutable
}
T![|] | T![&] | T![!] | T![^] if parent_matches::<ast::BinExpr>(&element) => {
HlOperator::Bitwise.into()
}
T![|=] | T![&=] | T![^=] if parent_matches::<ast::BinExpr>(&element) => {
Highlight::from(HlOperator::Bitwise) | HlMod::Mutable
}
T![&&] | T![||] if parent_matches::<ast::BinExpr>(&element) => {
HlOperator::Logical.into()
}