@@ -697,6 +697,25 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode {
697697 node. ancestors ( ) . last ( ) . unwrap ( )
698698}
699699
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. Notion of
710+ /// scope is also useful to answer question like "what would be the meaning of
711+ /// this piece of code if we insert 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+ /// in on a somewhat best-effort basis.
716+ ///
717+ /// Note that if you are wondering "what this specific existing name means?",
718+ /// you'd better use the `resolve_` family of methods.
700719#[ derive( Debug ) ]
701720pub struct SemanticsScope < ' a > {
702721 pub db : & ' a dyn HirDatabase ,
0 commit comments