@@ -61,7 +61,13 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
61
61
}
62
62
63
63
/** 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
+ }
65
71
66
72
/** Gets a dependency of this module definition. */
67
73
PathExpr getADependency ( ) {
@@ -102,9 +108,10 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
102
108
/**
103
109
* Holds if `p` is the parameter corresponding to dependency `dep`.
104
110
*/
105
- predicate dependencyParameter ( PathExpr dep , Parameter p ) {
111
+ predicate dependencyParameter ( Expr dep , Parameter p ) {
106
112
exists ( int i |
107
- dep = this .getDependency ( i ) and
113
+ // Note: to avoid spurious recursion, do not depend on PathExpr here
114
+ dep = this .getDependencies ( ) .getElement ( i ) and
108
115
p = this .getFactoryParameter ( i )
109
116
)
110
117
}
@@ -122,9 +129,9 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
122
129
* `dep1` and `dep2`.
123
130
*/
124
131
Parameter getDependencyParameter ( string name ) {
125
- exists ( PathExpr dep |
132
+ exists ( Expr dep |
126
133
this .dependencyParameter ( dep , result ) and
127
- dep .getValue ( ) = name
134
+ name = dep .getStringValue ( )
128
135
)
129
136
}
130
137
@@ -202,11 +209,15 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
202
209
}
203
210
}
204
211
212
+ private predicate isPseudoDependency ( string s ) { s = [ "exports" , "require" , "module" ] }
213
+
205
214
/** An AMD dependency, considered as a path expression. */
206
215
private class AmdDependencyPath extends PathExprCandidate {
207
216
AmdDependencyPath ( ) {
208
217
exists ( AmdModuleDefinition amd |
209
- this = amd .getDependencies ( ) .getAnElement ( ) or
218
+ this = amd .getDependencies ( ) .getAnElement ( ) and
219
+ not isPseudoDependency ( this .getStringValue ( ) )
220
+ or
210
221
this = amd .getARequireCall ( ) .getAnArgument ( )
211
222
)
212
223
}
0 commit comments