aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting/highlight.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-10 12:45:07 +0000
committerGitHub <[email protected]>2021-01-10 12:45:07 +0000
commit77362c71735a8b5ab4b5cd9f396fa657fbffe2cb (patch)
tree8c47a7929d15e6e4b36a854a662c3ea5ee7d972c /crates/ide/src/syntax_highlighting/highlight.rs
parentdcbb77cb6c75db9b300abe0fe6ed4668e2ef1193 (diff)
parent78fe6133c4908aefcf5c690e665abba9ef2389eb (diff)
Merge #6238
6238: Split punctuation semantic highlighting up into more tags r=matklad a=Veykril Open question would be the name of the delimiter modifiers. I chose them this was as I see them this way but from what I remember people tend to mix the names however they like. So maybe using `delimSquare`, `delimCurly`, `delimRound` would be better. That would also go well with `angle` becoming `delimAngle`? Closes #6152 Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide/src/syntax_highlighting/highlight.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 20eccf3c6..34bae49a8 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -12,7 +12,7 @@ use syntax::{
12 SyntaxNode, SyntaxToken, T, 12 SyntaxNode, SyntaxToken, T,
13}; 13};
14 14
15use crate::{Highlight, HlMod, HlTag, SymbolKind}; 15use crate::{syntax_highlighting::tags::HlPunct, Highlight, HlMod, HlTag, SymbolKind};
16 16
17pub(super) fn element( 17pub(super) fn element(
18 sema: &Semantics<RootDatabase>, 18 sema: &Semantics<RootDatabase>,
@@ -173,7 +173,7 @@ pub(super) fn element(
173 } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() { 173 } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() {
174 HlTag::Operator.into() 174 HlTag::Operator.into()
175 } else { 175 } else {
176 HlTag::Punctuation.into() 176 HlTag::Punctuation(HlPunct::Other).into()
177 } 177 }
178 } 178 }
179 T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { 179 T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
@@ -196,7 +196,18 @@ pub(super) fn element(
196 _ if element.parent().and_then(ast::RangePat::cast).is_some() => HlTag::Operator.into(), 196 _ if element.parent().and_then(ast::RangePat::cast).is_some() => HlTag::Operator.into(),
197 _ if element.parent().and_then(ast::RestPat::cast).is_some() => HlTag::Operator.into(), 197 _ if element.parent().and_then(ast::RestPat::cast).is_some() => HlTag::Operator.into(),
198 _ if element.parent().and_then(ast::Attr::cast).is_some() => HlTag::Attribute.into(), 198 _ if element.parent().and_then(ast::Attr::cast).is_some() => HlTag::Attribute.into(),
199 _ => HlTag::Punctuation.into(), 199 kind => HlTag::Punctuation(match kind {
200 T!['['] | T![']'] => HlPunct::Bracket,
201 T!['{'] | T!['}'] => HlPunct::Brace,
202 T!['('] | T![')'] => HlPunct::Parenthesis,
203 T![<] | T![>] => HlPunct::Angle,
204 T![,] => HlPunct::Comma,
205 T![:] => HlPunct::Colon,
206 T![;] => HlPunct::Semi,
207 T![.] => HlPunct::Dot,
208 _ => HlPunct::Other,
209 })
210 .into(),
200 }, 211 },
201 212
202 k if k.is_keyword() => { 213 k if k.is_keyword() => {