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 1515import java
1616
1717/**
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)
1919 */
2020predicate isWithinType ( Callable c , RefType t ) {
2121 c .getDeclaringType ( ) = t
@@ -24,28 +24,37 @@ predicate isWithinType(Callable c, RefType t) {
2424}
2525
2626/**
27- * A `Callable` is within same package as the `RefType`
27+ * Holds if a `Callable` is within same package as the `RefType`
2828 */
2929predicate isWithinPackage ( Expr e , RefType t ) {
3030 e .getCompilationUnit ( ) .getPackage ( ) = t .getPackage ( )
3131}
3232
33+ /**
34+ * Holds if a nested class is within a static context
35+ */
3336predicate withinStaticContext ( NestedClass c ) {
3437 c .isStatic ( ) or
3538 c .( AnonymousClass ) .getClassInstanceExpr ( ) .getEnclosingCallable ( ) .isStatic ( ) // JLS 15.9.2
3639}
3740
41+ /**
42+ * Gets the enclosing instance type for a non-static inner class
43+ */
3844RefType enclosingInstanceType ( Class inner ) {
3945 not withinStaticContext ( inner ) and
4046 result = inner .( NestedClass ) .getEnclosingType ( )
4147}
4248
49+ /**
50+ * A class that encloses one or more inner classes
51+ */
4352class OuterClass extends Class {
4453 OuterClass ( ) { this = enclosingInstanceType + ( _) }
4554}
4655
4756/**
48- * An innerclass is accessed outside of its outerclass
57+ * Holds if an innerclass is accessed outside of its outerclass
4958 * and also outside of its fellow inner parallel classes
5059 */
5160predicate isWithinDirectOuterClassOrSiblingInner (
You can’t perform that action at this time.
0 commit comments