From cff0d6b6e667832a3822d84718dd0e1d44272cf7 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sat, 9 May 2020 10:24:57 -0700 Subject: Use Property instead of Member for fields --- crates/rust-analyzer/src/to_proto.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 4500d4982..33c2fd595 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -264,7 +264,7 @@ fn semantic_token_type_and_modifiers( HighlightTag::Trait => lsp_types::SemanticTokenType::INTERFACE, HighlightTag::BuiltinType => semantic_tokens::BUILTIN_TYPE, HighlightTag::SelfType => lsp_types::SemanticTokenType::TYPE, - HighlightTag::Field => lsp_types::SemanticTokenType::MEMBER, + HighlightTag::Field => lsp_types::SemanticTokenType::PROPERTY, HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, HighlightTag::Module => lsp_types::SemanticTokenType::NAMESPACE, HighlightTag::Constant => { -- cgit v1.2.3 From 3f1c73633eb3e5d8a2df3a72dc772087cfb18be4 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 10 May 2020 11:08:32 -0700 Subject: Color `in` as a control keyword --- crates/ra_ide/src/snapshots/highlighting.html | 4 ++++ crates/ra_ide/src/syntax_highlighting.rs | 3 ++- crates/ra_ide/src/syntax_highlighting/tests.rs | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 4c27aade4..c67df5c39 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -63,6 +63,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd STATIC_MUT = 1; } + for e in vec { + // Do nothing + } + let mut x = 42; let y = &mut x; let z = &y; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index d53a39f57..16123c5cb 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -408,7 +408,8 @@ fn highlight_element( | T![loop] | T![match] | T![return] - | T![while] => h | HighlightModifier::ControlFlow, + | T![while] + | T![in] => h | HighlightModifier::ControlFlow, T![unsafe] => h | HighlightModifier::Unsafe, _ => h, } diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 13894869c..7975755b2 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -47,6 +47,10 @@ fn main() { STATIC_MUT = 1; } + for e in vec { + // Do nothing + } + let mut x = 42; let y = &mut x; let z = &y; -- cgit v1.2.3 From 63b75a40c8c9e1f24fbd21c423f62f303281b77c Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 10 May 2020 11:26:19 -0700 Subject: Color `for` as a regular keyword when it's part of impl _ for _ --- crates/ra_ide/src/snapshots/highlighting.html | 10 ++++++++++ crates/ra_ide/src/syntax_highlighting.rs | 9 ++++++++- crates/ra_ide/src/syntax_highlighting/tests.rs | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index c67df5c39..635fe5cf9 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -33,6 +33,16 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd pub y: i32, } +trait Bar { + fn bar(&self) -> i32; +} + +impl Bar for Foo { + fn bar(&self) -> i32 { + self.x + } +} + static mut STATIC_MUT: i32 = 0; fn foo<'a, T>() -> T { diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 16123c5cb..be57eeb0a 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -403,13 +403,13 @@ fn highlight_element( T![break] | T![continue] | T![else] - | T![for] | T![if] | T![loop] | T![match] | T![return] | T![while] | T![in] => h | HighlightModifier::ControlFlow, + T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow, T![unsafe] => h | HighlightModifier::Unsafe, _ => h, } @@ -433,6 +433,13 @@ fn highlight_element( } } +fn is_child_of_impl(element: SyntaxElement) -> bool { + match element.parent() { + Some(e) => e.kind() == IMPL_DEF, + _ => false, + } +} + fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { match def { Definition::Macro(_) => HighlightTag::Macro, diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 7975755b2..eb43a23da 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -17,6 +17,16 @@ struct Foo { pub y: i32, } +trait Bar { + fn bar(&self) -> i32; +} + +impl Bar for Foo { + fn bar(&self) -> i32 { + self.x + } +} + static mut STATIC_MUT: i32 = 0; fn foo<'a, T>() -> T { -- cgit v1.2.3