mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Only complete modules in empty use-statements
This commit is contained in:
parent
01bfc5f5c0
commit
9e71dd9799
3 changed files with 27 additions and 14 deletions
|
@ -14,6 +14,7 @@ use crate::test_utils::{check_pattern_is_applicable, check_pattern_is_not_applic
|
|||
/// Direct parent container of the cursor position
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ImmediateLocation {
|
||||
Use,
|
||||
Impl,
|
||||
Trait,
|
||||
RecordField,
|
||||
|
@ -58,6 +59,7 @@ pub(crate) fn determine_location(tok: SyntaxToken) -> Option<ImmediateLocation>
|
|||
let res = match_ast! {
|
||||
match parent {
|
||||
ast::IdentPat(_it) => ImmediateLocation::IdentPat,
|
||||
ast::Use(_it) => ImmediateLocation::Use,
|
||||
ast::BlockExpr(_it) => ImmediateLocation::BlockExpr,
|
||||
ast::SourceFile(_it) => ImmediateLocation::ItemList,
|
||||
ast::ItemList(_it) => ImmediateLocation::ItemList,
|
||||
|
@ -87,6 +89,11 @@ fn test_has_trait_parent() {
|
|||
check_location(r"trait A { f$0 }", ImmediateLocation::Trait);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_has_use_parent() {
|
||||
check_location(r"use f$0", ImmediateLocation::Use);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_has_impl_parent() {
|
||||
check_location(r"impl A { f$0 }", ImmediateLocation::Impl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue