Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d78731

Browse files
committed
JS: rename getNamespaceId to getClosureNamespace
1 parent 5502627 commit 8d78731

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

javascript/ql/src/semmle/javascript/Closure.qll

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ module Closure {
3838
Expr getAnArgument() { result = getArgument(_) }
3939
}
4040

41-
abstract private class GoogNamespaceRef extends ExprOrStmt {
42-
abstract string getNamespaceId();
43-
}
41+
abstract private class GoogNamespaceRef extends ExprOrStmt { abstract string getClosureNamespace(); }
4442

4543
/**
4644
* A call to `goog.provide`.
@@ -49,7 +47,7 @@ module Closure {
4947
GoogProvide() { getFunctionName() = "provide" }
5048

5149
/** Gets the identifier of the namespace created by this call. */
52-
override string getNamespaceId() { result = getArgument(0).getStringValue() }
50+
override string getClosureNamespace() { result = getArgument(0).getStringValue() }
5351
}
5452

5553
/**
@@ -59,7 +57,7 @@ module Closure {
5957
GoogRequire() { getFunctionName() = "require" }
6058

6159
/** Gets the identifier of the namespace imported by this call. */
62-
override string getNamespaceId() { result = getArgument(0).getStringValue() }
60+
override string getClosureNamespace() { result = getArgument(0).getStringValue() }
6361
}
6462

6563
private class GoogRequireImport extends GoogRequire, Import {
@@ -80,7 +78,7 @@ module Closure {
8078
}
8179

8280
/** Gets the identifier of the namespace imported by this call. */
83-
override string getNamespaceId() { result = getArgument(0).getStringValue() }
81+
override string getClosureNamespace() { result = getArgument(0).getStringValue() }
8482
}
8583

8684
/**
@@ -97,12 +95,12 @@ module Closure {
9795
/**
9896
* Gets the namespace of this module.
9997
*/
100-
string getNamespaceId() { result = getModuleDeclaration().getNamespaceId() }
98+
string getClosureNamespace() { result = getModuleDeclaration().getClosureNamespace() }
10199

102100
override Module getAnImportedModule() {
103101
exists(GoogRequireImport imprt |
104102
imprt.getEnclosingModule() = this and
105-
result.(ClosureModule).getNamespaceId() = imprt.getNamespaceId()
103+
result.(ClosureModule).getClosureNamespace() = imprt.getClosureNamespace()
106104
)
107105
}
108106

@@ -146,19 +144,19 @@ module Closure {
146144

147145
/** Gets the identifier of a namespace required by this module. */
148146
string getARequiredNamespace() {
149-
result = getAChildStmt().(ExprStmt).getExpr().(GoogRequire).getNamespaceId()
147+
result = getAChildStmt().(ExprStmt).getExpr().(GoogRequire).getClosureNamespace()
150148
}
151149

152150
/** Gets the identifer of a namespace provided by this module. */
153-
string getAProvidedNamespace() { result = getAChildStmt().(GoogProvide).getNamespaceId() }
151+
string getAProvidedNamespace() { result = getAChildStmt().(GoogProvide).getClosureNamespace() }
154152
}
155153

156154
/**
157155
* Holds if `name` is a closure namespace, including proper namespace prefixes.
158156
*/
159157
pragma[noinline]
160158
predicate isLibraryNamespacePath(string name) {
161-
exists(string namespace | namespace = any(GoogNamespaceRef provide).getNamespaceId() |
159+
exists(string namespace | namespace = any(GoogNamespaceRef provide).getClosureNamespace() |
162160
name = namespace.substring(0, namespace.indexOf("."))
163161
or
164162
name = namespace
@@ -187,7 +185,7 @@ module Closure {
187185
result = getWrittenLibraryAccessPath(write)
188186
)
189187
or
190-
result = node.asExpr().(GoogRequire).getNamespaceId()
188+
result = node.asExpr().(GoogRequire).getClosureNamespace()
191189
}
192190

193191
/**

javascript/ql/src/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ private class AnalyzedClosureGlobalAccessPath extends AnalyzedNode, AnalyzedProp
371371

372372
override predicate reads(AbstractValue base, string propName) {
373373
exists(Closure::ClosureModule mod |
374-
mod.getNamespaceId() = accessPath and
374+
mod.getClosureNamespace() = accessPath and
375375
base = TAbstractModuleObject(mod) and
376376
propName = "exports"
377377
)

0 commit comments

Comments
 (0)