mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
update ra_ide_api to use builtins
This commit is contained in:
parent
c6ee9d681c
commit
b6a854e161
8 changed files with 82 additions and 55 deletions
|
@ -17,6 +17,12 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
hir::ModuleDef::Module(module) => {
|
||||
let module_scope = module.scope(ctx.db);
|
||||
for (name, res) in module_scope.entries() {
|
||||
if let Some(hir::ModuleDef::BuiltinType(..)) = res.def.as_ref().take_types() {
|
||||
if ctx.use_item_syntax.is_some() {
|
||||
tested_by!(dont_complete_primitive_in_use);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if Some(module) == ctx.module {
|
||||
if let Some(import) = res.import {
|
||||
if let Either::A(use_tree) = module.import_source(ctx.db, import) {
|
||||
|
@ -88,6 +94,20 @@ mod tests {
|
|||
assert_eq!(completions.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_complete_primitive_in_use() {
|
||||
covers!(dont_complete_primitive_in_use);
|
||||
let completions = do_completion(r"use self::<|>;", CompletionKind::BuiltinType);
|
||||
assert!(completions.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_primitives() {
|
||||
let completions =
|
||||
do_completion(r"fn main() { let _: <|> = 92; }", CompletionKind::BuiltinType);
|
||||
assert_eq!(completions.len(), 17);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_mod_with_docs() {
|
||||
check_reference_completion(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue