From d057afb945b34cbefc1f0722f4dd0ff2758b760b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 14:10:31 +0100 Subject: Improve highlighting test --- crates/ra_ide/src/snapshots/highlighting.html | 4 +++- crates/ra_ide/src/snapshots/rainbow_highlighting.html | 1 + crates/ra_ide/src/syntax_highlighting.rs | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 2157139f6..748fd9558 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -5,6 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .comment { color: #7F9F7F; } .string { color: #CC9393; } +.field { color: #94BFF3; } .function { color: #93E0E3; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } @@ -39,7 +40,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let mut vec = Vec::new(); if true { - vec.push(Foo { x: 0, y: 1 }); + let x = 92; + vec.push(Foo { x, y: 1 }); } unsafe { vec.set_len(0); } diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index 871a52cf6..110556c09 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -5,6 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .comment { color: #7F9F7F; } .string { color: #CC9393; } +.field { color: #94BFF3; } .function { color: #93E0E3; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 15e75709c..63f5d3cb0 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -282,6 +282,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .comment { color: #7F9F7F; } .string { color: #CC9393; } +.field { color: #94BFF3; } .function { color: #93E0E3; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } @@ -327,7 +328,8 @@ fn main() { let mut vec = Vec::new(); if true { - vec.push(Foo { x: 0, y: 1 }); + let x = 92; + vec.push(Foo { x, y: 1 }); } unsafe { vec.set_len(0); } -- cgit v1.2.3 From 77af7b087fd95140c28b30bf7127d7d83fb0dcc6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 14:11:49 +0100 Subject: Fix highlighting for field init shorthand --- crates/ra_ide/src/snapshots/highlighting.html | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 748fd9558..a097cf8e8 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -41,7 +41,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let mut vec = Vec::new(); if true { let x = 92; - vec.push(Foo { x, y: 1 }); + vec.push(Foo { x, y: 1 }); } unsafe { vec.set_len(0); } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 63f5d3cb0..657c7b21a 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -102,11 +102,10 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec tags::LITERAL_COMMENT, STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => tags::LITERAL_STRING, ATTR => tags::LITERAL_ATTRIBUTE, + // Special-case field init shorthand + NAME_REF if node.parent().and_then(ast::RecordField::cast).is_some() => tags::FIELD, + NAME_REF if node.ancestors().any(|it| it.kind() == ATTR) => continue, NAME_REF => { - if node.ancestors().any(|it| it.kind() == ATTR) { - continue; - } - let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap(); let name_kind = classify_name_ref(db, InFile::new(file_id.into(), &name_ref)).map(|d| d.kind); -- cgit v1.2.3