File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,13 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
6161 }
6262
6363 /** Gets the `i`th dependency of this module definition. */
64- PathExpr getDependency ( int i ) { result = this .getDependencies ( ) .getElement ( i ) }
64+ PathExpr getDependency ( int i ) {
65+ exists ( Expr expr |
66+ expr = this .getDependencies ( ) .getElement ( i ) and
67+ not isPseudoDependency ( expr .getStringValue ( ) ) and
68+ result = expr
69+ )
70+ }
6571
6672 /** Gets a dependency of this module definition. */
6773 PathExpr getADependency ( ) {
@@ -203,11 +209,15 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
203209 }
204210}
205211
212+ private predicate isPseudoDependency ( string s ) { s = [ "exports" , "require" , "module" ] }
213+
206214/** An AMD dependency, considered as a path expression. */
207215private class AmdDependencyPath extends PathExprCandidate {
208216 AmdDependencyPath ( ) {
209217 exists ( AmdModuleDefinition amd |
210- this = amd .getDependencies ( ) .getAnElement ( ) or
218+ this = amd .getDependencies ( ) .getAnElement ( ) and
219+ not isPseudoDependency ( this .getStringValue ( ) )
220+ or
211221 this = amd .getARequireCall ( ) .getAnArgument ( )
212222 )
213223 }
Original file line number Diff line number Diff line change @@ -61,7 +61,6 @@ amdModuleDefinition
6161| umd.js:4:9:4:43 | define( ... actory) | umd.js:1:18:1:24 | factory |
6262| umd.js:4:9:4:43 | define( ... actory) | umd.js:9:9:14:1 | functio ... };\\n} |
6363amdModuleDependencies
64- | tst2.js:1:1:3:2 | define( ... 42;\\n}) | tst2.js:1:9:1:17 | 'exports' |
6564| tst3.js:1:1:3:2 | define( ... 42;\\n}) | tst3.js:2:21:2:25 | './a' |
6665| tst4.js:1:1:11:2 | define( ... };\\n}) | tst4.js:2:9:2:14 | 'a.js' |
6766| tst4.js:1:1:11:2 | define( ... };\\n}) | tst4.js:3:9:3:13 | 'foo' |
You can’t perform that action at this time.
0 commit comments