aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorPascal Hertleif <[email protected]>2019-05-25 15:29:39 +0100
committerPascal Hertleif <[email protected]>2019-05-27 10:26:35 +0100
commit2b200f6e1a600e263f314efba5d8c3743095071b (patch)
tree96daa90ff3fd6b3ebd372784ca75c6c495dbc8bf /crates
parent43d5a4965308ec4b594725c0bd02cb046bdb730c (diff)
Disable broken struct field rainbowing
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api/src/lib.rs6
-rw-r--r--crates/ra_ide_api/src/snapshots/highlighting.html6
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs18
3 files changed, 7 insertions, 23 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 65a3b591a..452407e8e 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -463,8 +463,8 @@ impl Analysis {
463 } 463 }
464 464
465 /// Computes syntax highlighting for the given file. 465 /// Computes syntax highlighting for the given file.
466 pub fn highlight_as_html(&self, file_id: FileId) -> Cancelable<String> { 466 pub fn highlight_as_html(&self, file_id: FileId, rainbow: bool) -> Cancelable<String> {
467 self.with_db(|db| syntax_highlighting::highlight_as_html(db, file_id, true)) 467 self.with_db(|db| syntax_highlighting::highlight_as_html(db, file_id, rainbow))
468 } 468 }
469 469
470 /// Computes completions at the given position. 470 /// Computes completions at the given position.
@@ -472,7 +472,7 @@ impl Analysis {
472 self.with_db(|db| completion::completions(db, position).map(Into::into)) 472 self.with_db(|db| completion::completions(db, position).map(Into::into))
473 } 473 }
474 474
475 /// Computes assists (aks code actons aka intentions) for the given 475 /// Computes assists (aka code actions aka intentions) for the given
476 /// position. 476 /// position.
477 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> { 477 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> {
478 self.with_db(|db| assists::assists(db, frange)) 478 self.with_db(|db| assists::assists(db, frange))
diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide_api/src/snapshots/highlighting.html
index 4f4ed62a1..ebd187a35 100644
--- a/crates/ra_ide_api/src/snapshots/highlighting.html
+++ b/crates/ra_ide_api/src/snapshots/highlighting.html
@@ -19,8 +19,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4e
19</style> 19</style>
20<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> 20<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>
21<span class="keyword">struct</span> <span class="function">Foo</span> { 21<span class="keyword">struct</span> <span class="function">Foo</span> {
22 <span class="keyword">pub</span> <span class="variable" data-binding-hash="12067179602561426350" style="color: hsl(78,84%,47%);">x</span>: <span class="text">i32</span>, 22 <span class="keyword">pub</span> <span class="function">x</span>: <span class="text">i32</span>,
23 <span class="keyword">pub</span> <span class="variable" data-binding-hash="15562018766631452210" style="color: hsl(318,95%,78%);">y</span>: <span class="text">i32</span>, 23 <span class="keyword">pub</span> <span class="function">y</span>: <span class="text">i32</span>,
24} 24}
25 25
26<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type function">T</span>&gt;() -&gt; <span class="type">T</span> { 26<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type function">T</span>&gt;() -&gt; <span class="type">T</span> {
@@ -33,7 +33,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4e
33 33
34 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable" data-binding-hash="9636295041291189729" style="color: hsl(51,57%,74%);">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>(); 34 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable" data-binding-hash="9636295041291189729" style="color: hsl(51,57%,74%);">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
35 <span class="keyword.control">if</span> <span class="keyword">true</span> { 35 <span class="keyword.control">if</span> <span class="keyword">true</span> {
36 <span class="variable" data-binding-hash="8496027264380925433" style="color: hsl(18,48%,55%);">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field" data-binding-hash="17368948500121423555" style="color: hsl(49,97%,70%);">x</span>: <span class="literal">0</span>, <span class="field" data-binding-hash="13663097548341495469" style="color: hsl(26,51%,46%);">y</span>: <span class="literal">1</span> }); 36 <span class="variable" data-binding-hash="8496027264380925433" style="color: hsl(18,48%,55%);">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>: <span class="literal">0</span>, <span class="field">y</span>: <span class="literal">1</span> });
37 } 37 }
38 <span class="keyword.unsafe">unsafe</span> { <span class="variable" data-binding-hash="8496027264380925433" style="color: hsl(18,48%,55%);">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); } 38 <span class="keyword.unsafe">unsafe</span> { <span class="variable" data-binding-hash="8496027264380925433" style="color: hsl(18,48%,55%);">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); }
39}</code></pre> \ No newline at end of file 39}</code></pre> \ No newline at end of file
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 8981c85e6..e46686ab9 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -68,16 +68,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
68 match classify_name_ref(db, &analyzer, name_ref) { 68 match classify_name_ref(db, &analyzer, name_ref) {
69 Some(Method(_)) => "function", 69 Some(Method(_)) => "function",
70 Some(Macro(_)) => "macro", 70 Some(Macro(_)) => "macro",
71 Some(FieldAccess(field)) => { 71 Some(FieldAccess(_)) => "field",
72 let (hir_file_id, src) = field.source(db);
73 if let hir::FieldSource::Named(name) = src {
74 let text = name.syntax().text().to_smol_string();
75 let shadow_count = 0; // potentially even from different file
76 binding_hash = Some(calc_binding_hash(hir_file_id.original_file(db), &text, shadow_count));
77 }
78
79 "field"
80 },
81 Some(AssocItem(ImplItem::Method(_))) => "function", 72 Some(AssocItem(ImplItem::Method(_))) => "function",
82 Some(AssocItem(ImplItem::Const(_))) => "constant", 73 Some(AssocItem(ImplItem::Const(_))) => "constant",
83 Some(AssocItem(ImplItem::TypeAlias(_))) => "type", 74 Some(AssocItem(ImplItem::TypeAlias(_))) => "type",
@@ -119,13 +110,6 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
119 calc_binding_hash(file_id, &text, *shadow_count) 110 calc_binding_hash(file_id, &text, *shadow_count)
120 }); 111 });
121 "variable" 112 "variable"
122 } else if name.syntax().ancestors().any(|x| ast::NamedFieldDef::cast(x).is_some()) {
123 binding_hash = Some({
124 let text = name.syntax().text().to_smol_string();
125 let shadow_count = 0;
126 calc_binding_hash(file_id, &text, shadow_count)
127 });
128 "variable"
129 } else { 113 } else {
130 "function" 114 "function"
131 } 115 }