AST: rename Class/Module to ClassDefinition/ModuleDefinition

This commit is contained in:
Arthur Baars
2021-03-26 16:00:24 +01:00
parent aad5d133d0
commit eebbc7e505
11 changed files with 131 additions and 125 deletions

View File

@@ -14,16 +14,16 @@ class ModuleBase extends BodyStmt, TModuleBase {
MethodBase getMethod(string name) { result = this.getAMethod() and result.getName() = name }
/** Gets a class defined in this module/class. */
Class getAClass() { result = this.getAStmt() }
ClassDefinition getAClass() { result = this.getAStmt() }
/** Gets the class named `name` in this module/class, if any. */
Class getClass(string name) { result = this.getAClass() and result.getName() = name }
ClassDefinition getClass(string name) { result = this.getAClass() and result.getName() = name }
/** Gets a module defined in this module/class. */
Module getAModule() { result = this.getAStmt() }
ModuleDefinition getAModule() { result = this.getAStmt() }
/** Gets the module named `name` in this module/class, if any. */
Module getModule(string name) { result = this.getAModule() and result.getName() = name }
ModuleDefinition getModule(string name) { result = this.getAModule() and result.getName() = name }
}
/**
@@ -150,12 +150,12 @@ class Namespace extends ModuleBase, ConstantWriteAccess, TNamespace {
* end
* ```
*/
class Class extends Namespace, TClass {
class ClassDefinition extends Namespace, TClass {
private Generated::Class g;
Class() { this = TClass(g) }
ClassDefinition() { this = TClass(g) }
final override string getAPrimaryQlClass() { result = "Class" }
final override string getAPrimaryQlClass() { result = "ClassDefinition" }
/**
* Gets the `Expr` used as the superclass in the class definition, if any.
@@ -214,7 +214,7 @@ class SingletonClass extends ModuleBase, TSingletonClass {
SingletonClass() { this = TSingletonClass(g) }
final override string getAPrimaryQlClass() { result = "Class" }
final override string getAPrimaryQlClass() { result = "ClassDefinition" }
/**
* Gets the expression resulting in the object on which the singleton class
@@ -249,7 +249,7 @@ class SingletonClass extends ModuleBase, TSingletonClass {
* N.B. this class represents a single instance of a module definition. In the
* following example, classes `Bar` and `Baz` are both defined in the module
* `Foo`, but in two syntactically distinct definitions, meaning that there
* will be two instances of `Module` in the database.
* will be two instances of `ModuleDefinition` in the database.
*
* ```rb
* module Foo
@@ -261,12 +261,12 @@ class SingletonClass extends ModuleBase, TSingletonClass {
* end
* ```
*/
class Module extends Namespace, TModule {
class ModuleDefinition extends Namespace, TModule {
private Generated::Module g;
Module() { this = TModule(g) }
ModuleDefinition() { this = TModule(g) }
final override string getAPrimaryQlClass() { result = "Module" }
final override string getAPrimaryQlClass() { result = "ModuleDefinition" }
final override string getName() {
result = g.getName().(Generated::Token).getValue() or

View File

@@ -598,7 +598,7 @@ module Trees {
private class CharacterTree extends LeafTree, CharacterLiteral { }
private class ClassTree extends BodyStmtPreOrderTree, Class {
private class ClassTree extends BodyStmtPreOrderTree, ClassDefinition {
/** Gets the `i`th child in the body of this block. */
final override AstNode getBodyChild(int i, boolean rescuable) {
result = this.getScopeExpr() and i = 0 and rescuable = false
@@ -673,8 +673,8 @@ module Trees {
private class ConstantAccessTree extends PostOrderTree, ConstantAccess {
ConstantAccessTree() {
not this instanceof Class and
not this instanceof Module
not this instanceof ClassDefinition and
not this instanceof ModuleDefinition
}
final override predicate propagatesAbnormal(AstNode child) { child = this.getScopeExpr() }
@@ -934,7 +934,7 @@ module Trees {
}
}
private class ModuleTree extends BodyStmtPreOrderTree, Module {
private class ModuleTree extends BodyStmtPreOrderTree, ModuleDefinition {
/** Gets the `i`th child in the body of this block. */
final override AstNode getBodyChild(int i, boolean rescuable) {
result = this.getScopeExpr() and i = 0 and rescuable = false