From 5ebfcb9cb757ece936f631cf69136e1d38cb6afc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Feb 2020 16:36:14 +0100 Subject: Fix highlighting of const patterns --- crates/ra_ide/src/syntax_highlighting/tests.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src/syntax_highlighting') diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 2d90a072f..21c4dd818 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -50,12 +50,19 @@ fn main() { y; } -enum E { - V(X) +enum Option { + Some(T), + None, } - -impl E { - fn new() -> E {} +use Option::*; + +impl Option { + fn and(self, other: Option) -> Option<(T, U)> { + match other { + None => todo!(), + Nope => Nope, + } + } } "# .trim(), -- cgit v1.2.3 From 56ce34c6a7ec0b4426d4cb25e10512c7efaf6f06 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Feb 2020 16:49:46 +0100 Subject: Correctly flag 'lifetime definitions as definitions --- crates/ra_ide/src/syntax_highlighting/html.rs | 2 +- crates/ra_ide/src/syntax_highlighting/tags.rs | 8 ++++++-- crates/ra_ide/src/syntax_highlighting/tests.rs | 9 ++++----- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'crates/ra_ide/src/syntax_highlighting') diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 54678c278..e13766c9d 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -80,7 +80,7 @@ const STYLE: &str = " body { margin: 0; } pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } - +.lifetime { color: #DFAF8F; font-style: italic; } .comment { color: #7F9F7F; } .struct, .enum { color: #7CB8BB; } .enum_variant { color: #BDE0F3; } diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 9da80823c..8835a5de2 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -90,8 +90,12 @@ impl fmt::Display for HighlightTag { } impl HighlightModifier { - const ALL: &'static [HighlightModifier] = - &[HighlightModifier::Mutable, HighlightModifier::Unsafe, HighlightModifier::Control]; + const ALL: &'static [HighlightModifier] = &[ + HighlightModifier::Control, + HighlightModifier::Definition, + HighlightModifier::Mutable, + HighlightModifier::Unsafe, + ]; fn as_str(self) -> &'static str { match self { diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 21c4dd818..98c030791 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -17,9 +17,8 @@ struct Foo { pub y: i32, } -fn foo() -> T { - unimplemented!(); - foo::(); +fn foo<'a, T>() -> T { + foo::<'a, i32>() } macro_rules! def_fn { @@ -59,7 +58,7 @@ use Option::*; impl Option { fn and(self, other: Option) -> Option<(T, U)> { match other { - None => todo!(), + None => unimplemented!(), Nope => Nope, } } @@ -130,5 +129,5 @@ fn test_ranges() { .highlight_range(FileRange { file_id, range: TextRange::offset_len(82.into(), 1.into()) }) .unwrap(); - assert_eq!(&highlights[0].highlight.to_string(), "field"); + assert_eq!(&highlights[0].highlight.to_string(), "field.declaration"); } -- cgit v1.2.3