Skip to content

Commit 3b35880

Browse files
committed
WIP
1 parent 25ae0e9 commit 3b35880

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

crates/ra_hir/src/semantics.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hash::FxHashMap;
77
use crate::{
88
db::HirDatabase, source_analyzer::ReferenceDescriptor, source_binder::ToDef, Function,
99
HirFileId, InFile, MacroDef, Module, Origin, PathResolution, SourceAnalyzer, SourceBinder,
10-
StructField, Type,
10+
StructField, Type, VariantDef,
1111
};
1212

1313
pub struct Semantics<'a, DB> {
@@ -145,6 +145,14 @@ impl<DB: HirDatabase> Semantics<'_, DB> {
145145
self.analyze(field.syntax().clone()).resolve_record_field(field)
146146
}
147147

148+
pub fn resolve_record_literal(&self, record_lit: &ast::RecordLit) -> Option<VariantDef> {
149+
self.analyze(record_lit.syntax().clone()).resolve_record_literal(record_lit)
150+
}
151+
152+
pub fn resolve_record_pattern(&self, record_pat: &ast::RecordPat) -> Option<VariantDef> {
153+
self.analyze(record_pat.syntax().clone()).resolve_record_pattern(record_pat)
154+
}
155+
148156
pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> {
149157
let sa = self.analyze(macro_call.syntax().clone());
150158
let macro_call = self.find_file(macro_call.syntax().clone()).with_value(macro_call);

crates/ra_ide/src/completion/complete_dot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
1616
_ => return,
1717
};
1818

19-
let receiver_ty = match ctx.analyzer.type_of(ctx.db, &dot_receiver) {
19+
let receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) {
2020
Some(ty) => ty,
2121
_ => return,
2222
};

crates/ra_ide/src/completion/complete_postfix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
2929
dot_receiver.syntax().text().to_string()
3030
};
3131

32-
let receiver_ty = match ctx.analyzer.type_of(ctx.db, &dot_receiver) {
32+
let receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) {
3333
Some(it) => it,
3434
None => return,
3535
};

crates/ra_ide/src/completion/complete_record_literal.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ use crate::completion::{CompletionContext, Completions};
55
/// Complete fields in fields literals.
66
pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionContext) {
77
let (ty, variant) = match ctx.record_lit_syntax.as_ref().and_then(|it| {
8-
Some((
9-
ctx.analyzer.type_of(ctx.db, &it.clone().into())?,
10-
ctx.analyzer.resolve_record_literal(it)?,
11-
))
8+
Some((ctx.sema.type_of_expr(&it.clone().into())?, ctx.sema.resolve_record_literal(it)?))
129
}) {
1310
Some(it) => it,
1411
_ => return,

crates/ra_ide/src/completion/complete_record_pattern.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ use crate::completion::{CompletionContext, Completions};
44

55
pub(super) fn complete_record_pattern(acc: &mut Completions, ctx: &CompletionContext) {
66
let (ty, variant) = match ctx.record_lit_pat.as_ref().and_then(|it| {
7-
Some((
8-
ctx.analyzer.type_of_pat(ctx.db, &it.clone().into())?,
9-
ctx.analyzer.resolve_record_pattern(it)?,
10-
))
7+
Some((ctx.sema.type_of_pat(&it.clone().into())?, ctx.sema.resolve_record_pattern(it)?))
118
}) {
129
Some(it) => it,
1310
_ => return,

crates/ra_ide/src/completion/completion_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ra_db::SourceDatabase;
55
use ra_ide_db::RootDatabase;
66
use ra_syntax::{
77
algo::{find_covering_element, find_node_at_offset},
8-
ast, AstNode, SourceFile,
8+
ast, AstNode, Parse, SourceFile,
99
SyntaxKind::*,
1010
SyntaxNode, SyntaxToken, TextRange, TextUnit,
1111
};

0 commit comments

Comments
 (0)