AST: make some classes instance of Scope

This commit is contained in:
Arthur Baars
2021-03-26 16:01:11 +01:00
parent eebbc7e505
commit ea9afcd4e1
3 changed files with 5 additions and 2 deletions

View File

@@ -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()) }

View File

@@ -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() }

View File

@@ -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 }