Give TypeInfo fields and methods more appropriate names
This commit is contained in:
parent
8afa2722b2
commit
b96f1adf5c
30 changed files with 76 additions and 74 deletions
|
|
@ -14,7 +14,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
};
|
||||
|
||||
let receiver_ty = match ctx.sema.type_of_expr(dot_receiver) {
|
||||
Some(ty) => ty.ty,
|
||||
Some(ty) => ty.original,
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option<ImportAs
|
|||
if let Some(dot_receiver) = ctx.dot_receiver() {
|
||||
ImportAssets::for_fuzzy_method_call(
|
||||
current_module,
|
||||
ctx.sema.type_of_expr(dot_receiver)?.ty,
|
||||
ctx.sema.type_of_expr(dot_receiver)?.original,
|
||||
fuzzy_name,
|
||||
dot_receiver.syntax().clone(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
let receiver_text = get_receiver_text(dot_receiver, receiver_is_ambiguous_float_literal);
|
||||
|
||||
let receiver_ty = match ctx.sema.type_of_expr(dot_receiver) {
|
||||
Some(it) => it.ty,
|
||||
Some(it) => it.original,
|
||||
None => return,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
Some(ImmediateLocation::RecordExpr(record_expr)) => {
|
||||
let ty = ctx.sema.type_of_expr(&Expr::RecordExpr(record_expr.clone()));
|
||||
let default_trait = FamousDefs(&ctx.sema, ctx.krate).core_default_Default();
|
||||
let impl_default_trait = default_trait
|
||||
.zip(ty)
|
||||
.map_or(false, |(default_trait, ty)| ty.ty.impls_trait(ctx.db, default_trait, &[]));
|
||||
let impl_default_trait = default_trait.zip(ty).map_or(false, |(default_trait, ty)| {
|
||||
ty.original.impls_trait(ctx.db, default_trait, &[])
|
||||
});
|
||||
|
||||
let missing_fields = ctx.sema.record_literal_missing_fields(record_expr);
|
||||
if impl_default_trait && !missing_fields.is_empty() {
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ impl<'a> CompletionContext<'a> {
|
|||
let ty = it.pat()
|
||||
.and_then(|pat| self.sema.type_of_pat(&pat))
|
||||
.or_else(|| it.initializer().and_then(|it| self.sema.type_of_expr(&it)))
|
||||
.map(TypeInfo::ty);
|
||||
.map(TypeInfo::original);
|
||||
let name = if let Some(ast::Pat::IdentPat(ident)) = it.pat() {
|
||||
ident.name().map(NameOrNameRef::Name)
|
||||
} else {
|
||||
|
|
@ -497,13 +497,13 @@ impl<'a> CompletionContext<'a> {
|
|||
ast::RecordExprField(it) => {
|
||||
cov_mark::hit!(expected_type_struct_field_with_leading_char);
|
||||
(
|
||||
it.expr().as_ref().and_then(|e| self.sema.type_of_expr(e)).map(TypeInfo::ty),
|
||||
it.expr().as_ref().and_then(|e| self.sema.type_of_expr(e)).map(TypeInfo::original),
|
||||
it.field_name().map(NameOrNameRef::NameRef),
|
||||
)
|
||||
},
|
||||
ast::MatchExpr(it) => {
|
||||
cov_mark::hit!(expected_type_match_arm_without_leading_char);
|
||||
let ty = it.expr().and_then(|e| self.sema.type_of_expr(&e)).map(TypeInfo::ty);
|
||||
let ty = it.expr().and_then(|e| self.sema.type_of_expr(&e)).map(TypeInfo::original);
|
||||
(ty, None)
|
||||
},
|
||||
ast::IfExpr(it) => {
|
||||
|
|
@ -511,13 +511,13 @@ impl<'a> CompletionContext<'a> {
|
|||
let ty = it.condition()
|
||||
.and_then(|cond| cond.expr())
|
||||
.and_then(|e| self.sema.type_of_expr(&e))
|
||||
.map(TypeInfo::ty);
|
||||
.map(TypeInfo::original);
|
||||
(ty, None)
|
||||
},
|
||||
ast::IdentPat(it) => {
|
||||
cov_mark::hit!(expected_type_if_let_with_leading_char);
|
||||
cov_mark::hit!(expected_type_match_arm_with_leading_char);
|
||||
let ty = self.sema.type_of_pat(&ast::Pat::from(it)).map(TypeInfo::ty);
|
||||
let ty = self.sema.type_of_pat(&ast::Pat::from(it)).map(TypeInfo::original);
|
||||
(ty, None)
|
||||
},
|
||||
ast::Fn(it) => {
|
||||
|
|
@ -528,7 +528,7 @@ impl<'a> CompletionContext<'a> {
|
|||
},
|
||||
ast::ClosureExpr(it) => {
|
||||
let ty = self.sema.type_of_expr(&it.into());
|
||||
ty.and_then(|ty| ty.ty.as_callable(self.db))
|
||||
ty.and_then(|ty| ty.original.as_callable(self.db))
|
||||
.map(|c| (Some(c.return_type()), None))
|
||||
.unwrap_or((None, None))
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue