fix: Show parameter hints unconditionally for logical not expressions

This commit is contained in:
Lukas Wirth 2021-11-27 19:12:47 +01:00
parent 82abe04931
commit 76022bfd60

View File

@ -1,11 +1,10 @@
use either::Either;
use hir::{known, Callable, HasVisibility, HirDisplay, Semantics, TypeInfo};
use ide_db::RootDatabase;
use ide_db::{base_db::FileRange, helpers::FamousDefs};
use ide_db::{base_db::FileRange, helpers::FamousDefs, RootDatabase};
use itertools::Itertools;
use stdx::to_lower_snake_case;
use syntax::{
ast::{self, AstNode, HasArgList, HasName},
ast::{self, AstNode, HasArgList, HasName, UnaryOp},
match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T,
};
@ -421,6 +420,10 @@ fn should_hide_param_name_hint(
return true;
}
if matches!(argument, ast::Expr::PrefixExpr(prefix) if prefix.op_kind() == Some(UnaryOp::Not)) {
return false;
}
let fn_name = match callable.kind() {
hir::CallableKind::Function(it) => Some(it.name(sema.db).to_smol_str()),
_ => None,
@ -868,7 +871,8 @@ fn non_ident_pat((a, b): (u32, u32)) {}
fn main() {
const PARAM: u32 = 0;
foo(PARAM);
foo(!PARAM);
// ^^^^^^ param
check("");
map(0);