11/**
22 * Provides classes for working with the Closure-Library module system.
33 */
4+ overlay [ local]
5+ module ;
46
57import javascript
68
@@ -40,13 +42,15 @@ module Closure {
4042 /**
4143 * A reference to a Closure namespace.
4244 */
45+ overlay [ global]
4346 deprecated class ClosureNamespaceRef extends DataFlow:: Node instanceof ClosureNamespaceRef:: Range {
4447 /**
4548 * Gets the namespace being referenced.
4649 */
4750 string getClosureNamespace ( ) { result = super .getClosureNamespace ( ) }
4851 }
4952
53+ overlay [ global]
5054 deprecated module ClosureNamespaceRef {
5155 /**
5256 * A reference to a Closure namespace.
@@ -64,9 +68,11 @@ module Closure {
6468 /**
6569 * A data flow node that returns the value of a closure namespace.
6670 */
71+ overlay [ global]
6772 deprecated class ClosureNamespaceAccess extends ClosureNamespaceRef instanceof ClosureNamespaceAccess:: Range
6873 { }
6974
75+ overlay [ global]
7076 deprecated module ClosureNamespaceAccess {
7177 /**
7278 * A data flow node that returns the value of a closure namespace.
@@ -79,6 +85,7 @@ module Closure {
7985 /**
8086 * A call to a method on the `goog.` namespace, as a closure reference.
8187 */
88+ overlay [ global]
8289 abstract deprecated private class DefaultNamespaceRef extends DataFlow:: MethodCallNode ,
8390 ClosureNamespaceRef:: Range
8491 {
@@ -91,13 +98,15 @@ module Closure {
9198 * Holds if `node` is the data flow node corresponding to the expression in
9299 * a top-level expression statement.
93100 */
101+ overlay [ global]
94102 deprecated private predicate isTopLevelExpr ( DataFlow:: Node node ) {
95103 any ( TopLevel tl ) .getAChildStmt ( ) .( ExprStmt ) .getExpr ( ) .flow ( ) = node
96104 }
97105
98106 /**
99107 * A top-level call to `goog.provide`.
100108 */
109+ overlay [ global]
101110 deprecated private class DefaultClosureProvideCall extends DefaultNamespaceRef {
102111 DefaultClosureProvideCall ( ) {
103112 this .getMethodName ( ) = "provide" and
@@ -108,12 +117,14 @@ module Closure {
108117 /**
109118 * A top-level call to `goog.provide`.
110119 */
120+ overlay [ global]
111121 deprecated class ClosureProvideCall extends ClosureNamespaceRef , DataFlow:: MethodCallNode instanceof DefaultClosureProvideCall
112122 { }
113123
114124 /**
115125 * A call to `goog.require`.
116126 */
127+ overlay [ global]
117128 deprecated private class DefaultClosureRequireCall extends DefaultNamespaceRef ,
118129 ClosureNamespaceAccess:: Range
119130 {
@@ -123,12 +134,14 @@ module Closure {
123134 /**
124135 * A call to `goog.require`.
125136 */
137+ overlay [ global]
126138 deprecated class ClosureRequireCall extends ClosureNamespaceAccess , DataFlow:: MethodCallNode instanceof DefaultClosureRequireCall
127139 { }
128140
129141 /**
130142 * A top-level call to `goog.module` or `goog.declareModuleId`.
131143 */
144+ overlay [ global]
132145 deprecated private class DefaultClosureModuleDeclaration extends DefaultNamespaceRef {
133146 DefaultClosureModuleDeclaration ( ) {
134147 ( this .getMethodName ( ) = "module" or this .getMethodName ( ) = "declareModuleId" ) and
@@ -139,6 +152,7 @@ module Closure {
139152 /**
140153 * A top-level call to `goog.module` or `goog.declareModuleId`.
141154 */
155+ overlay [ global]
142156 deprecated class ClosureModuleDeclaration extends ClosureNamespaceRef , DataFlow:: MethodCallNode instanceof DefaultClosureModuleDeclaration
143157 { }
144158
@@ -156,6 +170,7 @@ module Closure {
156170 /**
157171 * Gets the call to `goog.module` or `goog.declareModuleId` in this module.
158172 */
173+ overlay [ global]
159174 deprecated ClosureModuleDeclaration getModuleDeclaration ( ) { result .getTopLevel ( ) = this }
160175
161176 /**
@@ -181,6 +196,7 @@ module Closure {
181196 result = this .getScope ( ) .getVariable ( "exports" )
182197 }
183198
199+ overlay [ global]
184200 override DataFlow:: Node getAnExportedValue ( string name ) {
185201 exists ( DataFlow:: PropWrite write , Expr base |
186202 result = write .getRhs ( ) and
@@ -193,6 +209,7 @@ module Closure {
193209 )
194210 }
195211
212+ overlay [ global]
196213 override DataFlow:: Node getABulkExportedNode ( ) {
197214 result = this .getExportsVariable ( ) .getAnAssignedExpr ( ) .flow ( )
198215 }
@@ -232,6 +249,7 @@ module Closure {
232249 /**
233250 * Holds if `name` is a closure namespace, including proper namespace prefixes.
234251 */
252+ overlay [ global]
235253 pragma [ noinline]
236254 predicate isClosureNamespace ( string name ) {
237255 exists ( string namespace |
@@ -253,6 +271,7 @@ module Closure {
253271 * Holds if a prefix of `name` is a closure namespace.
254272 */
255273 bindingset [ name]
274+ overlay [ global]
256275 private predicate hasClosureNamespacePrefix ( string name ) {
257276 isClosureNamespace ( name .substring ( 0 , name .indexOf ( "." ) ) )
258277 or
@@ -262,6 +281,7 @@ module Closure {
262281 /**
263282 * Gets the closure namespace path addressed by the given data flow node, if any.
264283 */
284+ overlay [ global]
265285 string getClosureNamespaceFromSourceNode ( DataFlow:: SourceNode node ) {
266286 node = AccessPath:: getAReferenceOrAssignmentTo ( result ) and
267287 hasClosureNamespacePrefix ( result )
@@ -270,6 +290,7 @@ module Closure {
270290 /**
271291 * Gets the closure namespace path written to by the given property write, if any.
272292 */
293+ overlay [ global]
273294 string getWrittenClosureNamespace ( DataFlow:: PropWrite node ) {
274295 node .getRhs ( ) = AccessPath:: getAnAssignmentTo ( result ) and
275296 hasClosureNamespacePrefix ( result )
@@ -278,13 +299,15 @@ module Closure {
278299 /**
279300 * Gets a data flow node that refers to the given value exported from a Closure module.
280301 */
302+ overlay [ global]
281303 DataFlow:: SourceNode moduleImport ( string moduleName ) {
282304 getClosureNamespaceFromSourceNode ( result ) = moduleName
283305 }
284306
285307 /**
286308 * A call to `goog.bind`, as a partial function invocation.
287309 */
310+ overlay [ global]
288311 private class BindCall extends DataFlow:: PartialInvokeNode:: Range , DataFlow:: CallNode {
289312 BindCall ( ) { this = moduleImport ( "goog.bind" ) .getACall ( ) }
290313
0 commit comments