mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Document SemanticScope
This commit is contained in:
parent
3b52d3181a
commit
2c916bbc18
1 changed files with 19 additions and 0 deletions
|
@ -697,6 +697,25 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode {
|
||||||
node.ancestors().last().unwrap()
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct SemanticsScope<'a> {
|
pub struct SemanticsScope<'a> {
|
||||||
pub db: &'a dyn HirDatabase,
|
pub db: &'a dyn HirDatabase,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue