File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
java/ql/src/Violations of Best Practice/Implementation Hiding Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 15
15
import java
16
16
17
17
/**
18
- * A `Callable` is within some `RefType` (including through lambdas and inner classes)
18
+ * Holds if a `Callable` is within some `RefType` (including through lambdas and inner classes)
19
19
*/
20
20
predicate isWithinType ( Callable c , RefType t ) {
21
21
c .getDeclaringType ( ) = t
@@ -24,28 +24,37 @@ predicate isWithinType(Callable c, RefType t) {
24
24
}
25
25
26
26
/**
27
- * A `Callable` is within same package as the `RefType`
27
+ * Holds if a `Callable` is within same package as the `RefType`
28
28
*/
29
29
predicate isWithinPackage ( Expr e , RefType t ) {
30
30
e .getCompilationUnit ( ) .getPackage ( ) = t .getPackage ( )
31
31
}
32
32
33
+ /**
34
+ * Holds if a nested class is within a static context
35
+ */
33
36
predicate withinStaticContext ( NestedClass c ) {
34
37
c .isStatic ( ) or
35
38
c .( AnonymousClass ) .getClassInstanceExpr ( ) .getEnclosingCallable ( ) .isStatic ( ) // JLS 15.9.2
36
39
}
37
40
41
+ /**
42
+ * Gets the enclosing instance type for a non-static inner class
43
+ */
38
44
RefType enclosingInstanceType ( Class inner ) {
39
45
not withinStaticContext ( inner ) and
40
46
result = inner .( NestedClass ) .getEnclosingType ( )
41
47
}
42
48
49
+ /**
50
+ * A class that encloses one or more inner classes
51
+ */
43
52
class OuterClass extends Class {
44
53
OuterClass ( ) { this = enclosingInstanceType + ( _) }
45
54
}
46
55
47
56
/**
48
- * An innerclass is accessed outside of its outerclass
57
+ * Holds if an innerclass is accessed outside of its outerclass
49
58
* and also outside of its fellow inner parallel classes
50
59
*/
51
60
predicate isWithinDirectOuterClassOrSiblingInner (
You can’t perform that action at this time.
0 commit comments