Ruby: Rename getCanonicalEnclosing/Nested module

getCanonicalEnclosingModule -> getParentModule
getCanonicalNestedModule -> getNestedModule
This commit is contained in:
Asger F
2022-11-03 10:10:47 +01:00
parent bd2a065562
commit fe8945b5c9
2 changed files with 9 additions and 9 deletions

View File

@@ -151,24 +151,24 @@ class Module extends TModule {
/**
* Gets the enclosing module, as it appears in the qualified name of this module.
*
* For example, the canonical enclosing module of `A::B` is `A`, and `A` itself has no canonical enclosing module.
* For example, the parent module of `A::B` is `A`, and `A` itself has no parent module.
*/
pragma[nomagic]
Module getCanonicalEnclosingModule() { result.getQualifiedName() = this.getEnclosingModuleName() }
Module getParentModule() { result.getQualifiedName() = this.getEnclosingModuleName() }
/**
* Gets a module named `name` declared inside this one (not aliased), provided
* that such a module is defined or reopened in the current codebase.
*
* For example, for `A::B` the canonical nested module named `C` would be `A::B::C`.
* For example, for `A::B` the nested module named `C` would be `A::B::C`.
*
* Note that this is not the same as constant lookup. If `A::B::C` would resolve to a
* module whose qualified name is not `A::B::C`, then it will not be found by
* this predicate.
*/
pragma[nomagic]
Module getCanonicalNestedModule(string name) {
result.getCanonicalEnclosingModule() = this and
Module getNestedModule(string name) {
result.getParentModule() = this and
result.getOwnModuleName() = name
}
}

View File

@@ -927,7 +927,7 @@ class ModuleNode instanceof Module {
*
* For example, the canonical enclosing module of `A::B` is `A`, and `A` itself has no canonical enclosing module.
*/
ModuleNode getCanonicalEnclosingModule() { result = super.getCanonicalEnclosingModule() }
ModuleNode getCanonicalEnclosingModule() { result = super.getParentModule() }
/**
* Gets a module named `name` declared inside this one (not aliased), provided
@@ -939,7 +939,7 @@ class ModuleNode instanceof Module {
* module whose qualified name is not `A::B::C`, then it will not be found by
* this predicate.
*/
ModuleNode getCanonicalNestedModule(string name) { result = super.getCanonicalNestedModule(name) }
ModuleNode getCanonicalNestedModule(string name) { result = super.getNestedModule(name) }
}
/**
@@ -1152,7 +1152,7 @@ class ConstRef extends LocalSourceNode {
*/
predicate isPossiblyGlobal() {
exists(Module mod |
not exists(mod.getCanonicalEnclosingModule()) and
not exists(mod.getParentModule()) and
mod.getAnImmediateReference() = access
)
or
@@ -1237,7 +1237,7 @@ class ConstRef extends LocalSourceNode {
name = this.getName()
or
exists(Module mod |
this.getExactTarget() = mod.getCanonicalNestedModule(name) and
this.getExactTarget() = mod.getNestedModule(name) and
scope = MkExactLookup(mod)
)
}