Bump DEFAULT_QUERY_SEARCH_LIMIT from 40 to 100

This commit is contained in:
Lukas Wirth 2023-12-12 12:03:37 +01:00
parent 34ec665ba1
commit 1604ad1a6d
5 changed files with 66 additions and 24 deletions

View File

@ -23,6 +23,7 @@ pub struct FileSymbol {
pub loc: DeclarationLocation,
pub container_name: Option<SmolStr>,
pub is_alias: bool,
pub is_assoc: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@ -121,34 +122,34 @@ fn collect_from_module(&mut self, module_id: ModuleId) {
match module_def_id {
ModuleDefId::ModuleId(id) => self.push_module(id),
ModuleDefId::FunctionId(id) => {
self.push_decl(id);
self.push_decl(id, false);
self.collect_from_body(id);
}
ModuleDefId::AdtId(AdtId::StructId(id)) => self.push_decl(id),
ModuleDefId::AdtId(AdtId::EnumId(id)) => self.push_decl(id),
ModuleDefId::AdtId(AdtId::UnionId(id)) => self.push_decl(id),
ModuleDefId::AdtId(AdtId::StructId(id)) => self.push_decl(id, false),
ModuleDefId::AdtId(AdtId::EnumId(id)) => self.push_decl(id, false),
ModuleDefId::AdtId(AdtId::UnionId(id)) => self.push_decl(id, false),
ModuleDefId::ConstId(id) => {
self.push_decl(id);
self.push_decl(id, false);
self.collect_from_body(id);
}
ModuleDefId::StaticId(id) => {
self.push_decl(id);
self.push_decl(id, false);
self.collect_from_body(id);
}
ModuleDefId::TraitId(id) => {
self.push_decl(id);
self.push_decl(id, false);
self.collect_from_trait(id);
}
ModuleDefId::TraitAliasId(id) => {
self.push_decl(id);
self.push_decl(id, false);
}
ModuleDefId::TypeAliasId(id) => {
self.push_decl(id);
self.push_decl(id, false);
}
ModuleDefId::MacroId(id) => match id {
MacroId::Macro2Id(id) => self.push_decl(id),
MacroId::MacroRulesId(id) => self.push_decl(id),
MacroId::ProcMacroId(id) => self.push_decl(id),
MacroId::Macro2Id(id) => self.push_decl(id, false),
MacroId::MacroRulesId(id) => self.push_decl(id, false),
MacroId::ProcMacroId(id) => self.push_decl(id, false),
},
// Don't index these.
ModuleDefId::BuiltinType(_) => {}
@ -190,6 +191,7 @@ fn collect_from_module(&mut self, module_id: ModuleId) {
container_name: self.current_container_name.clone(),
loc: dec_loc,
is_alias: false,
is_assoc: false,
});
});
}
@ -202,9 +204,9 @@ fn collect_from_module(&mut self, module_id: ModuleId) {
for &id in id {
if id.module(self.db.upcast()) == module_id {
match id {
MacroId::Macro2Id(id) => self.push_decl(id),
MacroId::MacroRulesId(id) => self.push_decl(id),
MacroId::ProcMacroId(id) => self.push_decl(id),
MacroId::Macro2Id(id) => self.push_decl(id, false),
MacroId::MacroRulesId(id) => self.push_decl(id, false),
MacroId::ProcMacroId(id) => self.push_decl(id, false),
}
}
}
@ -266,13 +268,13 @@ fn def_with_body_id_name(&self, body_id: DefWithBodyId) -> Option<SmolStr> {
fn push_assoc_item(&mut self, assoc_item_id: AssocItemId) {
match assoc_item_id {
AssocItemId::FunctionId(id) => self.push_decl(id),
AssocItemId::ConstId(id) => self.push_decl(id),
AssocItemId::TypeAliasId(id) => self.push_decl(id),
AssocItemId::FunctionId(id) => self.push_decl(id, true),
AssocItemId::ConstId(id) => self.push_decl(id, true),
AssocItemId::TypeAliasId(id) => self.push_decl(id, true),
}
}
fn push_decl<L>(&mut self, id: L)
fn push_decl<L>(&mut self, id: L, is_assoc: bool)
where
L: Lookup + Into<ModuleDefId>,
<L as Lookup>::Data: HasSource,
@ -296,6 +298,7 @@ fn push_decl<L>(&mut self, id: L)
loc: dec_loc.clone(),
container_name: self.current_container_name.clone(),
is_alias: true,
is_assoc,
});
}
}
@ -306,6 +309,7 @@ fn push_decl<L>(&mut self, id: L)
container_name: self.current_container_name.clone(),
loc: dec_loc,
is_alias: false,
is_assoc,
});
}
@ -331,6 +335,7 @@ fn push_module(&mut self, module_id: ModuleId) {
loc: dec_loc.clone(),
container_name: self.current_container_name.clone(),
is_alias: true,
is_assoc: false,
});
}
}
@ -341,6 +346,7 @@ fn push_module(&mut self, module_id: ModuleId) {
container_name: self.current_container_name.clone(),
loc: dec_loc,
is_alias: false,
is_assoc: false,
});
}
}

