File tree Expand file tree Collapse file tree 3 files changed +11
-20
lines changed
javascript/ql/lib/semmle/javascript Expand file tree Collapse file tree 3 files changed +11
-20
lines changed Original file line number Diff line number Diff line change 22
33import javascript
44private import semmle.javascript.internal.CachedStages
5+ private import semmle.javascript.internal.paths.PathExprResolver
56
67/**
78 * An ECMAScript 2015 module.
@@ -725,22 +726,7 @@ abstract class ReExportDeclaration extends ExportDeclaration {
725726 cached
726727 Module getReExportedModule ( ) {
727728 Stages:: Imports:: ref ( ) and
728- result .getFile ( ) = this .getEnclosingModule ( ) .resolve ( this .getImportedPath ( ) )
729- or
730- result = this .resolveFromTypeRoot ( )
731- }
732-
733- /**
734- * Gets a module in a `node_modules/@types/` folder that matches the imported module name.
735- */
736- private Module resolveFromTypeRoot ( ) {
737- result .getFile ( ) =
738- min ( TypeRootFolder typeRoot |
739- |
740- typeRoot .getModuleFile ( this .getImportedPath ( ) .getStringValue ( ) )
741- order by
742- typeRoot .getSearchPriority ( this .getFile ( ) .getParentContainer ( ) )
743- )
729+ result .getFile ( ) = ImportPathResolver:: resolveExpr ( this .getImportedPath ( ) )
744730 }
745731}
746732
Original file line number Diff line number Diff line change @@ -115,10 +115,6 @@ abstract class Module extends TopLevel {
115115 }
116116}
117117
118- private predicate shouldResolveExpr ( Expr e ) { e = any ( Import imprt ) .getImportedPathExpr ( ) }
119-
120- private module Resolver = ResolveExpr< shouldResolveExpr / 1 > ;
121-
122118/**
123119 * An import in a module, which may be an ECMAScript 2015-style
124120 * `import` statement, a CommonJS-style `require` import, or an AMD dependency.
Original file line number Diff line number Diff line change @@ -244,3 +244,12 @@ module ResolveExpr<exprSig/1 shouldResolveExpr> {
244244 query predicate getFileFromFolderImport_ = getFileFromFolderImport / 1 ;
245245 }
246246}
247+
248+ private predicate isImportPathExpr ( Expr e ) {
249+ e = any ( Import imprt ) .getImportedPathExpr ( )
250+ or
251+ e = any ( ReExportDeclaration decl ) .getImportedPath ( )
252+ }
253+
254+ /** Resolves paths in imports and re-exports. */
255+ module ImportPathResolver = ResolveExpr< isImportPathExpr / 1 > ;
You can’t perform that action at this time.
0 commit comments