Don't suggest enum variant if name_ref start with ASCII lowercase letter
This commit is contained in:
parent
7d716cbeb9
commit
0ed85beb15
@ -41,6 +41,10 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext) -> O
|
||||
}
|
||||
|
||||
let name_ref = path.segment()?.name_ref()?;
|
||||
if name_ref.text().as_str().chars().next()?.is_ascii_lowercase() {
|
||||
// No need to generate anything if the name starts with a lowercase letter
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Some(hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Enum(e)))) =
|
||||
ctx.sema.resolve_path(&path.qualifier()?)
|
||||
@ -146,6 +150,21 @@ fn main() {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn not_applicable_for_lowercase() {
|
||||
check_assist_not_applicable(
|
||||
generate_enum_variant,
|
||||
r"
|
||||
enum Foo {
|
||||
Bar,
|
||||
}
|
||||
fn main() {
|
||||
Foo::new$0
|
||||
}
|
||||
",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn indentation_level_is_correct() {
|
||||
check_assist(
|
||||
|
Loading…
Reference in New Issue
Block a user