diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 33 | ||||
-rw-r--r-- | crates/ide/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/hover.rs | 148 | ||||
-rw-r--r-- | crates/ide/src/references.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/runnables.rs | 76 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 7 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 9 |
7 files changed, 196 insertions, 81 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index ac6346b2b..9b9295955 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -35,8 +35,6 @@ pub enum SymbolKind { | |||
35 | TypeAlias, | 35 | TypeAlias, |
36 | Trait, | 36 | Trait, |
37 | Macro, | 37 | Macro, |
38 | // Do we actually need this? | ||
39 | DocTest, | ||
40 | } | 38 | } |
41 | 39 | ||
42 | /// `NavigationTarget` represents and element in the editor's UI which you can | 40 | /// `NavigationTarget` represents and element in the editor's UI which you can |
@@ -64,7 +62,7 @@ pub struct NavigationTarget { | |||
64 | /// Clients should place the cursor on this range when navigating to this target. | 62 | /// Clients should place the cursor on this range when navigating to this target. |
65 | pub focus_range: Option<TextRange>, | 63 | pub focus_range: Option<TextRange>, |
66 | pub name: SmolStr, | 64 | pub name: SmolStr, |
67 | pub kind: SymbolKind, | 65 | pub kind: Option<SymbolKind>, |
68 | pub container_name: Option<SmolStr>, | 66 | pub container_name: Option<SmolStr>, |
69 | pub description: Option<String>, | 67 | pub description: Option<String>, |
70 | pub docs: Option<Documentation>, | 68 | pub docs: Option<Documentation>, |
@@ -110,8 +108,13 @@ impl NavigationTarget { | |||
110 | 108 | ||
111 | #[cfg(test)] | 109 | #[cfg(test)] |
112 | pub(crate) fn debug_render(&self) -> String { | 110 | pub(crate) fn debug_render(&self) -> String { |
113 | let mut buf = | 111 | let mut buf = format!( |
114 | format!("{} {:?} {:?} {:?}", self.name, self.kind, self.file_id, self.full_range); | 112 | "{} {:?} {:?} {:?}", |
113 | self.name, | ||
114 | self.kind.unwrap(), | ||
115 | self.file_id, | ||
116 | self.full_range | ||
117 | ); | ||
115 | if let Some(focus_range) = self.focus_range { | 118 | if let Some(focus_range) = self.focus_range { |
116 | buf.push_str(&format!(" {:?}", focus_range)) | 119 | buf.push_str(&format!(" {:?}", focus_range)) |
117 | } | 120 | } |
@@ -146,7 +149,7 @@ impl NavigationTarget { | |||
146 | NavigationTarget { | 149 | NavigationTarget { |
147 | file_id, | 150 | file_id, |
148 | name, | 151 | name, |
149 | kind, | 152 | kind: Some(kind), |
150 | full_range, | 153 | full_range, |
151 | focus_range, | 154 | focus_range, |
152 | container_name: None, | 155 | container_name: None, |
@@ -161,7 +164,7 @@ impl ToNav for FileSymbol { | |||
161 | NavigationTarget { | 164 | NavigationTarget { |
162 | file_id: self.file_id, | 165 | file_id: self.file_id, |
163 | name: self.name.clone(), | 166 | name: self.name.clone(), |
164 | kind: match self.kind { | 167 | kind: Some(match self.kind { |
165 | FileSymbolKind::Function => SymbolKind::Function, | 168 | FileSymbolKind::Function => SymbolKind::Function, |
166 | FileSymbolKind::Struct => SymbolKind::Struct, | 169 | FileSymbolKind::Struct => SymbolKind::Struct, |
167 | FileSymbolKind::Enum => SymbolKind::Enum, | 170 | FileSymbolKind::Enum => SymbolKind::Enum, |
@@ -171,7 +174,7 @@ impl ToNav for FileSymbol { | |||
171 | FileSymbolKind::Const => SymbolKind::Const, | 174 | FileSymbolKind::Const => SymbolKind::Const, |
172 | FileSymbolKind::Static => SymbolKind::Static, | 175 | FileSymbolKind::Static => SymbolKind::Static, |
173 | FileSymbolKind::Macro => SymbolKind::Macro, | 176 | FileSymbolKind::Macro => SymbolKind::Macro, |
174 | }, | 177 | }), |
175 | full_range: self.range, | 178 | full_range: self.range, |
176 | focus_range: self.name_range, | 179 | focus_range: self.name_range, |
177 | container_name: self.container_name.clone(), | 180 | container_name: self.container_name.clone(), |
@@ -386,7 +389,7 @@ impl ToNav for hir::Local { | |||
386 | NavigationTarget { | 389 | NavigationTarget { |
387 | file_id: full_range.file_id, | 390 | file_id: full_range.file_id, |
388 | name, | 391 | name, |
389 | kind: SymbolKind::Local, | 392 | kind: Some(SymbolKind::Local), |
390 | full_range: full_range.range, | 393 | full_range: full_range.range, |
391 | focus_range: None, | 394 | focus_range: None, |
392 | container_name: None, | 395 | container_name: None, |
@@ -410,7 +413,7 @@ impl ToNav for hir::TypeParam { | |||
410 | NavigationTarget { | 413 | NavigationTarget { |
411 | file_id: src.file_id.original_file(db), | 414 | file_id: src.file_id.original_file(db), |
412 | name: self.name(db).to_string().into(), | 415 | name: self.name(db).to_string().into(), |
413 | kind: SymbolKind::TypeParam, | 416 | kind: Some(SymbolKind::TypeParam), |
414 | full_range, | 417 | full_range, |
415 | focus_range, | 418 | focus_range, |
416 | container_name: None, | 419 | container_name: None, |
@@ -427,7 +430,7 @@ impl ToNav for hir::LifetimeParam { | |||
427 | NavigationTarget { | 430 | NavigationTarget { |
428 | file_id: src.file_id.original_file(db), | 431 | file_id: src.file_id.original_file(db), |
429 | name: self.name(db).to_string().into(), | 432 | name: self.name(db).to_string().into(), |
430 | kind: SymbolKind::LifetimeParam, | 433 | kind: Some(SymbolKind::LifetimeParam), |
431 | full_range, | 434 | full_range, |
432 | focus_range: Some(full_range), | 435 | focus_range: Some(full_range), |
433 | container_name: None, | 436 | container_name: None, |
@@ -488,7 +491,9 @@ fn foo() { enum FooInner { } } | |||
488 | 5..13, | 491 | 5..13, |
489 | ), | 492 | ), |
490 | name: "FooInner", | 493 | name: "FooInner", |
491 | kind: Enum, | 494 | kind: Some( |
495 | Enum, | ||
496 | ), | ||
492 | container_name: None, | 497 | container_name: None, |
493 | description: Some( | 498 | description: Some( |
494 | "enum FooInner", | 499 | "enum FooInner", |
@@ -504,7 +509,9 @@ fn foo() { enum FooInner { } } | |||
504 | 34..42, | 509 | 34..42, |
505 | ), | 510 | ), |
506 | name: "FooInner", | 511 | name: "FooInner", |
507 | kind: Enum, | 512 | kind: Some( |
513 | Enum, | ||
514 | ), | ||
508 | container_name: Some( | 515 | container_name: Some( |
509 | "foo", | 516 | "foo", |
510 | ), | 517 | ), |
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index 5bee69f4b..7a12e9965 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -86,7 +86,7 @@ fn self_to_nav_target(self_param: ast::SelfParam, file_id: FileId) -> Option<Nav | |||
86 | full_range: self_param.syntax().text_range(), | 86 | full_range: self_param.syntax().text_range(), |
87 | focus_range: Some(self_token.text_range()), | 87 | focus_range: Some(self_token.text_range()), |
88 | name: self_token.text().clone(), | 88 | name: self_token.text().clone(), |
89 | kind: SymbolKind::SelfParam, | 89 | kind: Some(SymbolKind::SelfParam), |
90 | container_name: None, | 90 | container_name: None, |
91 | description: None, | 91 | description: None, |
92 | docs: None, | 92 | docs: None, |
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index dca098af6..413b1526a 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -2191,7 +2191,9 @@ fn foo_<|>test() {} | |||
2191 | 11..19, | 2191 | 11..19, |
2192 | ), | 2192 | ), |
2193 | name: "foo_test", | 2193 | name: "foo_test", |
2194 | kind: Function, | 2194 | kind: Some( |
2195 | Function, | ||
2196 | ), | ||
2195 | container_name: None, | 2197 | container_name: None, |
2196 | description: None, | 2198 | description: None, |
2197 | docs: None, | 2199 | docs: None, |
@@ -2234,7 +2236,9 @@ mod tests<|> { | |||
2234 | 4..9, | 2236 | 4..9, |
2235 | ), | 2237 | ), |
2236 | name: "tests", | 2238 | name: "tests", |
2237 | kind: Module, | 2239 | kind: Some( |
2240 | Module, | ||
2241 | ), | ||
2238 | container_name: None, | 2242 | container_name: None, |
2239 | description: None, | 2243 | description: None, |
2240 | docs: None, | 2244 | docs: None, |
@@ -2273,7 +2277,9 @@ fn main() { let s<|>t = S{ f1:0 }; } | |||
2273 | 7..8, | 2277 | 7..8, |
2274 | ), | 2278 | ), |
2275 | name: "S", | 2279 | name: "S", |
2276 | kind: Struct, | 2280 | kind: Some( |
2281 | Struct, | ||
2282 | ), | ||
2277 | container_name: None, | 2283 | container_name: None, |
2278 | description: Some( | 2284 | description: Some( |
2279 | "struct S", | 2285 | "struct S", |
@@ -2312,7 +2318,9 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; } | |||
2312 | 24..25, | 2318 | 24..25, |
2313 | ), | 2319 | ), |
2314 | name: "S", | 2320 | name: "S", |
2315 | kind: Struct, | 2321 | kind: Some( |
2322 | Struct, | ||
2323 | ), | ||
2316 | container_name: None, | 2324 | container_name: None, |
2317 | description: Some( | 2325 | description: Some( |
2318 | "struct S", | 2326 | "struct S", |
@@ -2331,7 +2339,9 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; } | |||
2331 | 7..10, | 2339 | 7..10, |
2332 | ), | 2340 | ), |
2333 | name: "Arg", | 2341 | name: "Arg", |
2334 | kind: Struct, | 2342 | kind: Some( |
2343 | Struct, | ||
2344 | ), | ||
2335 | container_name: None, | 2345 | container_name: None, |
2336 | description: Some( | 2346 | description: Some( |
2337 | "struct Arg", | 2347 | "struct Arg", |
@@ -2370,7 +2380,9 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } | |||
2370 | 24..25, | 2380 | 24..25, |
2371 | ), | 2381 | ), |
2372 | name: "S", | 2382 | name: "S", |
2373 | kind: Struct, | 2383 | kind: Some( |
2384 | Struct, | ||
2385 | ), | ||
2374 | container_name: None, | 2386 | container_name: None, |
2375 | description: Some( | 2387 | description: Some( |
2376 | "struct S", | 2388 | "struct S", |
@@ -2389,7 +2401,9 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } | |||
2389 | 7..10, | 2401 | 7..10, |
2390 | ), | 2402 | ), |
2391 | name: "Arg", | 2403 | name: "Arg", |
2392 | kind: Struct, | 2404 | kind: Some( |
2405 | Struct, | ||
2406 | ), | ||
2393 | container_name: None, | 2407 | container_name: None, |
2394 | description: Some( | 2408 | description: Some( |
2395 | "struct Arg", | 2409 | "struct Arg", |
@@ -2431,7 +2445,9 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
2431 | 7..8, | 2445 | 7..8, |
2432 | ), | 2446 | ), |
2433 | name: "A", | 2447 | name: "A", |
2434 | kind: Struct, | 2448 | kind: Some( |
2449 | Struct, | ||
2450 | ), | ||
2435 | container_name: None, | 2451 | container_name: None, |
2436 | description: Some( | 2452 | description: Some( |
2437 | "struct A", | 2453 | "struct A", |
@@ -2450,7 +2466,9 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
2450 | 22..23, | 2466 | 22..23, |
2451 | ), | 2467 | ), |
2452 | name: "B", | 2468 | name: "B", |
2453 | kind: Struct, | 2469 | kind: Some( |
2470 | Struct, | ||
2471 | ), | ||
2454 | container_name: None, | 2472 | container_name: None, |
2455 | description: Some( | 2473 | description: Some( |
2456 | "struct B", | 2474 | "struct B", |
@@ -2469,7 +2487,9 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
2469 | 53..54, | 2487 | 53..54, |
2470 | ), | 2488 | ), |
2471 | name: "C", | 2489 | name: "C", |
2472 | kind: Struct, | 2490 | kind: Some( |
2491 | Struct, | ||
2492 | ), | ||
2473 | container_name: None, | 2493 | container_name: None, |
2474 | description: Some( | 2494 | description: Some( |
2475 | "pub struct C", | 2495 | "pub struct C", |
@@ -2508,7 +2528,9 @@ fn main() { let s<|>t = foo(); } | |||
2508 | 6..9, | 2528 | 6..9, |
2509 | ), | 2529 | ), |
2510 | name: "Foo", | 2530 | name: "Foo", |
2511 | kind: Trait, | 2531 | kind: Some( |
2532 | Trait, | ||
2533 | ), | ||
2512 | container_name: None, | 2534 | container_name: None, |
2513 | description: Some( | 2535 | description: Some( |
2514 | "trait Foo", | 2536 | "trait Foo", |
@@ -2548,7 +2570,9 @@ fn main() { let s<|>t = foo(); } | |||
2548 | 6..9, | 2570 | 6..9, |
2549 | ), | 2571 | ), |
2550 | name: "Foo", | 2572 | name: "Foo", |
2551 | kind: Trait, | 2573 | kind: Some( |
2574 | Trait, | ||
2575 | ), | ||
2552 | container_name: None, | 2576 | container_name: None, |
2553 | description: Some( | 2577 | description: Some( |
2554 | "trait Foo", | 2578 | "trait Foo", |
@@ -2567,7 +2591,9 @@ fn main() { let s<|>t = foo(); } | |||
2567 | 23..24, | 2591 | 23..24, |
2568 | ), | 2592 | ), |
2569 | name: "S", | 2593 | name: "S", |
2570 | kind: Struct, | 2594 | kind: Some( |
2595 | Struct, | ||
2596 | ), | ||
2571 | container_name: None, | 2597 | container_name: None, |
2572 | description: Some( | 2598 | description: Some( |
2573 | "struct S", | 2599 | "struct S", |
@@ -2607,7 +2633,9 @@ fn main() { let s<|>t = foo(); } | |||
2607 | 6..9, | 2633 | 6..9, |
2608 | ), | 2634 | ), |
2609 | name: "Foo", | 2635 | name: "Foo", |
2610 | kind: Trait, | 2636 | kind: Some( |
2637 | Trait, | ||
2638 | ), | ||
2611 | container_name: None, | 2639 | container_name: None, |
2612 | description: Some( | 2640 | description: Some( |
2613 | "trait Foo", | 2641 | "trait Foo", |
@@ -2626,7 +2654,9 @@ fn main() { let s<|>t = foo(); } | |||
2626 | 19..22, | 2654 | 19..22, |
2627 | ), | 2655 | ), |
2628 | name: "Bar", | 2656 | name: "Bar", |
2629 | kind: Trait, | 2657 | kind: Some( |
2658 | Trait, | ||
2659 | ), | ||
2630 | container_name: None, | 2660 | container_name: None, |
2631 | description: Some( | 2661 | description: Some( |
2632 | "trait Bar", | 2662 | "trait Bar", |
@@ -2669,7 +2699,9 @@ fn main() { let s<|>t = foo(); } | |||
2669 | 6..9, | 2699 | 6..9, |
2670 | ), | 2700 | ), |
2671 | name: "Foo", | 2701 | name: "Foo", |
2672 | kind: Trait, | 2702 | kind: Some( |
2703 | Trait, | ||
2704 | ), | ||
2673 | container_name: None, | 2705 | container_name: None, |
2674 | description: Some( | 2706 | description: Some( |
2675 | "trait Foo", | 2707 | "trait Foo", |
@@ -2688,7 +2720,9 @@ fn main() { let s<|>t = foo(); } | |||
2688 | 22..25, | 2720 | 22..25, |
2689 | ), | 2721 | ), |
2690 | name: "Bar", | 2722 | name: "Bar", |
2691 | kind: Trait, | 2723 | kind: Some( |
2724 | Trait, | ||
2725 | ), | ||
2692 | container_name: None, | 2726 | container_name: None, |
2693 | description: Some( | 2727 | description: Some( |
2694 | "trait Bar", | 2728 | "trait Bar", |
@@ -2707,7 +2741,9 @@ fn main() { let s<|>t = foo(); } | |||
2707 | 39..41, | 2741 | 39..41, |
2708 | ), | 2742 | ), |
2709 | name: "S1", | 2743 | name: "S1", |
2710 | kind: Struct, | 2744 | kind: Some( |
2745 | Struct, | ||
2746 | ), | ||
2711 | container_name: None, | 2747 | container_name: None, |
2712 | description: Some( | 2748 | description: Some( |
2713 | "struct S1", | 2749 | "struct S1", |
@@ -2726,7 +2762,9 @@ fn main() { let s<|>t = foo(); } | |||
2726 | 52..54, | 2762 | 52..54, |
2727 | ), | 2763 | ), |
2728 | name: "S2", | 2764 | name: "S2", |
2729 | kind: Struct, | 2765 | kind: Some( |
2766 | Struct, | ||
2767 | ), | ||
2730 | container_name: None, | 2768 | container_name: None, |
2731 | description: Some( | 2769 | description: Some( |
2732 | "struct S2", | 2770 | "struct S2", |
@@ -2763,7 +2801,9 @@ fn foo(ar<|>g: &impl Foo) {} | |||
2763 | 6..9, | 2801 | 6..9, |
2764 | ), | 2802 | ), |
2765 | name: "Foo", | 2803 | name: "Foo", |
2766 | kind: Trait, | 2804 | kind: Some( |
2805 | Trait, | ||
2806 | ), | ||
2767 | container_name: None, | 2807 | container_name: None, |
2768 | description: Some( | 2808 | description: Some( |
2769 | "trait Foo", | 2809 | "trait Foo", |
@@ -2803,7 +2843,9 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
2803 | 6..9, | 2843 | 6..9, |
2804 | ), | 2844 | ), |
2805 | name: "Foo", | 2845 | name: "Foo", |
2806 | kind: Trait, | 2846 | kind: Some( |
2847 | Trait, | ||
2848 | ), | ||
2807 | container_name: None, | 2849 | container_name: None, |
2808 | description: Some( | 2850 | description: Some( |
2809 | "trait Foo", | 2851 | "trait Foo", |
@@ -2822,7 +2864,9 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
2822 | 19..22, | 2864 | 19..22, |
2823 | ), | 2865 | ), |
2824 | name: "Bar", | 2866 | name: "Bar", |
2825 | kind: Trait, | 2867 | kind: Some( |
2868 | Trait, | ||
2869 | ), | ||
2826 | container_name: None, | 2870 | container_name: None, |
2827 | description: Some( | 2871 | description: Some( |
2828 | "trait Bar", | 2872 | "trait Bar", |
@@ -2841,7 +2885,9 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
2841 | 36..37, | 2885 | 36..37, |
2842 | ), | 2886 | ), |
2843 | name: "S", | 2887 | name: "S", |
2844 | kind: Struct, | 2888 | kind: Some( |
2889 | Struct, | ||
2890 | ), | ||
2845 | container_name: None, | 2891 | container_name: None, |
2846 | description: Some( | 2892 | description: Some( |
2847 | "struct S", | 2893 | "struct S", |
@@ -2886,7 +2932,9 @@ mod future { | |||
2886 | 140..146, | 2932 | 140..146, |
2887 | ), | 2933 | ), |
2888 | name: "Future", | 2934 | name: "Future", |
2889 | kind: Trait, | 2935 | kind: Some( |
2936 | Trait, | ||
2937 | ), | ||
2890 | container_name: None, | 2938 | container_name: None, |
2891 | description: Some( | 2939 | description: Some( |
2892 | "pub trait Future", | 2940 | "pub trait Future", |
@@ -2905,7 +2953,9 @@ mod future { | |||
2905 | 7..8, | 2953 | 7..8, |
2906 | ), | 2954 | ), |
2907 | name: "S", | 2955 | name: "S", |
2908 | kind: Struct, | 2956 | kind: Some( |
2957 | Struct, | ||
2958 | ), | ||
2909 | container_name: None, | 2959 | container_name: None, |
2910 | description: Some( | 2960 | description: Some( |
2911 | "struct S", | 2961 | "struct S", |
@@ -2943,7 +2993,9 @@ fn foo(ar<|>g: &impl Foo<S>) {} | |||
2943 | 6..9, | 2993 | 6..9, |
2944 | ), | 2994 | ), |
2945 | name: "Foo", | 2995 | name: "Foo", |
2946 | kind: Trait, | 2996 | kind: Some( |
2997 | Trait, | ||
2998 | ), | ||
2947 | container_name: None, | 2999 | container_name: None, |
2948 | description: Some( | 3000 | description: Some( |
2949 | "trait Foo", | 3001 | "trait Foo", |
@@ -2962,7 +3014,9 @@ fn foo(ar<|>g: &impl Foo<S>) {} | |||
2962 | 23..24, | 3014 | 23..24, |
2963 | ), | 3015 | ), |
2964 | name: "S", | 3016 | name: "S", |
2965 | kind: Struct, | 3017 | kind: Some( |
3018 | Struct, | ||
3019 | ), | ||
2966 | container_name: None, | 3020 | container_name: None, |
2967 | description: Some( | 3021 | description: Some( |
2968 | "struct S", | 3022 | "struct S", |
@@ -3005,7 +3059,9 @@ fn main() { let s<|>t = foo(); } | |||
3005 | 49..50, | 3059 | 49..50, |
3006 | ), | 3060 | ), |
3007 | name: "B", | 3061 | name: "B", |
3008 | kind: Struct, | 3062 | kind: Some( |
3063 | Struct, | ||
3064 | ), | ||
3009 | container_name: None, | 3065 | container_name: None, |
3010 | description: Some( | 3066 | description: Some( |
3011 | "struct B", | 3067 | "struct B", |
@@ -3024,7 +3080,9 @@ fn main() { let s<|>t = foo(); } | |||
3024 | 6..9, | 3080 | 6..9, |
3025 | ), | 3081 | ), |
3026 | name: "Foo", | 3082 | name: "Foo", |
3027 | kind: Trait, | 3083 | kind: Some( |
3084 | Trait, | ||
3085 | ), | ||
3028 | container_name: None, | 3086 | container_name: None, |
3029 | description: Some( | 3087 | description: Some( |
3030 | "trait Foo", | 3088 | "trait Foo", |
@@ -3061,7 +3119,9 @@ fn foo(ar<|>g: &dyn Foo) {} | |||
3061 | 6..9, | 3119 | 6..9, |
3062 | ), | 3120 | ), |
3063 | name: "Foo", | 3121 | name: "Foo", |
3064 | kind: Trait, | 3122 | kind: Some( |
3123 | Trait, | ||
3124 | ), | ||
3065 | container_name: None, | 3125 | container_name: None, |
3066 | description: Some( | 3126 | description: Some( |
3067 | "trait Foo", | 3127 | "trait Foo", |
@@ -3099,7 +3159,9 @@ fn foo(ar<|>g: &dyn Foo<S>) {} | |||
3099 | 6..9, | 3159 | 6..9, |
3100 | ), | 3160 | ), |
3101 | name: "Foo", | 3161 | name: "Foo", |
3102 | kind: Trait, | 3162 | kind: Some( |
3163 | Trait, | ||
3164 | ), | ||
3103 | container_name: None, | 3165 | container_name: None, |
3104 | description: Some( | 3166 | description: Some( |
3105 | "trait Foo", | 3167 | "trait Foo", |
@@ -3118,7 +3180,9 @@ fn foo(ar<|>g: &dyn Foo<S>) {} | |||
3118 | 23..24, | 3180 | 23..24, |
3119 | ), | 3181 | ), |
3120 | name: "S", | 3182 | name: "S", |
3121 | kind: Struct, | 3183 | kind: Some( |
3184 | Struct, | ||
3185 | ), | ||
3122 | container_name: None, | 3186 | container_name: None, |
3123 | description: Some( | 3187 | description: Some( |
3124 | "struct S", | 3188 | "struct S", |
@@ -3159,7 +3223,9 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
3159 | 6..15, | 3223 | 6..15, |
3160 | ), | 3224 | ), |
3161 | name: "ImplTrait", | 3225 | name: "ImplTrait", |
3162 | kind: Trait, | 3226 | kind: Some( |
3227 | Trait, | ||
3228 | ), | ||
3163 | container_name: None, | 3229 | container_name: None, |
3164 | description: Some( | 3230 | description: Some( |
3165 | "trait ImplTrait", | 3231 | "trait ImplTrait", |
@@ -3178,7 +3244,9 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
3178 | 50..51, | 3244 | 50..51, |
3179 | ), | 3245 | ), |
3180 | name: "B", | 3246 | name: "B", |
3181 | kind: Struct, | 3247 | kind: Some( |
3248 | Struct, | ||
3249 | ), | ||
3182 | container_name: None, | 3250 | container_name: None, |
3183 | description: Some( | 3251 | description: Some( |
3184 | "struct B", | 3252 | "struct B", |
@@ -3197,7 +3265,9 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
3197 | 28..36, | 3265 | 28..36, |
3198 | ), | 3266 | ), |
3199 | name: "DynTrait", | 3267 | name: "DynTrait", |
3200 | kind: Trait, | 3268 | kind: Some( |
3269 | Trait, | ||
3270 | ), | ||
3201 | container_name: None, | 3271 | container_name: None, |
3202 | description: Some( | 3272 | description: Some( |
3203 | "trait DynTrait", | 3273 | "trait DynTrait", |
@@ -3216,7 +3286,9 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
3216 | 65..66, | 3286 | 65..66, |
3217 | ), | 3287 | ), |
3218 | name: "S", | 3288 | name: "S", |
3219 | kind: Struct, | 3289 | kind: Some( |
3290 | Struct, | ||
3291 | ), | ||
3220 | container_name: None, | 3292 | container_name: None, |
3221 | description: Some( | 3293 | description: Some( |
3222 | "struct S", | 3294 | "struct S", |
@@ -3264,7 +3336,9 @@ fn main() { let s<|>t = test().get(); } | |||
3264 | 6..9, | 3336 | 6..9, |
3265 | ), | 3337 | ), |
3266 | name: "Foo", | 3338 | name: "Foo", |
3267 | kind: Trait, | 3339 | kind: Some( |
3340 | Trait, | ||
3341 | ), | ||
3268 | container_name: None, | 3342 | container_name: None, |
3269 | description: Some( | 3343 | description: Some( |
3270 | "trait Foo", | 3344 | "trait Foo", |
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index d8069eb64..8c00a7105 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -278,7 +278,7 @@ fn try_find_self_references( | |||
278 | full_range: self_param.syntax().text_range(), | 278 | full_range: self_param.syntax().text_range(), |
279 | focus_range: Some(param_self_token.text_range()), | 279 | focus_range: Some(param_self_token.text_range()), |
280 | name: param_self_token.text().clone(), | 280 | name: param_self_token.text().clone(), |
281 | kind: SymbolKind::SelfParam, | 281 | kind: Some(SymbolKind::SelfParam), |
282 | container_name: None, | 282 | container_name: None, |
283 | description: None, | 283 | description: None, |
284 | docs: None, | 284 | docs: None, |
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 600e93b6a..99f11c295 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -208,7 +208,7 @@ fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Op | |||
208 | nav.focus_range = None; | 208 | nav.focus_range = None; |
209 | nav.description = None; | 209 | nav.description = None; |
210 | nav.docs = None; | 210 | nav.docs = None; |
211 | nav.kind = SymbolKind::DocTest; | 211 | nav.kind = None; |
212 | let res = Runnable { nav, kind: RunnableKind::DocTest { test_id }, cfg: attrs.cfg() }; | 212 | let res = Runnable { nav, kind: RunnableKind::DocTest { test_id }, cfg: attrs.cfg() }; |
213 | Some(res) | 213 | Some(res) |
214 | } | 214 | } |
@@ -356,7 +356,9 @@ fn bench() {} | |||
356 | 4..8, | 356 | 4..8, |
357 | ), | 357 | ), |
358 | name: "main", | 358 | name: "main", |
359 | kind: Function, | 359 | kind: Some( |
360 | Function, | ||
361 | ), | ||
360 | container_name: None, | 362 | container_name: None, |
361 | description: None, | 363 | description: None, |
362 | docs: None, | 364 | docs: None, |
@@ -374,7 +376,9 @@ fn bench() {} | |||
374 | 26..34, | 376 | 26..34, |
375 | ), | 377 | ), |
376 | name: "test_foo", | 378 | name: "test_foo", |
377 | kind: Function, | 379 | kind: Some( |
380 | Function, | ||
381 | ), | ||
378 | container_name: None, | 382 | container_name: None, |
379 | description: None, | 383 | description: None, |
380 | docs: None, | 384 | docs: None, |
@@ -399,7 +403,9 @@ fn bench() {} | |||
399 | 62..70, | 403 | 62..70, |
400 | ), | 404 | ), |
401 | name: "test_foo", | 405 | name: "test_foo", |
402 | kind: Function, | 406 | kind: Some( |
407 | Function, | ||
408 | ), | ||
403 | container_name: None, | 409 | container_name: None, |
404 | description: None, | 410 | description: None, |
405 | docs: None, | 411 | docs: None, |
@@ -424,7 +430,9 @@ fn bench() {} | |||
424 | 89..94, | 430 | 89..94, |
425 | ), | 431 | ), |
426 | name: "bench", | 432 | name: "bench", |
427 | kind: Function, | 433 | kind: Some( |
434 | Function, | ||
435 | ), | ||
428 | container_name: None, | 436 | container_name: None, |
429 | description: None, | 437 | description: None, |
430 | docs: None, | 438 | docs: None, |
@@ -521,7 +529,9 @@ struct StructWithRunnable(String); | |||
521 | 4..8, | 529 | 4..8, |
522 | ), | 530 | ), |
523 | name: "main", | 531 | name: "main", |
524 | kind: Function, | 532 | kind: Some( |
533 | Function, | ||
534 | ), | ||
525 | container_name: None, | 535 | container_name: None, |
526 | description: None, | 536 | description: None, |
527 | docs: None, | 537 | docs: None, |
@@ -537,7 +547,7 @@ struct StructWithRunnable(String); | |||
537 | full_range: 15..74, | 547 | full_range: 15..74, |
538 | focus_range: None, | 548 | focus_range: None, |
539 | name: "should_have_runnable", | 549 | name: "should_have_runnable", |
540 | kind: DocTest, | 550 | kind: None, |
541 | container_name: None, | 551 | container_name: None, |
542 | description: None, | 552 | description: None, |
543 | docs: None, | 553 | docs: None, |
@@ -557,7 +567,7 @@ struct StructWithRunnable(String); | |||
557 | full_range: 76..148, | 567 | full_range: 76..148, |
558 | focus_range: None, | 568 | focus_range: None, |
559 | name: "should_have_runnable_1", | 569 | name: "should_have_runnable_1", |
560 | kind: DocTest, | 570 | kind: None, |
561 | container_name: None, | 571 | container_name: None, |
562 | description: None, | 572 | description: None, |
563 | docs: None, | 573 | docs: None, |
@@ -577,7 +587,7 @@ struct StructWithRunnable(String); | |||
577 | full_range: 150..254, | 587 | full_range: 150..254, |
578 | focus_range: None, | 588 | focus_range: None, |
579 | name: "should_have_runnable_2", | 589 | name: "should_have_runnable_2", |
580 | kind: DocTest, | 590 | kind: None, |
581 | container_name: None, | 591 | container_name: None, |
582 | description: None, | 592 | description: None, |
583 | docs: None, | 593 | docs: None, |
@@ -597,7 +607,7 @@ struct StructWithRunnable(String); | |||
597 | full_range: 756..821, | 607 | full_range: 756..821, |
598 | focus_range: None, | 608 | focus_range: None, |
599 | name: "StructWithRunnable", | 609 | name: "StructWithRunnable", |
600 | kind: DocTest, | 610 | kind: None, |
601 | container_name: None, | 611 | container_name: None, |
602 | description: None, | 612 | description: None, |
603 | docs: None, | 613 | docs: None, |
@@ -643,7 +653,9 @@ impl Data { | |||
643 | 4..8, | 653 | 4..8, |
644 | ), | 654 | ), |
645 | name: "main", | 655 | name: "main", |
646 | kind: Function, | 656 | kind: Some( |
657 | Function, | ||
658 | ), | ||
647 | container_name: None, | 659 | container_name: None, |
648 | description: None, | 660 | description: None, |
649 | docs: None, | 661 | docs: None, |
@@ -659,7 +671,7 @@ impl Data { | |||
659 | full_range: 44..98, | 671 | full_range: 44..98, |
660 | focus_range: None, | 672 | focus_range: None, |
661 | name: "foo", | 673 | name: "foo", |
662 | kind: DocTest, | 674 | kind: None, |
663 | container_name: None, | 675 | container_name: None, |
664 | description: None, | 676 | description: None, |
665 | docs: None, | 677 | docs: None, |
@@ -700,7 +712,9 @@ mod test_mod { | |||
700 | 5..13, | 712 | 5..13, |
701 | ), | 713 | ), |
702 | name: "test_mod", | 714 | name: "test_mod", |
703 | kind: Module, | 715 | kind: Some( |
716 | Module, | ||
717 | ), | ||
704 | container_name: None, | 718 | container_name: None, |
705 | description: None, | 719 | description: None, |
706 | docs: None, | 720 | docs: None, |
@@ -720,7 +734,9 @@ mod test_mod { | |||
720 | 35..44, | 734 | 35..44, |
721 | ), | 735 | ), |
722 | name: "test_foo1", | 736 | name: "test_foo1", |
723 | kind: Function, | 737 | kind: Some( |
738 | Function, | ||
739 | ), | ||
724 | container_name: None, | 740 | container_name: None, |
725 | description: None, | 741 | description: None, |
726 | docs: None, | 742 | docs: None, |
@@ -780,7 +796,9 @@ mod root_tests { | |||
780 | 26..40, | 796 | 26..40, |
781 | ), | 797 | ), |
782 | name: "nested_tests_0", | 798 | name: "nested_tests_0", |
783 | kind: Module, | 799 | kind: Some( |
800 | Module, | ||
801 | ), | ||
784 | container_name: None, | 802 | container_name: None, |
785 | description: None, | 803 | description: None, |
786 | docs: None, | 804 | docs: None, |
@@ -800,7 +818,9 @@ mod root_tests { | |||
800 | 55..69, | 818 | 55..69, |
801 | ), | 819 | ), |
802 | name: "nested_tests_1", | 820 | name: "nested_tests_1", |
803 | kind: Module, | 821 | kind: Some( |
822 | Module, | ||
823 | ), | ||
804 | container_name: None, | 824 | container_name: None, |
805 | description: None, | 825 | description: None, |
806 | docs: None, | 826 | docs: None, |
@@ -820,7 +840,9 @@ mod root_tests { | |||
820 | 107..121, | 840 | 107..121, |
821 | ), | 841 | ), |
822 | name: "nested_test_11", | 842 | name: "nested_test_11", |
823 | kind: Function, | 843 | kind: Some( |
844 | Function, | ||
845 | ), | ||
824 | container_name: None, | 846 | container_name: None, |
825 | description: None, | 847 | description: None, |
826 | docs: None, | 848 | docs: None, |
@@ -845,7 +867,9 @@ mod root_tests { | |||
845 | 163..177, | 867 | 163..177, |
846 | ), | 868 | ), |
847 | name: "nested_test_12", | 869 | name: "nested_test_12", |
848 | kind: Function, | 870 | kind: Some( |
871 | Function, | ||
872 | ), | ||
849 | container_name: None, | 873 | container_name: None, |
850 | description: None, | 874 | description: None, |
851 | docs: None, | 875 | docs: None, |
@@ -870,7 +894,9 @@ mod root_tests { | |||
870 | 206..220, | 894 | 206..220, |
871 | ), | 895 | ), |
872 | name: "nested_tests_2", | 896 | name: "nested_tests_2", |
873 | kind: Module, | 897 | kind: Some( |
898 | Module, | ||
899 | ), | ||
874 | container_name: None, | 900 | container_name: None, |
875 | description: None, | 901 | description: None, |
876 | docs: None, | 902 | docs: None, |
@@ -890,7 +916,9 @@ mod root_tests { | |||
890 | 258..271, | 916 | 258..271, |
891 | ), | 917 | ), |
892 | name: "nested_test_2", | 918 | name: "nested_test_2", |
893 | kind: Function, | 919 | kind: Some( |
920 | Function, | ||
921 | ), | ||
894 | container_name: None, | 922 | container_name: None, |
895 | description: None, | 923 | description: None, |
896 | docs: None, | 924 | docs: None, |
@@ -933,7 +961,9 @@ fn test_foo1() {} | |||
933 | 36..45, | 961 | 36..45, |
934 | ), | 962 | ), |
935 | name: "test_foo1", | 963 | name: "test_foo1", |
936 | kind: Function, | 964 | kind: Some( |
965 | Function, | ||
966 | ), | ||
937 | container_name: None, | 967 | container_name: None, |
938 | description: None, | 968 | description: None, |
939 | docs: None, | 969 | docs: None, |
@@ -983,7 +1013,9 @@ fn test_foo1() {} | |||
983 | 58..67, | 1013 | 58..67, |
984 | ), | 1014 | ), |
985 | name: "test_foo1", | 1015 | name: "test_foo1", |
986 | kind: Function, | 1016 | kind: Some( |
1017 | Function, | ||
1018 | ), | ||
987 | container_name: None, | 1019 | container_name: None, |
988 | description: None, | 1020 | description: None, |
989 | docs: None, | 1021 | docs: None, |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 404b35025..66f8bee99 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -385,7 +385,10 @@ pub(crate) fn handle_workspace_symbol( | |||
385 | #[allow(deprecated)] | 385 | #[allow(deprecated)] |
386 | let info = SymbolInformation { | 386 | let info = SymbolInformation { |
387 | name: nav.name.to_string(), | 387 | name: nav.name.to_string(), |
388 | kind: to_proto::symbol_kind(nav.kind), | 388 | kind: nav |
389 | .kind | ||
390 | .map(to_proto::symbol_kind) | ||
391 | .unwrap_or(lsp_types::SymbolKind::Variable), | ||
389 | tags: None, | 392 | tags: None, |
390 | location: to_proto::location_from_nav(snap, nav)?, | 393 | location: to_proto::location_from_nav(snap, nav)?, |
391 | container_name, | 394 | container_name, |
@@ -1263,7 +1266,7 @@ pub(crate) fn handle_call_hierarchy_prepare( | |||
1263 | let RangeInfo { range: _, info: navs } = nav_info; | 1266 | let RangeInfo { range: _, info: navs } = nav_info; |
1264 | let res = navs | 1267 | let res = navs |
1265 | .into_iter() | 1268 | .into_iter() |
1266 | .filter(|it| it.kind == SymbolKind::Function) | 1269 | .filter(|it| it.kind == Some(SymbolKind::Function)) |
1267 | .map(|it| to_proto::call_hierarchy_item(&snap, it)) | 1270 | .map(|it| to_proto::call_hierarchy_item(&snap, it)) |
1268 | .collect::<Result<Vec<_>>>()?; | 1271 | .collect::<Result<Vec<_>>>()?; |
1269 | 1272 | ||
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 79caafe80..6b2302803 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -43,10 +43,9 @@ pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind { | |||
43 | SymbolKind::Static => lsp_types::SymbolKind::Constant, | 43 | SymbolKind::Static => lsp_types::SymbolKind::Constant, |
44 | SymbolKind::Const => lsp_types::SymbolKind::Constant, | 44 | SymbolKind::Const => lsp_types::SymbolKind::Constant, |
45 | SymbolKind::Impl => lsp_types::SymbolKind::Object, | 45 | SymbolKind::Impl => lsp_types::SymbolKind::Object, |
46 | SymbolKind::Local | 46 | SymbolKind::Local | SymbolKind::SelfParam | SymbolKind::LifetimeParam => { |
47 | | SymbolKind::SelfParam | 47 | lsp_types::SymbolKind::Variable |
48 | | SymbolKind::LifetimeParam | 48 | } |
49 | | SymbolKind::DocTest => lsp_types::SymbolKind::Variable, | ||
50 | SymbolKind::Union => lsp_types::SymbolKind::Struct, | 49 | SymbolKind::Union => lsp_types::SymbolKind::Struct, |
51 | } | 50 | } |
52 | } | 51 | } |
@@ -722,7 +721,7 @@ pub(crate) fn call_hierarchy_item( | |||
722 | ) -> Result<lsp_types::CallHierarchyItem> { | 721 | ) -> Result<lsp_types::CallHierarchyItem> { |
723 | let name = target.name.to_string(); | 722 | let name = target.name.to_string(); |
724 | let detail = target.description.clone(); | 723 | let detail = target.description.clone(); |
725 | let kind = symbol_kind(target.kind); | 724 | let kind = target.kind.map(symbol_kind).unwrap_or(lsp_types::SymbolKind::Function); |
726 | let (uri, range, selection_range) = location_info(snap, target)?; | 725 | let (uri, range, selection_range) = location_info(snap, target)?; |
727 | Ok(lsp_types::CallHierarchyItem { | 726 | Ok(lsp_types::CallHierarchyItem { |
728 | name, | 727 | name, |