|
14 | 14 | // describes the scopes that exist within a Swift AST.
|
15 | 15 | //
|
16 | 16 | //===----------------------------------------------------------------------===//
|
17 |
| -#ifndef SWIFT_AST_SCOPE_MAP_H |
18 |
| -#define SWIFT_AST_SCOPE_MAP_H |
| 17 | +#ifndef SWIFT_AST_AST_SCOPE_H |
| 18 | +#define SWIFT_AST_AST_SCOPE_H |
19 | 19 |
|
20 | 20 | #include "swift/AST/ASTNode.h"
|
21 | 21 | #include "swift/Basic/LLVM.h"
|
@@ -116,6 +116,32 @@ enum class ASTScopeKind : uint8_t {
|
116 | 116 | TopLevelCode,
|
117 | 117 | };
|
118 | 118 |
|
| 119 | +/// Describes a lexical scope within a source file. |
| 120 | +/// |
| 121 | +/// Each \c ASTScope is a node within a tree that describes all of the lexical |
| 122 | +/// scopes within a particular source range. The root of this scope tree is |
| 123 | +/// always a \c SourceFile node, and the tree covers the entire source file. |
| 124 | +/// The children of a particular node are the lexical scopes immediately |
| 125 | +/// nested within that node, and have source ranges that are enclosed within |
| 126 | +/// the source range of their parent node. At the leaves are lexical scopes |
| 127 | +/// that cannot be subdivided further. |
| 128 | +/// |
| 129 | +/// The tree provides source-location-based query operations, allowing one to |
| 130 | +/// find the innermost scope that contains a given source location. Navigation |
| 131 | +/// to parent nodes from that scope allows one to walk the lexically enclosing |
| 132 | +/// scopes outward to the source file. Given a scope, one can also query the |
| 133 | +/// associated \c DeclContext for additional contextual information. |
| 134 | +/// |
| 135 | +/// As an implementation detail, the scope tree is lazily constructed as it is |
| 136 | +/// queried, and only the relevant subtrees (i.e., trees whose source ranges |
| 137 | +/// enclose the queried source location or whose children were explicitly |
| 138 | +/// requested by the client) will be constructed. The \c expandAll() operation |
| 139 | +/// can be used to fully-expand the tree, constructing all of its nodes, but |
| 140 | +/// should only be used for testing or debugging purposes, e.g., via the |
| 141 | +/// frontend option |
| 142 | +/// \code |
| 143 | +/// -dump-scope-maps expanded |
| 144 | +/// \endcode |
119 | 145 | class ASTScope {
|
120 | 146 | /// The kind of scope this represents.
|
121 | 147 | ASTScopeKind kind;
|
@@ -547,4 +573,4 @@ class ASTScope {
|
547 | 573 |
|
548 | 574 | }
|
549 | 575 |
|
550 |
| -#endif // SWIFT_BASIC_SOURCE_RANGE_MAP_H |
| 576 | +#endif // SWIFT_AST_AST_SCOPE_H |
0 commit comments