@@ -14,36 +14,41 @@ private predicate instanceVariableAccess(
14
14
) {
15
15
name = var .getValue ( ) and
16
16
scope = enclosingModuleOrClass ( var ) and
17
- if
18
- exists ( VariableScope method |
19
- method = enclosingMethod ( var ) and scope = enclosingScope ( method .getScopeElement ( ) )
20
- )
21
- then instance = true
22
- else instance = false
17
+ if exists ( enclosingMethod ( var ) ) then instance = true else instance = false
23
18
}
24
19
25
20
private predicate classVariableAccess ( Generated:: ClassVariable var , string name , VariableScope scope ) {
26
21
name = var .getValue ( ) and
27
22
scope = enclosingModuleOrClass ( var )
28
23
}
29
24
30
- private VariableScope enclosingMethod ( Generated:: AstNode node ) {
31
- exists ( VariableScope scope , Callable c |
32
- scope = outerScope * ( enclosingScope ( node ) ) and
33
- scope = TCallableScope ( c ) and
34
- ( c instanceof Method or c instanceof SingletonMethod ) and
35
- result = scope
25
+ private Callable enclosingMethod ( Generated:: AstNode node ) {
26
+ parentCallableScope * ( enclosingScope ( node ) ) = TCallableScope ( result ) and
27
+ (
28
+ result instanceof Method or
29
+ result instanceof SingletonMethod
36
30
)
37
31
}
38
32
39
- private VariableScope enclosingModuleOrClass ( Generated:: AstNode node ) {
40
- exists ( VariableScope scope | scope = enclosingScope ( node ) |
41
- if scope instanceof ModuleOrClassScope
42
- then result = scope
43
- else result = enclosingModuleOrClass ( scope .getScopeElement ( ) )
33
+ private TCallableScope parentCallableScope ( TCallableScope scope ) {
34
+ exists ( Callable c |
35
+ scope = TCallableScope ( c ) and
36
+ not c instanceof Method and
37
+ not c instanceof SingletonMethod
38
+ |
39
+ result = outerScope ( scope )
44
40
)
45
41
}
46
42
43
+ private VariableScope parentScope ( VariableScope scope ) {
44
+ not scope instanceof ModuleOrClassScope and
45
+ result = outerScope ( scope )
46
+ }
47
+
48
+ private ModuleOrClassScope enclosingModuleOrClass ( Generated:: AstNode node ) {
49
+ result = parentScope * ( enclosingScope ( node ) )
50
+ }
51
+
47
52
private predicate parameterAssignment (
48
53
CallableScope:: Range scope , string name , Generated:: Identifier i
49
54
) {
0 commit comments