@@ -30,12 +30,39 @@ class SuppressionAnnotation extends SuppressWarningsAnnotation {
3030 /** Gets the LGTM suppression annotation in this Java annotation. */
3131 string getAnnotation ( ) { result = annotation }
3232
33+ private Annotation getASiblingAnnotation ( ) {
34+ result = getAnnotatedElement ( ) .( Annotatable ) .getAnAnnotation ( ) and
35+ ( getAnnotatedElement ( ) instanceof Callable or getAnnotatedElement ( ) instanceof RefType )
36+ }
37+
38+ private Annotation firstAnnotation ( ) {
39+ exists ( Annotation m , int i |
40+ result = m and
41+ m = getASiblingAnnotation ( ) and
42+ i = rankOfAnnotation ( m ) and
43+ not exists ( Annotation other | other = getASiblingAnnotation ( ) | rankOfAnnotation ( other ) < i )
44+ )
45+ }
46+
47+ private int rankOfAnnotation ( Annotation m ) {
48+ this .getASiblingAnnotation ( ) = m and
49+ exists ( Location mLoc , File f , int maxCol | mLoc = m .getLocation ( ) |
50+ f = mLoc .getFile ( ) and
51+ maxCol = max ( Location loc | loc .getFile ( ) = f | loc .getStartColumn ( ) ) and
52+ result = mLoc .getStartLine ( ) * maxCol + mLoc .getStartColumn ( )
53+ )
54+ }
55+
3356 /**
3457 * Holds if this annotation applies to the range from column `startcolumn` of line `startline`
3558 * to column `endcolumn` of line `endline` in file `filepath`.
3659 */
3760 predicate covers ( string filepath , int startline , int startcolumn , int endline , int endcolumn ) {
38- getAnnotatedElement ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn )
61+ if firstAnnotation ( ) .hasLocationInfo ( filepath , _, _, _, _)
62+ then
63+ getAnnotatedElement ( ) .hasLocationInfo ( filepath , _, _, endline , endcolumn ) and
64+ firstAnnotation ( ) .hasLocationInfo ( filepath , startline , startcolumn , _, _)
65+ else getAnnotatedElement ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn )
3966 }
4067
4168 /** Gets the scope of this suppression. */
0 commit comments