aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-10 21:35:19 +0000
committerGitHub <[email protected]>2019-11-10 21:35:19 +0000
commit7973fd66e9a7f178b0963675c62233474dcec954 (patch)
treee55d40fa70e9e1122aecbe66f258073b2c3d7a43 /crates/ra_ide_api/src/completion
parent9d786ea221b27fbdf7c7f7beea0290db448e0611 (diff)
parentd634364462931c0a4944de29b38681a482817b6b (diff)
Merge #2201
2201: Resolve core types r=matklad a=Matthias247 This adds support for completion and goto definition of types defined within the "core" crate. The core crate is added as a dependency to each crate in the project. The core crate exported it's own prelude. This caused now all crates to inherit the core crates prelude instead of the std crates. In order to avoid the problem the prelude resolution has been changed to overwrite an already resolved prelude if this was set to a crate named core - in order to pick a better prelude like std. Fixes #2199 Co-authored-by: Matthias Einwag <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion')
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 4e56de3f5..3e205efd1 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -598,6 +598,68 @@ mod tests {
598 } 598 }
599 599
600 #[test] 600 #[test]
601 fn completes_std_prelude_if_core_is_defined() {
602 assert_debug_snapshot!(
603 do_reference_completion(
604 "
605 //- /main.rs
606 fn foo() { let x: <|> }
607
608 //- /core/lib.rs
609 #[prelude_import]
610 use prelude::*;
611
612 mod prelude {
613 struct Option;
614 }
615
616 //- /std/lib.rs
617 #[prelude_import]
618 use prelude::*;
619
620 mod prelude {
621 struct String;
622 }
623 "
624 ),
625 @r###"
626 [
627 CompletionItem {
628 label: "String",
629 source_range: [18; 18),
630 delete: [18; 18),
631 insert: "String",
632 kind: Struct,
633 },
634 CompletionItem {
635 label: "core",
636 source_range: [18; 18),
637 delete: [18; 18),
638 insert: "core",
639 kind: Module,
640 },
641 CompletionItem {
642 label: "foo()",
643 source_range: [18; 18),
644 delete: [18; 18),
645 insert: "foo()$0",
646 kind: Function,
647 lookup: "foo",
648 detail: "fn foo()",
649 },
650 CompletionItem {
651 label: "std",
652 source_range: [18; 18),
653 delete: [18; 18),
654 insert: "std",
655 kind: Module,
656 },
657 ]
658 "###
659 );
660 }
661
662 #[test]
601 fn completes_macros_as_value() { 663 fn completes_macros_as_value() {
602 assert_debug_snapshot!( 664 assert_debug_snapshot!(
603 do_reference_completion( 665 do_reference_completion(