diff options
Diffstat (limited to 'crates/hir/src/semantics.rs')
-rw-r--r-- | crates/hir/src/semantics.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 1594d4f0f..c61a430e1 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -207,8 +207,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
207 | self.imp.resolve_record_field(field) | 207 | self.imp.resolve_record_field(field) |
208 | } | 208 | } |
209 | 209 | ||
210 | pub fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> { | 210 | pub fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<Field> { |
211 | self.imp.resolve_record_field_pat(field) | 211 | self.imp.resolve_record_pat_field(field) |
212 | } | 212 | } |
213 | 213 | ||
214 | pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { | 214 | pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { |
@@ -433,8 +433,8 @@ impl<'db> SemanticsImpl<'db> { | |||
433 | self.analyze(field.syntax()).resolve_record_field(self.db, field) | 433 | self.analyze(field.syntax()).resolve_record_field(self.db, field) |
434 | } | 434 | } |
435 | 435 | ||
436 | fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> { | 436 | fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<Field> { |
437 | self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) | 437 | self.analyze(field.syntax()).resolve_record_pat_field(self.db, field) |
438 | } | 438 | } |
439 | 439 | ||
440 | fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { | 440 | fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { |
@@ -697,6 +697,25 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode { | |||
697 | node.ancestors().last().unwrap() | 697 | node.ancestors().last().unwrap() |
698 | } | 698 | } |
699 | 699 | ||
700 | /// `SemanticScope` encapsulates the notion of a scope (the set of visible | ||
701 | /// names) at a particular program point. | ||
702 | /// | ||
703 | /// It is a bit tricky, as scopes do not really exist inside the compiler. | ||
704 | /// Rather, the compiler directly computes for each reference the definition it | ||
705 | /// refers to. It might transiently compute the explicit scope map while doing | ||
706 | /// so, but, generally, this is not something left after the analysis. | ||
707 | /// | ||
708 | /// However, we do very much need explicit scopes for IDE purposes -- | ||
709 | /// completion, at its core, lists the contents of the current scope. The notion | ||
710 | /// of scope is also useful to answer questions like "what would be the meaning | ||
711 | /// of this piece of code if we inserted it into this position?". | ||
712 | /// | ||
713 | /// So `SemanticsScope` is constructed from a specific program point (a syntax | ||
714 | /// node or just a raw offset) and provides access to the set of visible names | ||
715 | /// on a somewhat best-effort basis. | ||
716 | /// | ||
717 | /// Note that if you are wondering "what does this specific existing name mean?", | ||
718 | /// you'd better use the `resolve_` family of methods. | ||
700 | #[derive(Debug)] | 719 | #[derive(Debug)] |
701 | pub struct SemanticsScope<'a> { | 720 | pub struct SemanticsScope<'a> { |
702 | pub db: &'a dyn HirDatabase, | 721 | pub db: &'a dyn HirDatabase, |