mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Ruby: add Module.getNamespaceOrTopLevel
This commit is contained in:
@@ -241,6 +241,14 @@ class ModuleBase extends BodyStmt, Scope, TModuleBase {
|
||||
* Does not include the `self` variable from any of the methods in the module.
|
||||
*/
|
||||
SelfVariable getModuleSelfVariable() { result.getDeclaringScope() = this }
|
||||
|
||||
/** Gets the nearest enclosing `Namespace` or `Toplevel`, possibly this module itself. */
|
||||
Namespace getNamespaceOrToplevel() {
|
||||
result = this
|
||||
or
|
||||
not this instanceof Namespace and
|
||||
result = this.getEnclosingModule().getNamespaceOrToplevel()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user