diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-22 07:57:01 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-22 07:57:01 +0100 |
commit | 2d0931b9ba7aabdc634c799b32957cc6f057e875 (patch) | |
tree | 0e23834d5e32c411919b156ecfc7f923de9acd83 /crates/ra_ide_api/src | |
parent | 5fd9a5be0984faa138281e46dd4b73cfdad073b1 (diff) | |
parent | 1d87f85441fe8879be96952c7c39ff8b8d4bc880 (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')
-rw-r--r-- | crates/ra_ide_api/src/snapshots/highlighting.html | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 24 |
2 files changed, 12 insertions, 16 deletions
diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide_api/src/snapshots/highlighting.html index af7b4a0d0..b39c4d371 100644 --- a/crates/ra_ide_api/src/snapshots/highlighting.html +++ b/crates/ra_ide_api/src/snapshots/highlighting.html | |||
@@ -21,8 +21,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
21 | </style> | 21 | </style> |
22 | <pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span> | 22 | <pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span> |
23 | <span class="keyword">struct</span> <span class="type">Foo</span> { | 23 | <span class="keyword">struct</span> <span class="type">Foo</span> { |
24 | <span class="keyword">pub</span> <span class="function">x</span>: <span class="type">i32</span>, | 24 | <span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>, |
25 | <span class="keyword">pub</span> <span class="function">y</span>: <span class="type">i32</span>, | 25 | <span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>, |
26 | } | 26 | } |
27 | 27 | ||
28 | <span class="keyword">fn</span> <span class="function">foo</span><<span class="type">T</span>>() -> <span class="type">T</span> { | 28 | <span class="keyword">fn</span> <span class="function">foo</span><<span class="type">T</span>>() -> <span class="type">T</span> { |
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" |