mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
Document SemanticScope
This commit is contained in:
parent
3b52d3181a
commit
2c916bbc18
@ -697,6 +697,25 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode {
|
||||
node.ancestors().last().unwrap()
|
||||
}
|
||||
|
||||
/// `SemanticScope` encapsulates the notion of a scope (the set of visible
|
||||
/// names) at a particular program point.
|
||||
///
|
||||
/// It is a bit tricky, as scopes do not really exist inside the compiler.
|
||||
/// Rather, the compiler directly computes for each reference the definition it
|
||||
/// refers to. It might transiently compute the explicit scope map while doing
|
||||
/// so, but, generally, this is not something left after the analysis.
|
||||
///
|
||||
/// However, we do very much need explicit scopes for IDE purposes --
|
||||
/// completion, at its core, lists the contents of the current scope. Notion of
|
||||
/// scope is also useful to answer question like "what would be the meaning of
|
||||
/// this piece of code if we insert into this position?".
|
||||
///
|
||||
/// So `SemanticsScope` is constructed from a specific program point (a syntax
|
||||
/// node or just a raw offset) and provides access to the set of visible names
|
||||
/// in on a somewhat best-effort basis.
|
||||
///
|
||||
/// Note that if you are wondering "what this specific existing name means?",
|
||||
/// you'd better use the `resolve_` family of methods.
|
||||
#[derive(Debug)]
|
||||
pub struct SemanticsScope<'a> {
|
||||
pub db: &'a dyn HirDatabase,
|
||||
|
Loading…
Reference in New Issue
Block a user