File tree Expand file tree Collapse file tree
javascript/ql/src/semmle/javascript Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,17 +115,28 @@ module Closure {
115115 override DefaultClosureModuleDeclaration range ;
116116 }
117117
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+
118134 /**
119135 * A module using the Closure module system, declared using `goog.module()` or `goog.declareModuleId()`.
120136 */
121137 class ClosureModule extends Module {
122138 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 ) )
129140 }
130141
131142 /**
You can’t perform that action at this time.
0 commit comments