diff options
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/Cargo.toml | 23 | ||||
-rw-r--r-- | crates/ide/src/completion.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/runnables.rs | 26 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting.rs | 6 | ||||
-rw-r--r-- | crates/ide/test_data/highlighting.html | 4 |
5 files changed, 38 insertions, 23 deletions
diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index 700944430..336e9d2aa 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml | |||
@@ -1,6 +1,7 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "ide" | 2 | name = "ide" |
3 | version = "0.0.0" | 3 | version = "0.0.0" |
4 | description = "TBD" | ||
4 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
5 | authors = ["rust-analyzer developers"] | 6 | authors = ["rust-analyzer developers"] |
6 | edition = "2018" | 7 | edition = "2018" |
@@ -16,20 +17,20 @@ log = "0.4.8" | |||
16 | rustc-hash = "1.1.0" | 17 | rustc-hash = "1.1.0" |
17 | oorandom = "11.1.2" | 18 | oorandom = "11.1.2" |
18 | 19 | ||
19 | stdx = { path = "../stdx" } | 20 | stdx = { path = "../stdx", version = "0.0.0" } |
20 | syntax = { path = "../syntax" } | 21 | syntax = { path = "../syntax", version = "0.0.0" } |
21 | text_edit = { path = "../text_edit" } | 22 | text_edit = { path = "../text_edit", version = "0.0.0" } |
22 | base_db = { path = "../base_db" } | 23 | base_db = { path = "../base_db", version = "0.0.0" } |
23 | ide_db = { path = "../ide_db" } | 24 | ide_db = { path = "../ide_db", version = "0.0.0" } |
24 | cfg = { path = "../cfg" } | 25 | cfg = { path = "../cfg", version = "0.0.0" } |
25 | profile = { path = "../profile" } | 26 | profile = { path = "../profile", version = "0.0.0" } |
26 | test_utils = { path = "../test_utils" } | 27 | test_utils = { path = "../test_utils", version = "0.0.0" } |
27 | assists = { path = "../assists" } | 28 | assists = { path = "../assists", version = "0.0.0" } |
28 | ssr = { path = "../ssr" } | 29 | ssr = { path = "../ssr", version = "0.0.0" } |
29 | 30 | ||
30 | # ide should depend only on the top-level `hir` package. if you need | 31 | # ide should depend only on the top-level `hir` package. if you need |
31 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. | 32 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. |
32 | hir = { path = "../hir" } | 33 | hir = { path = "../hir", version = "0.0.0" } |
33 | 34 | ||
34 | [dev-dependencies] | 35 | [dev-dependencies] |
35 | expect-test = "0.1" | 36 | expect-test = "0.1" |
diff --git a/crates/ide/src/completion.rs b/crates/ide/src/completion.rs index 25e580d80..33bed6991 100644 --- a/crates/ide/src/completion.rs +++ b/crates/ide/src/completion.rs | |||
@@ -92,7 +92,7 @@ pub use crate::completion::{ | |||
92 | /// already present, it should give all possible variants for the identifier at | 92 | /// already present, it should give all possible variants for the identifier at |
93 | /// the caret. In other words, for | 93 | /// the caret. In other words, for |
94 | /// | 94 | /// |
95 | /// ```no-run | 95 | /// ```no_run |
96 | /// fn f() { | 96 | /// fn f() { |
97 | /// let foo = 92; | 97 | /// let foo = 92; |
98 | /// let _ = bar<|> | 98 | /// let _ = bar<|> |
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 4139f329e..dd59d9e70 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -160,7 +160,7 @@ fn runnable_fn( | |||
160 | RunnableKind::Test { test_id, attr } | 160 | RunnableKind::Test { test_id, attr } |
161 | } else if fn_def.has_atom_attr("bench") { | 161 | } else if fn_def.has_atom_attr("bench") { |
162 | RunnableKind::Bench { test_id } | 162 | RunnableKind::Bench { test_id } |
163 | } else if has_doc_test(&fn_def) { | 163 | } else if has_runnable_doc_test(&fn_def) { |
164 | RunnableKind::DocTest { test_id } | 164 | RunnableKind::DocTest { test_id } |
165 | } else { | 165 | } else { |
166 | return None; | 166 | return None; |
@@ -211,8 +211,13 @@ fn has_test_related_attribute(fn_def: &ast::Fn) -> bool { | |||
211 | .any(|attribute_text| attribute_text.contains("test")) | 211 | .any(|attribute_text| attribute_text.contains("test")) |
212 | } | 212 | } |
213 | 213 | ||
214 | fn has_doc_test(fn_def: &ast::Fn) -> bool { | 214 | fn has_runnable_doc_test(fn_def: &ast::Fn) -> bool { |
215 | fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```")) | 215 | fn_def.doc_comment_text().map_or(false, |comments_text| { |
216 | comments_text.contains("```") | ||
217 | && !comments_text.contains("```ignore") | ||
218 | && !comments_text.contains("```no_run") | ||
219 | && !comments_text.contains("```compile_fail") | ||
220 | }) | ||
216 | } | 221 | } |
217 | 222 | ||
218 | fn runnable_mod( | 223 | fn runnable_mod( |
@@ -417,6 +422,21 @@ fn main() {} | |||
417 | /// let x = 5; | 422 | /// let x = 5; |
418 | /// ``` | 423 | /// ``` |
419 | fn foo() {} | 424 | fn foo() {} |
425 | |||
426 | /// ```no_run | ||
427 | /// let z = 55; | ||
428 | /// ``` | ||
429 | fn should_have_no_runnable() {} | ||
430 | |||
431 | /// ```ignore | ||
432 | /// let z = 55; | ||
433 | /// ``` | ||
434 | fn should_have_no_runnable_2() {} | ||
435 | |||
436 | /// ```compile_fail | ||
437 | /// let z = 55; | ||
438 | /// ``` | ||
439 | fn should_have_no_runnable_3() {} | ||
420 | "#, | 440 | "#, |
421 | &[&BIN, &DOCTEST], | 441 | &[&BIN, &DOCTEST], |
422 | expect![[r#" | 442 | expect![[r#" |
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index aefc86949..25d6f7abd 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs | |||
@@ -748,12 +748,6 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
748 | if func.is_unsafe(db) { | 748 | if func.is_unsafe(db) { |
749 | h |= HighlightModifier::Unsafe; | 749 | h |= HighlightModifier::Unsafe; |
750 | } | 750 | } |
751 | if let Some(self_param) = func.self_param(db) { | ||
752 | match self_param.access(db) { | ||
753 | hir::Access::Exclusive => h |= HighlightModifier::Mutable, | ||
754 | hir::Access::Shared | hir::Access::Owned => (), | ||
755 | } | ||
756 | } | ||
757 | return h; | 751 | return h; |
758 | } | 752 | } |
759 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, | 753 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, |
diff --git a/crates/ide/test_data/highlighting.html b/crates/ide/test_data/highlighting.html index a6b79589b..d0df2e0ec 100644 --- a/crates/ide/test_data/highlighting.html +++ b/crates/ide/test_data/highlighting.html | |||
@@ -65,7 +65,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
65 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> | 65 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> |
66 | <span class="punctuation">}</span> | 66 | <span class="punctuation">}</span> |
67 | 67 | ||
68 | <span class="keyword">fn</span> <span class="function declaration mutable">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 68 | <span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
69 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> | 69 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> |
70 | <span class="punctuation">}</span> | 70 | <span class="punctuation">}</span> |
71 | 71 | ||
@@ -84,7 +84,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
84 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> | 84 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> |
85 | <span class="punctuation">}</span> | 85 | <span class="punctuation">}</span> |
86 | 86 | ||
87 | <span class="keyword">fn</span> <span class="function declaration mutable">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 87 | <span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
88 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> | 88 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> |
89 | <span class="punctuation">}</span> | 89 | <span class="punctuation">}</span> |
90 | 90 | ||