File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
javascript/ql/src/semmle/javascript Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -115,17 +115,28 @@ module Closure {
115
115
override DefaultClosureModuleDeclaration range ;
116
116
}
117
117
118
+ private GlobalVariable googVariable ( ) {
119
+ variables ( result , "goog" , any ( GlobalScope sc ) )
120
+ }
121
+
122
+ pragma [ nomagic]
123
+ private MethodCallExpr googModuleDeclExpr ( ) {
124
+ result .getReceiver ( ) = googVariable ( ) .getAnAccess ( ) and
125
+ result .getMethodName ( ) = [ "module" , "declareModuleId" ]
126
+ }
127
+
128
+ pragma [ nomagic]
129
+ private MethodCallExpr googModuleDeclExprInContainer ( StmtContainer container ) {
130
+ result .getReceiver ( ) = googModuleDeclExpr ( ) and
131
+ container = result .getContainer ( )
132
+ }
133
+
118
134
/**
119
135
* A module using the Closure module system, declared using `goog.module()` or `goog.declareModuleId()`.
120
136
*/
121
137
class ClosureModule extends Module {
122
138
ClosureModule ( ) {
123
- // Use AST-based predicate to cut recursive dependencies.
124
- exists ( MethodCallExpr call |
125
- getAStmt ( ) .( ExprStmt ) .getExpr ( ) = call and
126
- call .getReceiver ( ) .( GlobalVarAccess ) .getName ( ) = "goog" and
127
- ( call .getMethodName ( ) = "module" or call .getMethodName ( ) = "declareModuleId" )
128
- )
139
+ exists ( googModuleDeclExprInContainer ( this ) )
129
140
}
130
141
131
142
/**
You can’t perform that action at this time.
0 commit comments