aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/semantics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/semantics.rs')
-rw-r--r--crates/ra_hir/src/semantics.rs49
1 files changed, 26 insertions, 23 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 1436b1afe..307b336f2 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -209,11 +209,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
209 self.imp.resolve_field(field) 209 self.imp.resolve_field(field)
210 } 210 }
211 211
212 pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { 212 pub fn resolve_record_field(
213 &self,
214 field: &ast::RecordExprField,
215 ) -> Option<(Field, Option<Local>)> {
213 self.imp.resolve_record_field(field) 216 self.imp.resolve_record_field(field)
214 } 217 }
215 218
216 pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<Field> { 219 pub fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> {
217 self.imp.resolve_record_field_pat(field) 220 self.imp.resolve_record_field_pat(field)
218 } 221 }
219 222
@@ -225,7 +228,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
225 self.imp.resolve_path(path) 228 self.imp.resolve_path(path)
226 } 229 }
227 230
228 pub fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantDef> { 231 pub fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantDef> {
229 self.imp.resolve_variant(record_lit).map(VariantDef::from) 232 self.imp.resolve_variant(record_lit).map(VariantDef::from)
230 } 233 }
231 234
@@ -233,14 +236,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
233 self.imp.lower_path(path) 236 self.imp.lower_path(path)
234 } 237 }
235 238
236 pub fn resolve_bind_pat_to_const(&self, pat: &ast::BindPat) -> Option<ModuleDef> { 239 pub fn resolve_bind_pat_to_const(&self, pat: &ast::IdentPat) -> Option<ModuleDef> {
237 self.imp.resolve_bind_pat_to_const(pat) 240 self.imp.resolve_bind_pat_to_const(pat)
238 } 241 }
239 242
240 // FIXME: use this instead? 243 // FIXME: use this instead?
241 // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; 244 // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>;
242 245
243 pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { 246 pub fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
244 self.imp.record_literal_missing_fields(literal) 247 self.imp.record_literal_missing_fields(literal)
245 } 248 }
246 249
@@ -422,11 +425,11 @@ impl<'db> SemanticsImpl<'db> {
422 self.analyze(field.syntax()).resolve_field(self.db, field) 425 self.analyze(field.syntax()).resolve_field(self.db, field)
423 } 426 }
424 427
425 fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { 428 fn resolve_record_field(&self, field: &ast::RecordExprField) -> Option<(Field, Option<Local>)> {
426 self.analyze(field.syntax()).resolve_record_field(self.db, field) 429 self.analyze(field.syntax()).resolve_record_field(self.db, field)
427 } 430 }
428 431
429 fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<Field> { 432 fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> {
430 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) 433 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field)
431 } 434 }
432 435
@@ -440,7 +443,7 @@ impl<'db> SemanticsImpl<'db> {
440 self.analyze(path.syntax()).resolve_path(self.db, path) 443 self.analyze(path.syntax()).resolve_path(self.db, path)
441 } 444 }
442 445
443 fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantId> { 446 fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantId> {
444 self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) 447 self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit)
445 } 448 }
446 449
@@ -449,11 +452,11 @@ impl<'db> SemanticsImpl<'db> {
449 Path::from_src(path.clone(), &Hygiene::new(self.db.upcast(), src.file_id.into())) 452 Path::from_src(path.clone(), &Hygiene::new(self.db.upcast(), src.file_id.into()))
450 } 453 }
451 454
452 fn resolve_bind_pat_to_const(&self, pat: &ast::BindPat) -> Option<ModuleDef> { 455 fn resolve_bind_pat_to_const(&self, pat: &ast::IdentPat) -> Option<ModuleDef> {
453 self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) 456 self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat)
454 } 457 }
455 458
456 fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { 459 fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
457 self.analyze(literal.syntax()) 460 self.analyze(literal.syntax())
458 .record_literal_missing_fields(self.db, literal) 461 .record_literal_missing_fields(self.db, literal)
459 .unwrap_or_default() 462 .unwrap_or_default()
@@ -577,21 +580,21 @@ macro_rules! to_def_impls {
577 580
578to_def_impls![ 581to_def_impls![
579 (crate::Module, ast::Module, module_to_def), 582 (crate::Module, ast::Module, module_to_def),
580 (crate::Struct, ast::StructDef, struct_to_def), 583 (crate::Struct, ast::Struct, struct_to_def),
581 (crate::Enum, ast::EnumDef, enum_to_def), 584 (crate::Enum, ast::Enum, enum_to_def),
582 (crate::Union, ast::UnionDef, union_to_def), 585 (crate::Union, ast::Union, union_to_def),
583 (crate::Trait, ast::TraitDef, trait_to_def), 586 (crate::Trait, ast::Trait, trait_to_def),
584 (crate::ImplDef, ast::ImplDef, impl_to_def), 587 (crate::ImplDef, ast::Impl, impl_to_def),
585 (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), 588 (crate::TypeAlias, ast::TypeAlias, type_alias_to_def),
586 (crate::Const, ast::ConstDef, const_to_def), 589 (crate::Const, ast::Const, const_to_def),
587 (crate::Static, ast::StaticDef, static_to_def), 590 (crate::Static, ast::Static, static_to_def),
588 (crate::Function, ast::FnDef, fn_to_def), 591 (crate::Function, ast::Fn, fn_to_def),
589 (crate::Field, ast::RecordFieldDef, record_field_to_def), 592 (crate::Field, ast::RecordField, record_field_to_def),
590 (crate::Field, ast::TupleFieldDef, tuple_field_to_def), 593 (crate::Field, ast::TupleField, tuple_field_to_def),
591 (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def), 594 (crate::EnumVariant, ast::Variant, enum_variant_to_def),
592 (crate::TypeParam, ast::TypeParam, type_param_to_def), 595 (crate::TypeParam, ast::TypeParam, type_param_to_def),
593 (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros 596 (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros
594 (crate::Local, ast::BindPat, bind_pat_to_def), 597 (crate::Local, ast::IdentPat, bind_pat_to_def),
595]; 598];
596 599
597fn find_root(node: &SyntaxNode) -> SyntaxNode { 600fn find_root(node: &SyntaxNode) -> SyntaxNode {