@@ -15,7 +15,7 @@ private import Declarations.Declarations
15
15
* For example, in the expression `f(x)`, `f` has kind `"M"` while
16
16
* `x` has kind `"V"`.
17
17
*/
18
- string refKind ( RefExpr r ) {
18
+ private string refKind ( RefExpr r ) {
19
19
if exists ( InvokeExpr invk | r = invk .getCallee ( ) .getUnderlyingReference ( ) )
20
20
then result = "M"
21
21
else result = "V"
@@ -24,7 +24,7 @@ string refKind(RefExpr r) {
24
24
/**
25
25
* Gets a class, function or object literal `va` may refer to.
26
26
*/
27
- ASTNode lookupDef ( VarAccess va ) {
27
+ private ASTNode lookupDef ( VarAccess va ) {
28
28
exists ( AbstractValue av | av = va .analyze ( ) .getAValue ( ) |
29
29
result = av .( AbstractClass ) .getClass ( ) or
30
30
result = av .( AbstractFunction ) .getFunction ( ) or
@@ -36,7 +36,7 @@ ASTNode lookupDef(VarAccess va) {
36
36
* Holds if `va` is of kind `kind` and `def` is the unique class,
37
37
* function or object literal it refers to.
38
38
*/
39
- predicate variableDefLookup ( VarAccess va , ASTNode def , string kind ) {
39
+ private predicate variableDefLookup ( VarAccess va , ASTNode def , string kind ) {
40
40
count ( lookupDef ( va ) ) = 1 and
41
41
def = lookupDef ( va ) and
42
42
kind = refKind ( va )
@@ -50,7 +50,7 @@ predicate variableDefLookup(VarAccess va, ASTNode def, string kind) {
50
50
* expression of `y` is a variable access `x` of kind `"V"` that refers to
51
51
* the declaration `x = 42`.
52
52
*/
53
- predicate variableDeclLookup ( VarAccess va , VarDecl decl , string kind ) {
53
+ private predicate variableDeclLookup ( VarAccess va , VarDecl decl , string kind ) {
54
54
// restrict to declarations in same file to avoid accidentally picking up
55
55
// unrelated global definitions
56
56
decl = firstRefInTopLevel ( va .getVariable ( ) , Decl ( ) , va .getTopLevel ( ) ) and
@@ -65,7 +65,7 @@ predicate variableDeclLookup(VarAccess va, VarDecl decl, string kind) {
65
65
* For example, in the statement `var a = require("./a")`, the path expression
66
66
* `"./a"` imports a module `a` in the same folder.
67
67
*/
68
- predicate importLookup ( ASTNode path , Module target , string kind ) {
68
+ private predicate importLookup ( ASTNode path , Module target , string kind ) {
69
69
kind = "I" and
70
70
(
71
71
exists ( Import i |
@@ -83,7 +83,7 @@ predicate importLookup(ASTNode path, Module target, string kind) {
83
83
/**
84
84
* Gets a node that may write the property read by `prn`.
85
85
*/
86
- ASTNode getAWrite ( DataFlow:: PropRead prn ) {
86
+ private ASTNode getAWrite ( DataFlow:: PropRead prn ) {
87
87
exists ( DataFlow:: AnalyzedNode base , DefiniteAbstractValue baseVal , string propName |
88
88
base = prn .getBase ( ) and
89
89
propName = prn .getPropertyName ( ) and
@@ -111,7 +111,7 @@ ASTNode getAWrite(DataFlow::PropRead prn) {
111
111
* only such property write. Parameter `kind` is always bound to `"M"`
112
112
* at the moment.
113
113
*/
114
- predicate propertyLookup ( Expr prop , ASTNode write , string kind ) {
114
+ private predicate propertyLookup ( Expr prop , ASTNode write , string kind ) {
115
115
exists ( DataFlow:: PropRead prn | prop = prn .getPropertyNameExpr ( ) |
116
116
count ( getAWrite ( prn ) ) = 1 and
117
117
write = getAWrite ( prn ) and
@@ -122,7 +122,7 @@ predicate propertyLookup(Expr prop, ASTNode write, string kind) {
122
122
/**
123
123
* Holds if `ref` is an identifier that refers to a type declared at `decl`.
124
124
*/
125
- predicate typeLookup ( ASTNode ref , ASTNode decl , string kind ) {
125
+ private predicate typeLookup ( ASTNode ref , ASTNode decl , string kind ) {
126
126
exists ( TypeAccess typeAccess |
127
127
ref = typeAccess .getIdentifier ( ) and
128
128
decl = typeAccess .getTypeName ( ) .getADefinition ( ) and
@@ -133,7 +133,7 @@ predicate typeLookup(ASTNode ref, ASTNode decl, string kind) {
133
133
/**
134
134
* Holds if `ref` is the callee name of an invocation of `decl`.
135
135
*/
136
- predicate typedInvokeLookup ( ASTNode ref , ASTNode decl , string kind ) {
136
+ private predicate typedInvokeLookup ( ASTNode ref , ASTNode decl , string kind ) {
137
137
not variableDefLookup ( ref , decl , _) and
138
138
not propertyLookup ( ref , decl , _) and
139
139
exists ( InvokeExpr invoke , Expr callee |
@@ -147,7 +147,7 @@ predicate typedInvokeLookup(ASTNode ref, ASTNode decl, string kind) {
147
147
/**
148
148
* Holds if `ref` is a JSDoc type annotation referring to a class defined at `decl`.
149
149
*/
150
- predicate jsdocTypeLookup ( JSDocNamedTypeExpr ref , ASTNode decl , string kind ) {
150
+ private predicate jsdocTypeLookup ( JSDocNamedTypeExpr ref , ASTNode decl , string kind ) {
151
151
decl = ref .getClass ( ) .getAstNode ( ) and
152
152
kind = "T"
153
153
}
0 commit comments