JS: Cache getReExportedModule

This commit is contained in:
Asger Feldthaus
2021-03-12 15:32:10 +00:00
parent 710cca5395
commit ff1326cc7b
2 changed files with 5 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
/** Provides classes for working with ECMAScript 2015 modules. */
import javascript
private import semmle.javascript.internal.CachedStages
/**
* An ECMAScript 2015 module.
@@ -654,7 +655,9 @@ abstract class ReExportDeclaration extends ExportDeclaration {
ES2015Module getReExportedES2015Module() { result = getReExportedModule() }
/** Gets the module from which this declaration re-exports. */
cached
Module getReExportedModule() {
Stages::Imports::ref() and
result.getFile() = getEnclosingModule().resolve(getImportedPath().(PathExpr))
or
result = resolveFromTypeRoot()

View File

@@ -162,6 +162,8 @@ module Stages {
exists(any(Import i).getImportedModule())
or
exists(DataFlow::moduleImport(_))
or
exists(any(ReExportDeclaration d).getReExportedModule())
}
}