Skip to content

Commit 3203cb1

Browse files
committed
Added coverage for trait, mod, impl, and enum cases.
1 parent 27b65ec commit 3203cb1

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

crates/ide-assists/src/handlers/extract_module.rs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,12 @@ impl Module {
385385
// We're looking for the start of functions, impls, structs, traits, and other documentable/attribute
386386
// macroable items that would have pub(crate) in front of it
387387
SyntaxKind::FN_KW
388-
| SyntaxKind::IMPL_KW
389388
| SyntaxKind::STRUCT_KW
389+
| SyntaxKind::ENUM_KW
390390
| SyntaxKind::TRAIT_KW
391391
| SyntaxKind::TYPE_KW
392392
| SyntaxKind::MOD_KW => true,
393-
// If we didn't find a keyword, we want to cover the record fields
393+
// If we didn't find a keyword, we want to cover the record fields in a struct
394394
SyntaxKind::NAME => true,
395395
// Otherwise, the token shouldn't have pub(crate) before it
396396
_ => false,
@@ -1659,7 +1659,30 @@ mod modname {
16591659
16601660
// A macroed type
16611661
#[cfg(test)]
1662-
type MacroedType = i32;$0
1662+
type MacroedType = i32;
1663+
1664+
/// A module to move
1665+
mod module {}
1666+
1667+
/// An impl to move
1668+
impl NormalStruct {
1669+
/// A method
1670+
fn new() {}
1671+
}
1672+
1673+
/// A documented trait
1674+
trait DocTrait {
1675+
/// Inner function
1676+
fn doc() {}
1677+
}
1678+
1679+
/// An enum
1680+
enum DocumentedEnum {
1681+
/// A variant
1682+
A,
1683+
/// Another variant
1684+
B { x: i32, y: i32 }
1685+
}$0
16631686
",
16641687
r"
16651688
mod modname {
@@ -1719,6 +1742,29 @@ mod modname {
17191742
// A macroed type
17201743
#[cfg(test)]
17211744
pub(crate) type MacroedType = i32;
1745+
1746+
/// A module to move
1747+
pub(crate) mod module {}
1748+
1749+
/// An impl to move
1750+
impl NormalStruct {
1751+
/// A method
1752+
pub(crate) fn new() {}
1753+
}
1754+
1755+
/// A documented trait
1756+
pub(crate) trait DocTrait {
1757+
/// Inner function
1758+
fn doc() {}
1759+
}
1760+
1761+
/// An enum
1762+
pub(crate) enum DocumentedEnum {
1763+
/// A variant
1764+
A,
1765+
/// Another variant
1766+
B { x: i32, y: i32 }
1767+
}
17221768
}
17231769
",
17241770
)

0 commit comments

Comments
 (0)