aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/syntax_highlighting.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-08-22 07:57:01 +0100
committerGitHub <[email protected]>2019-08-22 07:57:01 +0100
commit2d0931b9ba7aabdc634c799b32957cc6f057e875 (patch)
tree0e23834d5e32c411919b156ecfc7f923de9acd83 /crates/ra_ide_api/src/syntax_highlighting.rs
parent5fd9a5be0984faa138281e46dd4b73cfdad073b1 (diff)
parent1d87f85441fe8879be96952c7c39ff8b8d4bc880 (diff)
Merge #1714
1714: Fix syntax-highlighting for fields (`NAMED_FIELD_DEF`) r=matklad a=cynecx Before: `ralsp.function: "#ff0000"` ![image](https://user-images.githubusercontent.com/5961244/63473802-13920600-c477-11e9-93df-67c04fc67636.png) After: `ralsp.field: "#9cdcfe"` ![image](https://user-images.githubusercontent.com/5961244/63473976-a894ff00-c477-11e9-8731-269a4c942e05.png) Co-authored-by: cynecx <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/syntax_highlighting.rs')
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 878a94f06..448acffc8 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -158,21 +158,17 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
158 } else { 158 } else {
159 "variable" 159 "variable"
160 } 160 }
161 } else if name
162 .syntax()
163 .parent()
164 .map(|x| {
165 x.kind() == TYPE_PARAM
166 || x.kind() == STRUCT_DEF
167 || x.kind() == ENUM_DEF
168 || x.kind() == TRAIT_DEF
169 || x.kind() == TYPE_ALIAS_DEF
170 })
171 .unwrap_or(false)
172 {
173 "type"
174 } else { 161 } else {
175 "function" 162 name.syntax()
163 .parent()
164 .map(|x| match x.kind() {
165 TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => {
166 "type"
167 }
168 NAMED_FIELD_DEF => "field",
169 _ => "function",
170 })
171 .unwrap_or("function")
176 } 172 }
177 } else { 173 } else {
178 "text" 174 "text"