Skip to content

Commit 5b9c0de

Browse files
committed
JS: Update deprecated uses of Import.getImportedPath()
1 parent b82cbb0 commit 5b9c0de

File tree

16 files changed

+24
-24
lines changed

16 files changed

+24
-24
lines changed

javascript/ql/lib/definitions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private predicate importLookup(AstNode path, Module target, string kind) {
7070
kind = "I" and
7171
(
7272
exists(Import i |
73-
path = i.getImportedPath() and
73+
path = i.getImportedPathExpr() and
7474
target = i.getImportedModule()
7575
)
7676
or

javascript/ql/lib/semmle/javascript/AMD.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private class AmdDependencyImport extends Import {
265265

266266
override Module getEnclosingModule() { this = result.(AmdModule).getDefine().getADependency() }
267267

268-
override PathExpr getImportedPath() { result = this }
268+
override Expr getImportedPathExpr() { result = this }
269269

270270
/**
271271
* Gets a file that looks like it might be the target of this import.
@@ -298,7 +298,7 @@ private class AmdDependencyImport extends Import {
298298
private predicate targetCandidate(
299299
File f, string abspath, PathString imported, string dirname, string basename
300300
) {
301-
imported = this.getImportedPath().getValue() and
301+
imported = this.getImportedPathString() and
302302
f.getStem() = imported.getStem() and
303303
f.getAbsolutePath() = abspath and
304304
dirname = imported.getDirName() and

javascript/ql/lib/semmle/javascript/ES2015Modules.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private predicate hasDefaultExport(ES2015Module mod) {
9191
class ImportDeclaration extends Stmt, Import, @import_declaration {
9292
override ES2015Module getEnclosingModule() { result = this.getTopLevel() }
9393

94-
override PathExpr getImportedPath() { result = this.getChildExpr(-1) }
94+
override Expr getImportedPathExpr() { result = this.getChildExpr(-1) }
9595

9696
/**
9797
* Gets the object literal passed as part of the `with` (or `assert`) clause in this import declaration.

javascript/ql/lib/semmle/javascript/Expr.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ class DynamicImportExpr extends @dynamic_import, Expr, Import {
28212821
result = this.getSource().getFirstControlFlowNode()
28222822
}
28232823

2824-
override PathExpr getImportedPath() { result = this.getSource() }
2824+
override Expr getImportedPathExpr() { result = this.getSource() }
28252825

28262826
/**
28272827
* Gets the second "argument" to the import expression, that is, the `Y` in `import(X, Y)`.

javascript/ql/lib/semmle/javascript/NodeJS.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private class RequireVariable extends Variable {
237237
}
238238

239239
private predicate isModuleModule(EarlyStageNode nd) {
240-
exists(ImportDeclaration imp | imp.getImportedPath().getValue() = "module" |
240+
exists(ImportDeclaration imp | imp.getImportedPathString() = "module" |
241241
nd = TDestructuredModuleImportNode(imp)
242242
or
243243
nd = TValueNode(imp.getASpecifier().(ImportNamespaceSpecifier))
@@ -263,7 +263,7 @@ private predicate isCreateRequire(EarlyStageNode nd) {
263263
)
264264
or
265265
exists(ImportDeclaration decl, NamedImportSpecifier spec |
266-
decl.getImportedPath().getValue() = "module" and
266+
decl.getImportedPathString() = "module" and
267267
spec = decl.getASpecifier() and
268268
spec.getImportedName() = "createRequire" and
269269
nd = TValueNode(spec)
@@ -323,7 +323,7 @@ private predicate isRequire(EarlyStageNode nd) {
323323
class Require extends CallExpr, Import {
324324
Require() { isRequire(TValueNode(this.getCallee())) }
325325

326-
override PathExpr getImportedPath() { result = this.getArgument(0) }
326+
override Expr getImportedPathExpr() { result = this.getArgument(0) }
327327

328328
override Module getEnclosingModule() { this = result.getAnImport() }
329329

@@ -391,7 +391,7 @@ class Require extends CallExpr, Import {
391391
* `.js`, `.json` and `.node`.
392392
*/
393393
private File load(int priority) {
394-
exists(int r | this.getEnclosingModule().searchRoot(this.getImportedPath(), _, r) |
394+
exists(int r | this.getEnclosingModule().searchRoot(this.getImportedPathExpr(), _, r) |
395395
result = loadAsFile(this, r, priority - prioritiesPerCandidate() * r) or
396396
result =
397397
loadAsDirectory(this, r,

javascript/ql/lib/semmle/javascript/NodeModuleResolutionImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int numberOfExtensions() { result = count(getFileExtensionPriority(_)) }
4646
* when resolved from the root with priority `rootPriority`.
4747
*/
4848
File loadAsFile(Require req, int rootPriority, int priority) {
49-
exists(PathExpr path | path = req.getImportedPath() |
49+
exists(PathExpr path | path = req.getImportedPathExpr() |
5050
result = path.resolve(rootPriority) and priority = 0
5151
or
5252
exists(Folder encl | encl = path.resolveUpTo(path.getNumComponent() - 1, rootPriority) |
@@ -61,7 +61,7 @@ File loadAsFile(Require req, int rootPriority, int priority) {
6161
* priority `rootPriority`.
6262
*/
6363
File loadAsDirectory(Require req, int rootPriority, int priority) {
64-
exists(Folder dir | dir = req.getImportedPath().resolve(rootPriority) |
64+
exists(Folder dir | dir = req.getImportedPathExpr().(PathExpr).resolve(rootPriority) |
6565
result = resolveMainModule(dir.(NpmPackage).getPackageJson(), priority, ".") or
6666
result = tryExtensions(dir, "index", priority - (numberOfExtensions() + 1))
6767
)

javascript/ql/lib/semmle/javascript/TypeScript.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class ExternalModuleReference extends Expr, Import, @external_module_reference {
207207
/** Gets the expression specifying the module. */
208208
Expr getExpression() { result = this.getChildExpr(0) }
209209

210-
override PathExpr getImportedPath() { result = this.getExpression() }
210+
override Expr getImportedPathExpr() { result = this.getExpression() }
211211

212212
override Module getEnclosingModule() { result = this.getTopLevel() }
213213

@@ -743,7 +743,7 @@ class TypeAccess extends @typeaccess, TypeExpr, TypeRef {
743743
* For non-relative imports, it is the import path itself.
744744
*/
745745
private string getImportName(Import imprt) {
746-
exists(string path | path = imprt.getImportedPath().getValue() |
746+
exists(string path | path = imprt.getImportedPathExpr().getStringValue() |
747747
if path.regexpMatch("[./].*")
748748
then result = imprt.getImportedModule().getFile().getRelativePath()
749749
else result = path
@@ -1731,7 +1731,7 @@ class TSGlobalDeclImport extends DataFlow::ModuleImportNode::Range {
17311731
pkg = tt.getExpressionName() and
17321732
// then, check pkg is imported as "import * as pkg from path"
17331733
i.getLocal().getVariable() = pkg.getVariable() and
1734-
path = i.getImportedPath().getValue() and
1734+
path = i.getImportedPathString() and
17351735
// finally, "this" needs to be a reference to gv
17361736
this = DataFlow::exprNode(gv.getAnAccess())
17371737
)

javascript/ql/lib/semmle/javascript/dataflow/Nodes.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ module ModuleImportNode {
738738
DefaultRange() {
739739
exists(Import i |
740740
this = i.getImportedModuleNode() and
741-
i.getImportedPath().getValue() = path
741+
i.getImportedPathString() = path
742742
)
743743
or
744744
// AMD require

javascript/ql/lib/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class AnalyzedImportSpecifier extends AnalyzedVarDef, @import_specifier
2525

2626
override predicate isIncomplete(DataFlow::Incompleteness cause) {
2727
// mark as incomplete if the import could rely on the lookup path
28-
mayDependOnLookupPath(id.getImportedPath().getValue()) and
28+
mayDependOnLookupPath(id.getImportedPathString()) and
2929
cause = "import"
3030
or
3131
// mark as incomplete if we cannot fully analyze this import

javascript/ql/lib/semmle/javascript/dependencies/Dependencies.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private int importsDependency(Import i, NpmPackage pkg, NpmDependency dep) {
159159
exists(string name |
160160
dep = pkg.getPackageJson().getADependenciesObject(_).getPropValue(name) and
161161
not exists(i.getImportedModule()) and
162-
i.getImportedPath().getComponent(0) = name and
162+
i.getImportedPathExpr().(PathExpr).getComponent(0) = name and
163163
i.getEnclosingModule() = pkg.getAModule() and
164164
result = distance(pkg, i.getFile())
165165
)

0 commit comments

Comments
 (0)