Address comments

This commit is contained in:
Arthur Baars
2021-04-16 16:37:42 +02:00
parent 07726fd979
commit bf4f91e038
4 changed files with 25 additions and 18 deletions

View File

@@ -85,6 +85,21 @@ class MethodCall extends Call, TMethodCall {
*/
Expr getReceiver() { none() }
/**
* Holds if the receiver is `self` or there is no receiver, which has the same
* meaning as an explict `self`. For example:
*
* ```rb
* self.foo
* foo
* ```
*/
predicate receiverIsSelf() {
this.getReceiver() instanceof Self
or
not exists(this.getReceiver())
}
/**
* Gets the name of the method being called. For example, in:
*

View File

@@ -8,13 +8,13 @@ private import internal.TreeSitter
* A representation of a method.
*/
class Method extends TMethod {
/** Get a declaration of this module, if any. */
/** Gets a declaration of this module, if any. */
MethodBase getADeclaration() { result.getMethod() = this }
/** Get the name of this method */
/** Gets the name of this method */
string getName() { this = TInstanceMethod(_, result) }
/** Get the module in which this method is defined */
/** Gets the module in which this method is defined */
Module getModule() { this = TInstanceMethod(result, _) }
/** Gets a textual representation of this method. */

View File

@@ -8,22 +8,22 @@ private import internal.TreeSitter
* A representation of a run-time `module` or `class` value.
*/
class Module extends TModule {
/** Get a declaration of this module, if any. */
/** Gets a declaration of this module, if any. */
ModuleBase getADeclaration() { result.getModule() = this }
/** Get the super class of this module, if any. */
/** Gets the super class of this module, if any. */
Module getSuperClass() { result = getSuperClass(this) }
/** Get a method defined in this module by name. */
/** Gets a method defined in this module by name. */
Method getMethod(string name) { result.getName() = name and result.getModule() = this }
/** Look up a method in this module's ancestor chain. */
Method lookupMethod(string name) { result = lookupMethod(this, name) }
/** Get a `prepend`ed module. */
/** Gets a `prepend`ed module. */
Module getAPrependedModule() { result = getAPrependedModule(this) }
/** Get an `include`d module. */
/** Gets an `include`d module. */
Module getAnIncludedModule() { result = getAnIncludedModule(this) }
/** Gets a textual representation of this module. */

View File

@@ -67,11 +67,7 @@ private module Cached {
m = resolveScopeExpr(c.getReceiver())
or
m = enclosingModule(c).getModule() and
(
c.getReceiver() instanceof Self
or
not exists(c.getReceiver())
)
c.receiverIsSelf()
) and
result = resolveScopeExpr(c.getAnArgument())
)
@@ -85,11 +81,7 @@ private module Cached {
m = resolveScopeExpr(c.getReceiver())
or
m = enclosingModule(c).getModule() and
(
c.getReceiver() instanceof Self
or
not exists(c.getReceiver())
)
c.receiverIsSelf()
) and
result = resolveScopeExpr(c.getAnArgument())
)