mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
AST: make some classes instance of Scope
This commit is contained in:
@@ -4,7 +4,7 @@ private import internal.AST
|
||||
private import internal.TreeSitter
|
||||
|
||||
/** A callable. */
|
||||
class Callable extends Expr, TCallable {
|
||||
class Callable extends Expr, Scope, TCallable {
|
||||
/** Gets the number of parameters of this callable. */
|
||||
final int getNumberOfParameters() { result = count(this.getAParameter()) }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ private import internal.TreeSitter
|
||||
/**
|
||||
* The base class for classes, singleton classes, and modules.
|
||||
*/
|
||||
class ModuleBase extends BodyStmt, TModuleBase {
|
||||
class ModuleBase extends BodyStmt, Scope, TModuleBase {
|
||||
/** Gets a method defined in this module/class. */
|
||||
MethodBase getAMethod() { result = this.getAStmt() }
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ class Scope extends AstNode, TScopeType {
|
||||
/** Gets the scope in which this scope is nested, if any. */
|
||||
Scope getOuterScope() { toGenerated(result) = range.getOuterScope() }
|
||||
|
||||
/** Gets the scope in which this scope is nested, if any. */
|
||||
AstNode getADescendant() { range = scopeOf(toGenerated(result)) }
|
||||
|
||||
/** Gets a variable that is declared in this scope. */
|
||||
final Variable getAVariable() { result.getDeclaringScope() = this }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user