for most nodes this is also /// what obtains for scoping. However, guards are different. The scope after /// the guard else must hop into the innermoset scope of the guard condition. virtual NullablePtr<const ASTScopeImpl> getLookupParent() const
the ASTScopeImpl class ontology, which /// describes the scopes that exist within a Swift AST. /// /// Each scope has four basic functions: printing for debugging, creation of /// itself and its children, obtaining its SourceRange (for lookup), and looking /// up names accessible from that scope. /// /// Invariants: /// a child's source range is a subset (proper or improper) of its parent's, /// children are ordered by source range, and do not overlap, /// all the names visible within a parent are visible within the child, unless /// the nesting is illegal. For instance, a protocol nested inside of a class /// does not get to see the symbols in the class or its ancestors. /// //===----------------------------------------------------------------------===//
the ASTScopeImpl class ontology, which /// describes the scopes that exist within a Swift AST. /// /// Each scope has four basic functions: printing for debugging, creation of /// itself and its children, obtaining its SourceRange (for lookup), and looking /// up names accessible from that scope. /// /// Invariants: /// a child's source range is a subset (proper or improper) of its parent's, /// children are ordered by source range, and do not overlap, /// all the names visible within a parent are visible within the child, unless /// the nesting is illegal. For instance, a protocol nested inside of a class /// does not get to see the symbols in the class or its ancestors. /// //===----------------------------------------------------------------------===// MJC"45"454DPQFI
public enum LookupResult { /// Scope and the names that matched lookup. case fromScope(Syntax, withNames: [LookupName]) /// Indicates where to perform member lookup. case lookForMembers(in: Syntax) /// Indicates to lookup generic parameters of extended type. /// /// ### Example /// ```swift /// extension Foo { /// func bar() { /// let a = A() // <-- lookup here /// } /// } /// ``` case lookForGenericParameters(of: ExtensionDeclSyntax) /// Indicates this closure expression could introduce dollar identi fi ers. /// /// ### Example /// ```swift /// func foo() { /// let a = { /// $0 // <-- lookup here /// } /// } /// ``` case lookForImplicitClosureParameters(ClosureExprSyntax)
with: config) { switch result { case .lookInMembers(let typeSyntax): // Hand off to qualified lookup let memberResults = typeSyntax.qualifiedLookup("area", in: sourceFile) // ... process memberResults default: // ... process unqualified results } }
<(4P$>4XJGU-FYJDBM-PPLVQBOFXMFYJDBMOBNFMPPLVQMJCSBSZ w IUUQTGPSVNTTXJGUPSHUHTPDTXJGUMFYJDBMMPPLVQBOFXMFYJDBMOBNFMPPLVQMJCSBSZ w <(4P$>2VBMJ fi FE/BNF-PPLVQGPSTXJGUTZOUBY w IUUQTGPSVNTTXJGUPSHUHTPDRVBMJ fi FEOBNFMPPLVQGPSTXJGUTZOUBY