Skip to content

Commit a252a41

Browse files
committed
JS: Rename/deprecate a predicate to loosen its return type
1 parent 2b77c79 commit a252a41

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

javascript/ql/src/semmle/javascript/ES2015Modules.qll

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ class BulkReExportDeclaration extends ReExportDeclaration, @exportalldeclaration
273273
override ConstantString getImportedPath() { result = getChildExpr(0) }
274274

275275
override predicate exportsAs(LexicalName v, string name) {
276-
getImportedModule().exportsAs(v, name) and
276+
getReExportedES2015Module().exportsAs(v, name) and
277277
not isShadowedFromBulkExport(this, name)
278278
}
279279

280280
override DataFlow::Node getSourceNode(string name) {
281-
result = getImportedModule().getAnExport().getSourceNode(name)
281+
result = getReExportedES2015Module().getAnExport().getSourceNode(name)
282282
}
283283
}
284284

@@ -379,7 +379,7 @@ class ExportNamedDeclaration extends ExportDeclaration, @exportnameddeclaration
379379
exists(ExportSpecifier spec | spec = getASpecifier() and name = spec.getExportedName() |
380380
v = spec.getLocal().(LexicalAccess).getALexicalName()
381381
or
382-
this.(ReExportDeclaration).getImportedModule().exportsAs(v, spec.getLocalName())
382+
this.(ReExportDeclaration).getReExportedES2015Module().exportsAs(v, spec.getLocalName())
383383
)
384384
}
385385

@@ -393,7 +393,7 @@ class ExportNamedDeclaration extends ExportDeclaration, @exportnameddeclaration
393393
not exists(getImportedPath()) and result = DataFlow::valueNode(spec.getLocal())
394394
or
395395
exists(ReExportDeclaration red | red = this |
396-
result = red.getImportedModule().getAnExport().getSourceNode(spec.getLocalName())
396+
result = red.getReExportedES2015Module().getAnExport().getSourceNode(spec.getLocalName())
397397
)
398398
)
399399
}
@@ -572,8 +572,23 @@ abstract class ReExportDeclaration extends ExportDeclaration {
572572
/** Gets the path of the module from which this declaration re-exports. */
573573
abstract ConstantString getImportedPath();
574574

575-
/** Gets the module from which this declaration re-exports. */
575+
/**
576+
* DEPRECATED. Use `getReExportedES2015Module()` instead.
577+
*
578+
* Gets the module from which this declaration re-exports.
579+
*/
580+
deprecated
576581
ES2015Module getImportedModule() {
582+
result = getReExportedModule()
583+
}
584+
585+
/** Gets the module from which this declaration re-exports, if it is an ES2015 module. */
586+
ES2015Module getReExportedES2015Module() {
587+
result = getReExportedModule()
588+
}
589+
590+
/** Gets the module from which this declaration re-exports. */
591+
Module getReExportedModule() {
577592
result.getFile() = getEnclosingModule().resolve(getImportedPath().(PathExpr))
578593
or
579594
result = resolveFromTypeRoot()
@@ -641,4 +656,4 @@ class OriginalExportDeclaration extends ExportDeclaration {
641656
result = this.(ExportDefaultDeclaration).getSourceNode(name) or
642657
result = this.(ExportNamedDeclaration).getSourceNode(name)
643658
}
644-
}
659+
}

0 commit comments

Comments
 (0)