From 336b81abd7e8d05caf72dbeab228e4e03b2c53ee Mon Sep 17 00:00:00 2001 From: Bastian Kersting Date: Mon, 26 Apr 2021 09:22:36 +0200 Subject: Added mutable semantic token modifier for &mut self methods --- crates/ide/src/syntax_highlighting/highlight.rs | 9 +++++++-- crates/ide/src/syntax_highlighting/test_data/highlighting.html | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 8731699dc..f80b8d9cc 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -286,8 +286,13 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Function)); if let Some(item) = func.as_assoc_item(db) { h |= HlMod::Associated; - if func.self_param(db).is_none() { - h |= HlMod::Static + match func.self_param(db) { + Some(sp) => { + if let hir::Access::Exclusive = sp.access(db) { + h |= HlMod::Mutable; + } + }, + None => h |= HlMod::Static, } match item.container(db) { diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index 4319e8b50..df4192194 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -81,7 +81,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd f.baz(self) } - fn qux(&mut self) { + fn qux(&mut self) { self.x = 0; } @@ -100,7 +100,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd f.baz(self) } - fn qux(&mut self) { + fn qux(&mut self) { self.x = 0; } -- cgit v1.2.3 From 421cf9a1bdd42c146c466f517e23104cd6fe27d4 Mon Sep 17 00:00:00 2001 From: Bastian Kersting Date: Mon, 26 Apr 2021 11:37:28 +0200 Subject: Fixed formatting --- crates/ide/src/syntax_highlighting/highlight.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index f80b8d9cc..b586dcc17 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -291,7 +291,7 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { if let hir::Access::Exclusive = sp.access(db) { h |= HlMod::Mutable; } - }, + } None => h |= HlMod::Static, } -- cgit v1.2.3