@@ -146,7 +146,7 @@ class NodeModule extends Module {
146
146
)
147
147
}
148
148
149
- override predicate searchRoot ( PathExpr path , Folder searchRoot , int priority ) {
149
+ deprecated override predicate searchRoot ( PathExpr path , Folder searchRoot , int priority ) {
150
150
path .getEnclosingModule ( ) = this and
151
151
exists ( string pathval | pathval = path .getValue ( ) |
152
152
// paths starting with `./` or `../` are resolved relative to the importing
@@ -236,11 +236,6 @@ private class RequireVariable extends Variable {
236
236
}
237
237
}
238
238
239
- /**
240
- * Holds if module `m` is in file `f`.
241
- */
242
- private predicate moduleInFile ( Module m , File f ) { m .getFile ( ) = f }
243
-
244
239
private predicate isModuleModule ( EarlyStageNode nd ) {
245
240
exists ( ImportDeclaration imp | imp .getRawImportPath ( ) = "module" |
246
241
nd = TDestructuredModuleImportNode ( imp )
@@ -328,24 +323,17 @@ private predicate isRequire(EarlyStageNode nd) {
328
323
class Require extends CallExpr , Import {
329
324
Require ( ) { isRequire ( TValueNode ( this .getCallee ( ) ) ) }
330
325
331
- override PathExpr getImportedPath ( ) { result = this .getArgument ( 0 ) }
326
+ override Expr getImportedPathExpr ( ) { result = this .getArgument ( 0 ) }
332
327
333
328
override Module getEnclosingModule ( ) { this = result .getAnImport ( ) }
334
329
335
- override Module resolveImportedPath ( ) {
336
- moduleInFile ( result , this .load ( min ( int prio | moduleInFile ( _, this .load ( prio ) ) ) ) )
337
- or
338
- not moduleInFile ( _, this .load ( _) ) and
339
- result = Import .super .resolveImportedPath ( )
340
- }
341
-
342
330
/**
343
331
* Gets the file that is imported by this `require`.
344
332
*
345
333
* The result can be a JavaScript file, a JSON file or a `.node` file.
346
334
* Externs files are not treated differently from other files by this predicate.
347
335
*/
348
- File getImportedFile ( ) { result = this .load ( min ( int prio | exists ( this .load ( prio ) ) ) ) }
336
+ deprecated File getImportedFile ( ) { result = this .load ( min ( int prio | exists ( this .load ( prio ) ) ) ) }
349
337
350
338
/**
351
339
* Gets the file that this `require` refers to (which may not be a JavaScript file),
@@ -402,8 +390,8 @@ class Require extends CallExpr, Import {
402
390
* predicate `tryExtensions` that handles the repeated distinction between
403
391
* `.js`, `.json` and `.node`.
404
392
*/
405
- private File load ( int priority ) {
406
- exists ( int r | this .getEnclosingModule ( ) .searchRoot ( this .getImportedPath ( ) , _, r ) |
393
+ deprecated private File load ( int priority ) {
394
+ exists ( int r | this .getEnclosingModule ( ) .searchRoot ( this .getImportedPathExpr ( ) , _, r ) |
407
395
result = loadAsFile ( this , r , priority - prioritiesPerCandidate ( ) * r ) or
408
396
result =
409
397
loadAsDirectory ( this , r ,
@@ -415,7 +403,7 @@ class Require extends CallExpr, Import {
415
403
}
416
404
417
405
/** An argument to `require` or `require.resolve`, considered as a path expression. */
418
- private class RequirePath extends PathExprCandidate {
406
+ deprecated private class RequirePath extends PathExprCandidate {
419
407
RequirePath ( ) {
420
408
this = any ( Require req ) .getArgument ( 0 )
421
409
or
@@ -428,14 +416,14 @@ private class RequirePath extends PathExprCandidate {
428
416
}
429
417
430
418
/** A constant path element appearing in a call to `require` or `require.resolve`. */
431
- private class ConstantRequirePathElement extends PathExpr , ConstantString {
419
+ deprecated private class ConstantRequirePathElement extends PathExpr , ConstantString {
432
420
ConstantRequirePathElement ( ) { this = any ( RequirePath rp ) .getAPart ( ) }
433
421
434
422
override string getValue ( ) { result = this .getStringValue ( ) }
435
423
}
436
424
437
425
/** A `__dirname` path expression. */
438
- private class DirNamePath extends PathExpr , VarAccess {
426
+ deprecated private class DirNamePath extends PathExpr , VarAccess {
439
427
DirNamePath ( ) {
440
428
this .getName ( ) = "__dirname" and
441
429
this .getVariable ( ) .getScope ( ) instanceof ModuleScope
@@ -445,7 +433,7 @@ private class DirNamePath extends PathExpr, VarAccess {
445
433
}
446
434
447
435
/** A `__filename` path expression. */
448
- private class FileNamePath extends PathExpr , VarAccess {
436
+ deprecated private class FileNamePath extends PathExpr , VarAccess {
449
437
FileNamePath ( ) {
450
438
this .getName ( ) = "__filename" and
451
439
this .getVariable ( ) .getScope ( ) instanceof ModuleScope
@@ -458,7 +446,7 @@ private class FileNamePath extends PathExpr, VarAccess {
458
446
* A path expression of the form `path.join(p, "...")` where
459
447
* `p` is also a path expression.
460
448
*/
461
- private class JoinedPath extends PathExpr , @call_expr {
449
+ deprecated private class JoinedPath extends PathExpr , @call_expr {
462
450
JoinedPath ( ) {
463
451
exists ( MethodCallExpr call | call = this |
464
452
call .getReceiver ( ) .( VarAccess ) .getName ( ) = "path" and
0 commit comments