diff options
Diffstat (limited to 'crates/ra_hir/src/semantics.rs')
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 2ad231d36..2707e422d 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -23,7 +23,7 @@ use crate::{ | |||
23 | semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, | 23 | semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, |
24 | source_analyzer::{resolve_hir_path, SourceAnalyzer}, | 24 | source_analyzer::{resolve_hir_path, SourceAnalyzer}, |
25 | AssocItem, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, Name, | 25 | AssocItem, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, Name, |
26 | Origin, Path, ScopeDef, StructField, Trait, Type, TypeParam, VariantDef, | 26 | Origin, Path, ScopeDef, StructField, Trait, Type, TypeParam, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | #[derive(Debug, Clone, PartialEq, Eq)] | 29 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -187,14 +187,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
187 | self.analyze(field.syntax()).resolve_record_field(self.db, field) | 187 | self.analyze(field.syntax()).resolve_record_field(self.db, field) |
188 | } | 188 | } |
189 | 189 | ||
190 | pub fn resolve_record_literal(&self, record_lit: &ast::RecordLit) -> Option<VariantDef> { | ||
191 | self.analyze(record_lit.syntax()).resolve_record_literal(self.db, record_lit) | ||
192 | } | ||
193 | |||
194 | pub fn resolve_record_pattern(&self, record_pat: &ast::RecordPat) -> Option<VariantDef> { | ||
195 | self.analyze(record_pat.syntax()).resolve_record_pattern(record_pat) | ||
196 | } | ||
197 | |||
198 | pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { | 190 | pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { |
199 | let sa = self.analyze(macro_call.syntax()); | 191 | let sa = self.analyze(macro_call.syntax()); |
200 | let macro_call = self.find_file(macro_call.syntax().clone()).with_value(macro_call); | 192 | let macro_call = self.find_file(macro_call.syntax().clone()).with_value(macro_call); |
@@ -212,6 +204,24 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
212 | // FIXME: use this instead? | 204 | // FIXME: use this instead? |
213 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; | 205 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; |
214 | 206 | ||
207 | pub fn record_literal_missing_fields( | ||
208 | &self, | ||
209 | literal: &ast::RecordLit, | ||
210 | ) -> Vec<(StructField, Type)> { | ||
211 | self.analyze(literal.syntax()) | ||
212 | .record_literal_missing_fields(self.db, literal) | ||
213 | .unwrap_or_default() | ||
214 | } | ||
215 | |||
216 | pub fn record_pattern_missing_fields( | ||
217 | &self, | ||
218 | pattern: &ast::RecordPat, | ||
219 | ) -> Vec<(StructField, Type)> { | ||
220 | self.analyze(pattern.syntax()) | ||
221 | .record_pattern_missing_fields(self.db, pattern) | ||
222 | .unwrap_or_default() | ||
223 | } | ||
224 | |||
215 | pub fn to_def<T: ToDef>(&self, src: &T) -> Option<T::Def> { | 225 | pub fn to_def<T: ToDef>(&self, src: &T) -> Option<T::Def> { |
216 | let src = self.find_file(src.syntax().clone()).with_value(src).cloned(); | 226 | let src = self.find_file(src.syntax().clone()).with_value(src).cloned(); |
217 | T::to_def(self, src) | 227 | T::to_def(self, src) |