Skip to content

Commit 8281f8b

Browse files
authored
Merge pull request rust-lang#1 from gab-umich/mockup
Mockup merge in
2 parents bbd0fbd + 91af0ff commit 8281f8b

File tree

4 files changed

+355
-1
lines changed

4 files changed

+355
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#[derive(Clone, Debug)]
2+
struct Foo {
3+
pub x: i32,
4+
pub y: i32,
5+
}
6+
7+
fn foo<T>() -> T {
8+
unimplemented!();
9+
foo::<i32>();
10+
}
11+
12+
// comment
13+
fn main() {
14+
println!("Hello, {}!", 92);
15+
16+
let mut vec = Vec::new();
17+
if true {
18+
vec.push(Foo { x: 0, y: 1 });
19+
}
20+
unsafe { vec.set_len(0); }
21+
22+
let mut x = 42;
23+
let y = &mut x;
24+
let z = &y;
25+
26+
y;
27+
}

crates/ra_ide_api/src/snapshots/highlighting.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<style>
33
body { margin: 0; }
44
pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
5+
background { color: #3F3F3F; }
6+
7+
.sideBySide { display: flex; }
8+
.rustCode { flex-grow: 1; }
59

610
.comment { color: #7F9F7F; }
711
.string { color: #CC9393; }
@@ -19,6 +23,15 @@
1923
.keyword\.unsafe { color: #DFAF8F; }
2024
.keyword\.control { color: #F0DFAF; font-weight: bold; }
2125
</style>
26+
<div class="sideBySide">
27+
<div class="lifetime">
28+
<pre><code>
29+
|
30+
|
31+
|
32+
</code></pre>
33+
</div>
34+
<div class="rustCode">
2235
<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>
2336
<span class="keyword">struct</span> <span class="type">Foo</span> {
2437
<span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>,
@@ -45,4 +58,6 @@
4558
<span class="keyword">let</span> <span class="variable">z</span> = &<span class="variable.mut">y</span>;
4659

4760
<span class="variable.mut">y</span>;
48-
}</code></pre>
61+
}</code></pre>
62+
</div>
63+
</div>

html/example_mock.html

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
2+
<style>
3+
body { margin: 0; }
4+
pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
5+
6+
span[variable="vec"] {
7+
/* <!-- specification about this --> */
8+
}
9+
10+
.lifetime {
11+
border-right: thin solid orange;
12+
}
13+
.sideBySide {
14+
display: flex;
15+
}
16+
.rustCode {
17+
flex-grow: 1;
18+
}
19+
20+
.comment { color: #7F9F7F; }
21+
.string { color: #CC9393; }
22+
.function { color: #93E0E3; }
23+
.parameter { color: #94BFF3; }
24+
.builtin { color: #DD6718; }
25+
.text { color: #DCDCCC; }
26+
.attribute { color: #94BFF3; }
27+
.literal { color: #BFEBBF; }
28+
.macro { color: #94BFF3; }
29+
.variable { color: #DCDCCC; }
30+
.variable\.mut { color: #DCDCCC; text-decoration: underline; }
31+
32+
.keyword { color: #F0DFAF; }
33+
.keyword\.unsafe { color: #DFAF8F; }
34+
.keyword\.control { color: #F0DFAF; font-weight: bold; }
35+
</style>
36+
<div class="sideBySide">
37+
<span class="lifetime" variable="vec">
38+
<pre><code>
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
<span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">vec</span> <- <span class="text">Vec</span>::<span class="text">new</span>()
54+
|
55+
|
56+
|
57+
-> <span class="keyword">no longer used</span>
58+
59+
60+
61+
62+
63+
64+
65+
</code></pre>
66+
</span>
67+
<span class="lifetime" variable="x">
68+
<pre><code>
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
<span class="variable.mut" data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">x</span> <- <span class="literal">42</span>
90+
-> <span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span>
91+
92+
93+
94+
95+
</code></pre>
96+
</span>
97+
<span class="lifetime" variable="y">
98+
<pre><code>
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
<span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span> <- from <span class="variable.mut" data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">x</span>
121+
|
122+
|
123+
-> <span class="keyword">returned</span>
124+
125+
</code></pre>
126+
</span>
127+
<div class="rustCode">
128+
<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>
129+
<span class="keyword">struct</span> <span class="type">Foo</span> {
130+
<span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>,
131+
<span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>,
132+
}
133+
134+
<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type">T</span>&gt;() -&gt; <span class="type">T</span> {
135+
<span class="macro">unimplemented</span><span class="macro">!</span>();
136+
<span class="function">foo</span>::&lt;<span class="type">i32</span>&gt;();
137+
}
138+
139+
<span class="comment">// comment</span>
140+
<span class="keyword">fn</span> <span class="function">main</span>() {
141+
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="literal">92</span>);
142+
143+
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
144+
<span class="keyword.control">if</span> <span class="keyword">true</span> {
145+
<span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">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> });
146+
}
147+
<span class="keyword.unsafe">unsafe</span> { <span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); }
148+
149+
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut" data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">x</span> = <span class="literal">42</span>;
150+
<span class="keyword">let</span> <span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span> = &<span class="keyword">mut</span> <span class="variable.mut" data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">x</span>;
151+
<span class="keyword">let</span> <span class="variable" data-binding-hash="5534246180748221479" style="color: hsl(283,85%,80%);">z</span> = &<span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span>;
152+
153+
<span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span>;
154+
}</code></pre>
155+
</div>
156+
</div>

html/example_mock_simple.html

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
2+
<style>
3+
body { margin: 0; }
4+
pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
5+
6+
span[variable="vec"] {
7+
/* <!-- specification about this --> */
8+
}
9+
10+
.lifetime {
11+
/* border-right: thin solid orange; */
12+
}
13+
.sideBySide {
14+
display: flex;
15+
}
16+
.rustCode {
17+
flex-grow: 1;
18+
}
19+
20+
.comment { color: #7F9F7F; }
21+
.string { color: #CC9393; }
22+
.function { color: #93E0E3; }
23+
.parameter { color: #94BFF3; }
24+
.builtin { color: #DD6718; }
25+
.text { color: #DCDCCC; }
26+
.attribute { color: #94BFF3; }
27+
.literal { color: #BFEBBF; }
28+
.macro { color: #94BFF3; }
29+
.variable { color: #DCDCCC; }
30+
.variable\.mut { color: #DCDCCC; text-decoration: underline; }
31+
32+
.keyword { color: #F0DFAF; }
33+
.keyword\.unsafe { color: #DFAF8F; }
34+
.keyword\.control { color: #F0DFAF; font-weight: bold; }
35+
</style>
36+
<div class="sideBySide">
37+
<span class="lifetime" variable="vec">
38+
<pre><code>
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
<span data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">-vec
54+
|
55+
|
56+
|
57+
|</span>
58+
59+
60+
61+
62+
63+
64+
65+
</code></pre>
66+
</span>
67+
<span class="lifetime" variable="x">
68+
<pre><code>
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
<span data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">|
90+
|</span>
91+
92+
93+
94+
95+
</code></pre>
96+
</span>
97+
<span class="lifetime" variable="y">
98+
<pre><code>
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
<span data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">|
121+
|
122+
|
123+
|</span>
124+
125+
</code></pre>
126+
</span>
127+
<div class="rustCode">
128+
<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>
129+
<span class="keyword">struct</span> <span class="type">Foo</span> {
130+
<span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>,
131+
<span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>,
132+
}
133+
134+
<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type">T</span>&gt;() -&gt; <span class="type">T</span> {
135+
<span class="macro">unimplemented</span><span class="macro">!</span>();
136+
<span class="function">foo</span>::&lt;<span class="type">i32</span>&gt;();
137+
}
138+
139+
<span class="comment">// comment</span>
140+
<span class="keyword">fn</span> <span class="function">main</span>() {
141+
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="literal">92</span>);
142+
143+
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
144+
<span class="keyword.control">if</span> <span class="keyword">true</span> {
145+
<span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">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> });
146+
}
147+
<span class="keyword.unsafe">unsafe</span> { <span class="variable.mut" data-binding-hash="11110498128616369639" style="color: hsl(20,93%,82%);">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); }
148+
149+
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut" data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">x</span> = <span class="literal">42</span>;
150+
<span class="keyword">let</span> <span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span> = &<span class="keyword">mut</span> <span class="variable.mut" data-binding-hash="1627512989129656761" style="color: hsl(97,65%,64%);">x</span>;
151+
<span class="keyword">let</span> <span class="variable" data-binding-hash="5534246180748221479" style="color: hsl(283,85%,80%);">z</span> = &<span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span>;
152+
153+
<span class="variable.mut" data-binding-hash="3959636447297899133" style="color: hsl(303,50%,86%);">y</span>;
154+
}</code></pre>
155+
</div>
156+
</div>

0 commit comments

Comments
 (0)