aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-21 14:58:42 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-21 14:58:42 +0100
commit51e82fe6d2edd7ca66944540bdbbc8cb39e4b5d2 (patch)
tree4ba523d010901e2c68d2901217074494d01c22d1 /crates/ra_ide_api
parentc6a5d871d7a670473a78e03852bb158f3b6d5be3 (diff)
parentb08362f6d2973336764c52ebc7cc5e9f34f0d80a (diff)
Merge #1299
1299: Use ThemeColor and add support for light themes r=matklad a=lnicola Part of #1294. - switch to `ThemeColor` - add light and high contrast theme definitions - highlight control flow keywords and `unsafe` Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index a03b13839..2158291dc 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -1,6 +1,6 @@
1use rustc_hash::FxHashSet; 1use rustc_hash::FxHashSet;
2 2
3use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind::*, SyntaxElement, T}; 3use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind, SyntaxKind::*, SyntaxElement, T};
4use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
5 5
6use crate::{FileId, db::RootDatabase}; 6use crate::{FileId, db::RootDatabase};
@@ -11,6 +11,21 @@ pub struct HighlightedRange {
11 pub tag: &'static str, 11 pub tag: &'static str,
12} 12}
13 13
14fn is_control_keyword(kind: SyntaxKind) -> bool {
15 match kind {
16 T![for]
17 | T![loop]
18 | T![while]
19 | T![continue]
20 | T![break]
21 | T![if]
22 | T![else]
23 | T![match]
24 | T![return] => true,
25 _ => false,
26 }
27}
28
14pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { 29pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> {
15 let source_file = db.parse(file_id); 30 let source_file = db.parse(file_id);
16 31
@@ -29,6 +44,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
29 NAME => "function", 44 NAME => "function",
30 INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", 45 INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal",
31 LIFETIME => "parameter", 46 LIFETIME => "parameter",
47 T![unsafe] => "keyword.unsafe",
48 k if is_control_keyword(k) => "keyword.control",
32 k if k.is_keyword() => "keyword", 49 k if k.is_keyword() => "keyword",
33 _ => { 50 _ => {
34 if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { 51 if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) {