JavaScript: Make AMD dependencies Imports.

This commit is contained in:
Max Schaefer
2019-03-25 11:47:32 +00:00
parent fcf04abb84
commit 6a78e37d93
2 changed files with 19 additions and 2 deletions

View File

@@ -196,6 +196,23 @@ private predicate amdModuleTopLevel(AMDModuleDefinition def, TopLevel tl) {
not def.getParent+() instanceof AMDModuleDefinition
}
/**
* An AMD dependency, viewed as an import.
*/
private class AmdDependencyImport extends Import {
AmdDependencyImport() {
this = any(AMDModuleDefinition def).getADependency()
}
override Module getEnclosingModule() {
this = result.(AMDModule).getDefine().getADependency()
}
override PathExpr getImportedPath() {
result = this
}
}
/**
* An AMD-style module.
*/

View File

@@ -92,8 +92,8 @@ abstract class Module extends TopLevel {
}
/**
* An import in a module, which may either be an ECMAScript 2015-style
* `import` statement or a CommonJS-style `require` import.
* An import in a module, which may be an ECMAScript 2015-style
* `import` statement, a CommonJS-style `require` import, or an AMD dependency.
*/
abstract class Import extends ASTNode {
/** Gets the module in which this import appears. */