mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #9404 from MathiasVP/swift-get-enclosing-function
Swift: Add `getEnclosingFunction` to `AstNode`
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
|
||||
private import codeql.swift.generated.AstNode
|
||||
private import codeql.swift.elements.decl.AbstractFunctionDecl
|
||||
private import codeql.swift.generated.GetImmediateParent
|
||||
|
||||
class AstNode extends AstNodeBase { }
|
||||
private Element getEnclosingFunctionStep(Element e) {
|
||||
not e instanceof AbstractFunctionDecl and
|
||||
result = getImmediateParent(e)
|
||||
}
|
||||
|
||||
cached
|
||||
private AbstractFunctionDecl getEnclosingFunctionCached(AstNode ast) {
|
||||
result = getEnclosingFunctionStep*(getImmediateParent(ast))
|
||||
}
|
||||
|
||||
class AstNode extends AstNodeBase {
|
||||
final AbstractFunctionDecl getEnclosingFunction() { result = getEnclosingFunctionCached(this) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user