View File

@ -3,13 +3,13 @@
//! The main reason for this module to exist is the fact that project's items and dependencies' items
//! are located in different caches, with different APIs.
use either::Either;
use hir::{import_map, AsAssocItem, Crate, ItemInNs, Semantics};
use hir::{import_map, Crate, ItemInNs, Semantics};
use limit::Limit;
use crate::{imports::import_assets::NameToImport, symbol_index, RootDatabase};
/// A value to use, when uncertain which limit to pick.
pub static DEFAULT_QUERY_SEARCH_LIMIT: Limit = Limit::new(40);
pub static DEFAULT_QUERY_SEARCH_LIMIT: Limit = Limit::new(100);
pub use import_map::AssocSearchMode;
@ -101,8 +101,8 @@ fn find_items<'a>(
.into_iter()
.filter(move |candidate| match assoc_item_search {
AssocSearchMode::Include => true,
AssocSearchMode::Exclude => candidate.def.as_assoc_item(db).is_none(),
AssocSearchMode::AssocItemsOnly => candidate.def.as_assoc_item(db).is_some(),
AssocSearchMode::Exclude => !candidate.is_assoc,
AssocSearchMode::AssocItemsOnly => candidate.is_assoc,
})
.map(|local_candidate| match local_candidate.def {
hir::ModuleDef::Macro(macro_def) => ItemInNs::Macros(macro_def),

View File

@ -50,7 +50,7 @@ enum SearchMode {
Prefix,
}
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Query {
query: String,
lowercased: String,

View File

@ -36,6 +36,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Struct",
@ -65,6 +66,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "mul1",
@ -94,6 +96,7 @@
},
container_name: None,
is_alias: true,
is_assoc: false,
},
FileSymbol {
name: "mul2",
@ -123,6 +126,7 @@
},
container_name: None,
is_alias: true,
is_assoc: false,
},
FileSymbol {
name: "s1",
@ -152,6 +156,7 @@
},
container_name: None,
is_alias: true,
is_assoc: false,
},
FileSymbol {
name: "s1",
@ -181,6 +186,7 @@
},
container_name: None,
is_alias: true,
is_assoc: false,
},
FileSymbol {
name: "s2",
@ -210,6 +216,7 @@
},
container_name: None,
is_alias: true,
is_assoc: false,
},
],
),

View File

@ -34,6 +34,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "CONST",
@ -61,6 +62,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "CONST_WITH_INNER",
@ -88,6 +90,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Enum",
@ -117,6 +120,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "ItemLikeMacro",
@ -146,6 +150,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Macro",
@ -175,6 +180,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "STATIC",
@ -202,6 +208,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Struct",
@ -231,6 +238,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "StructFromMacro",
@ -260,6 +268,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "StructInFn",
@ -291,6 +300,7 @@
"main",
),
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "StructInNamedConst",
@ -322,6 +332,7 @@
"CONST_WITH_INNER",
),
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "StructInUnnamedConst",
@ -351,6 +362,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Trait",
@ -378,6 +390,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Trait",
@ -407,6 +420,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "Union",
@ -436,6 +450,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "a_mod",
@ -465,6 +480,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "b_mod",
@ -494,6 +510,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "define_struct",
@ -523,6 +540,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "impl_fn",
@ -550,6 +568,7 @@
},
container_name: None,
is_alias: false,
is_assoc: true,
},
FileSymbol {
name: "macro_rules_macro",
@ -579,6 +598,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "main",
@ -606,6 +626,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "really_define_struct",
@ -635,6 +656,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "trait_fn",
@ -664,6 +686,7 @@
"Trait",
),
is_alias: false,
is_assoc: true,
},
],
),
@ -704,6 +727,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
],
),
@ -744,6 +768,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "StructInModB",
@ -773,6 +798,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "SuperItemLikeMacro",
@ -802,6 +828,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "ThisStruct",
@ -831,6 +858,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
FileSymbol {
name: "ThisStruct",
@ -860,6 +888,7 @@
},
container_name: None,
is_alias: false,
is_assoc: false,
},
],
),