mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Swift: move getName to Callable (hand-written)
Now that getStaticTarget returns a Callable.
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
private import codeql.swift.generated.Callable
|
||||
private import codeql.swift.elements.AstNode
|
||||
private import codeql.swift.elements.decl.Decl
|
||||
|
||||
class Callable extends Generated::Callable, AstNode { }
|
||||
class Callable extends Generated::Callable, AstNode {
|
||||
/**
|
||||
* Holds if this Callable is a function named `funcName`.
|
||||
*/
|
||||
predicate hasName(string funcName) { this.getName() = funcName }
|
||||
|
||||
/**
|
||||
* Holds if this Callable is a function named `funcName` defined in a module
|
||||
* called `moduleName`.
|
||||
*/
|
||||
predicate hasName(string moduleName, string funcName) {
|
||||
this.hasName(funcName) and
|
||||
this.(Decl).getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
private import codeql.swift.generated.decl.AbstractFunctionDecl
|
||||
private import codeql.swift.elements.decl.MethodDecl
|
||||
private import codeql.swift.elements.Callable
|
||||
|
||||
/**
|
||||
* A function.
|
||||
*/
|
||||
class AbstractFunctionDecl extends Generated::AbstractFunctionDecl {
|
||||
class AbstractFunctionDecl extends Generated::AbstractFunctionDecl, Callable {
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName`.
|
||||
*/
|
||||
predicate hasName(string funcName) { this.getName() = funcName }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -177,12 +177,13 @@ class ParamDecl(VarDecl):
|
||||
""")
|
||||
|
||||
class Callable(Element):
|
||||
name: optional[string] | doc("name of this Callable")
|
||||
self_param: optional[ParamDecl] | child
|
||||
params: list[ParamDecl] | child
|
||||
body: optional["BraceStmt"] | child | desc("The body is absent within protocol declarations.")
|
||||
|
||||
class AbstractFunctionDecl(GenericContext, ValueDecl, Callable):
|
||||
name: string | doc("name of this function")
|
||||
pass
|
||||
|
||||
class EnumElementDecl(ValueDecl):
|
||||
name: string
|
||||
|
||||
Reference in New Issue
Block a user