mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Small helpers
This commit is contained in:
parent
ca42a52051
commit
27b3b13824
2 changed files with 5 additions and 1 deletions
|
@ -124,8 +124,8 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
|
||||||
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding
|
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corredponding
|
||||||
// capability enabled.
|
// capability enabled.
|
||||||
fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
||||||
let _p = profile::span("fuzzy_completion");
|
|
||||||
let potential_import_name = ctx.token.to_string();
|
let potential_import_name = ctx.token.to_string();
|
||||||
|
let _p = profile::span("fuzzy_completion").detail(|| potential_import_name.clone());
|
||||||
|
|
||||||
if potential_import_name.len() < 2 {
|
if potential_import_name.len() < 2 {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -8,6 +8,7 @@ use hir_expand::name::Name;
|
||||||
use indexmap::{map::Entry, IndexMap};
|
use indexmap::{map::Entry, IndexMap};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_hash::{FxHashSet, FxHasher};
|
use rustc_hash::{FxHashSet, FxHasher};
|
||||||
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase, item_scope::ItemInNs, visibility::Visibility, AssocItemId, ModuleDefId,
|
db::DefDatabase, item_scope::ItemInNs, visibility::Visibility, AssocItemId, ModuleDefId,
|
||||||
|
@ -185,6 +186,7 @@ impl ImportMap {
|
||||||
is_type_in_ns: bool,
|
is_type_in_ns: bool,
|
||||||
original_import_info: &ImportInfo,
|
original_import_info: &ImportInfo,
|
||||||
) {
|
) {
|
||||||
|
mark::hit!(type_aliases_ignored);
|
||||||
for (assoc_item_name, item) in &db.trait_data(tr).items {
|
for (assoc_item_name, item) in &db.trait_data(tr).items {
|
||||||
let module_def_id = match item {
|
let module_def_id = match item {
|
||||||
AssocItemId::FunctionId(f) => ModuleDefId::from(*f),
|
AssocItemId::FunctionId(f) => ModuleDefId::from(*f),
|
||||||
|
@ -442,6 +444,7 @@ fn item_import_kind(item: ItemInNs) -> Option<ImportKind> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use base_db::{fixture::WithFixture, SourceDatabase, Upcast};
|
use base_db::{fixture::WithFixture, SourceDatabase, Upcast};
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{test_db::TestDB, AssocContainerId, Lookup};
|
use crate::{test_db::TestDB, AssocContainerId, Lookup};
|
||||||
|
|
||||||
|
@ -779,6 +782,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fuzzy_import_trait_and_assoc_items() {
|
fn fuzzy_import_trait_and_assoc_items() {
|
||||||
|
mark::check!(type_aliases_ignored);
|
||||||
let ra_fixture = r#"
|
let ra_fixture = r#"
|
||||||
//- /main.rs crate:main deps:dep
|
//- /main.rs crate:main deps:dep
|
||||||
//- /dep.rs crate:dep
|
//- /dep.rs crate:dep
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue