JS: change charpred of ClosureModule to be AST-based

This commit is contained in:
Asger F
2019-02-15 11:43:27 +00:00
parent d1607f7c47
commit c8823fa7cf

View File

@@ -68,7 +68,14 @@ module Closure {
* A module using the Closure module system, declared using `goog.module()` or `goog.declareModuleId()`.
*/
class ClosureModule extends Module {
ClosureModule() { any(ClosureModuleDeclaration decl).getTopLevel() = this }
ClosureModule() {
// Use AST-based predicate to cut recursive dependencies.
exists(MethodCallExpr call |
getAStmt().(ExprStmt).getExpr() = call and
call.getReceiver().(GlobalVarAccess).getName() = "goog" and
(call.getMethodName() = "module" or call.getMethodName() = "declareModuleId")
)
}
/**
* Gets the call to `goog.module` or `goog.declareModuleId` in this module.