File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
java/ql/src/Violations of Best Practice/Naming Conventions Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,21 @@ predicate setterFor(Method m, Field f) {
20
20
predicate shadows ( LocalVariableDecl d , Class c , Field f , Callable method ) {
21
21
d .getCallable ( ) = method and
22
22
method .getDeclaringType ( ) = c and
23
- c .getAField ( ) = f and
24
- f .getName ( ) = d .getName ( ) and
25
- f .getType ( ) = d .getType ( ) and
26
- not d .getCallable ( ) .isStatic ( ) and
23
+ f = getField ( c , d .getName ( ) , d .getType ( ) ) and
24
+ not method .isStatic ( ) and
27
25
not f .isStatic ( )
28
26
}
29
27
28
+ /**
29
+ * Gets the field with the given name and type from the given class, if any.
30
+ */
31
+ pragma [ nomagic]
32
+ private Field getField ( Class c , string name , Type t ) {
33
+ result .getDeclaringType ( ) = c and
34
+ result .getName ( ) = name and
35
+ result .getType ( ) = t
36
+ }
37
+
30
38
predicate thisAccess ( LocalVariableDecl d , Field f ) {
31
39
shadows ( d , _, f , _) and
32
40
exists ( VarAccess va | va .getVariable ( ) .( Field ) .getSourceDeclaration ( ) = f |
You can’t perform that action at this time.
0 commit comments