aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-17 16:00:43 +0000
committerGitHub <[email protected]>2021-03-17 16:00:43 +0000
commitedf11480ceae1ef77d7084604011c0ef6f692c72 (patch)
tree6d1da24b8e275d8e36a12a48e1cdc9de0f8e1ec4 /crates/ide_db
parentbaa19991688c6bdd99b63b8dc6f539be44da0350 (diff)
parent5734b347ddfff0d285d3eecf5735cac30271696c (diff)
Merge #8065
8065: Better handling of block doc comments r=Veykril a=Veykril Moves doc string processing to `Attrs::docs`, as we need the indent info from all comments before being able to know how much to strip Closes #7774 Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/call_info.rs6
-rw-r--r--crates/ide_db/src/call_info/tests.rs82
2 files changed, 44 insertions, 44 deletions
diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs
index d4016973c..7e26c3ccf 100644
--- a/crates/ide_db/src/call_info.rs
+++ b/crates/ide_db/src/call_info.rs
@@ -53,15 +53,15 @@ pub fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo>
53 53
54 match callable.kind() { 54 match callable.kind() {
55 hir::CallableKind::Function(func) => { 55 hir::CallableKind::Function(func) => {
56 res.doc = func.docs(db).map(|it| it.as_str().to_string()); 56 res.doc = func.docs(db).map(|it| it.into());
57 format_to!(res.signature, "fn {}", func.name(db)); 57 format_to!(res.signature, "fn {}", func.name(db));
58 } 58 }
59 hir::CallableKind::TupleStruct(strukt) => { 59 hir::CallableKind::TupleStruct(strukt) => {
60 res.doc = strukt.docs(db).map(|it| it.as_str().to_string()); 60 res.doc = strukt.docs(db).map(|it| it.into());
61 format_to!(res.signature, "struct {}", strukt.name(db)); 61 format_to!(res.signature, "struct {}", strukt.name(db));
62 } 62 }
63 hir::CallableKind::TupleEnumVariant(variant) => { 63 hir::CallableKind::TupleEnumVariant(variant) => {
64 res.doc = variant.docs(db).map(|it| it.as_str().to_string()); 64 res.doc = variant.docs(db).map(|it| it.into());
65 format_to!( 65 format_to!(
66 res.signature, 66 res.signature,
67 "enum {}::{}", 67 "enum {}::{}",
diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs
index 9f84c253c..75ab3eb6e 100644
--- a/crates/ide_db/src/call_info/tests.rs
+++ b/crates/ide_db/src/call_info/tests.rs
@@ -220,11 +220,11 @@ fn bar() {
220} 220}
221"#, 221"#,
222 expect![[r#" 222 expect![[r#"
223 test 223 test
224 ------ 224 ------
225 fn foo(j: u32) -> u32 225 fn foo(j: u32) -> u32
226 (<j: u32>) 226 (<j: u32>)
227 "#]], 227 "#]],
228 ); 228 );
229} 229}
230 230
@@ -249,19 +249,19 @@ pub fn do() {
249 add_one($0 249 add_one($0
250}"#, 250}"#,
251 expect![[r##" 251 expect![[r##"
252 Adds one to the number given. 252 Adds one to the number given.
253 253
254 # Examples 254 # Examples
255 255
256 ``` 256 ```
257 let five = 5; 257 let five = 5;
258 258
259 assert_eq!(6, my_crate::add_one(5)); 259 assert_eq!(6, my_crate::add_one(5));
260 ``` 260 ```
261 ------ 261 ------
262 fn add_one(x: i32) -> i32 262 fn add_one(x: i32) -> i32
263 (<x: i32>) 263 (<x: i32>)
264 "##]], 264 "##]],
265 ); 265 );
266} 266}
267 267
@@ -291,19 +291,19 @@ pub fn do_it() {
291} 291}
292"#, 292"#,
293 expect![[r##" 293 expect![[r##"
294 Adds one to the number given. 294 Adds one to the number given.
295 295
296 # Examples 296 # Examples
297 297
298 ``` 298 ```
299 let five = 5; 299 let five = 5;
300 300
301 assert_eq!(6, my_crate::add_one(5)); 301 assert_eq!(6, my_crate::add_one(5));
302 ``` 302 ```
303 ------ 303 ------
304 fn add_one(x: i32) -> i32 304 fn add_one(x: i32) -> i32
305 (<x: i32>) 305 (<x: i32>)
306 "##]], 306 "##]],
307 ); 307 );
308} 308}
309 309
@@ -335,13 +335,13 @@ pub fn foo(mut r: WriteHandler<()>) {
335} 335}
336"#, 336"#,
337 expect![[r#" 337 expect![[r#"
338 Method is called when writer finishes. 338 Method is called when writer finishes.
339 339
340 By default this method stops actor's `Context`. 340 By default this method stops actor's `Context`.
341 ------ 341 ------
342 fn finished(&mut self, ctx: &mut {unknown}) 342 fn finished(&mut self, ctx: &mut {unknown})
343 (<ctx: &mut {unknown}>) 343 (<ctx: &mut {unknown}>)
344 "#]], 344 "#]],
345 ); 345 );
346} 346}
347 347
@@ -389,11 +389,11 @@ fn main() {
389} 389}
390"#, 390"#,
391 expect![[r#" 391 expect![[r#"
392 A cool tuple struct 392 A cool tuple struct
393 ------ 393 ------
394 struct S(u32, i32) 394 struct S(u32, i32)
395 (u32, <i32>) 395 (u32, <i32>)
396 "#]], 396 "#]],
397 ); 397 );
398} 398}
399 399
@@ -431,11 +431,11 @@ fn main() {
431} 431}
432"#, 432"#,
433 expect![[r#" 433 expect![[r#"
434 A Variant 434 A Variant
435 ------ 435 ------
436 enum E::A(i32) 436 enum E::A(i32)
437 (<i32>) 437 (<i32>)
438 "#]], 438 "#]],
439 ); 439 );
440} 440}
441 441