@@ -82,6 +82,21 @@ module AlertFilteringImpl<LocationSig Location> {
8282 )
8383 }
8484
85+ /** Holds if diff information is available in this evaluation. */
86+ predicate diffInformationAvailable ( ) {
87+ restrictAlertsTo ( _, _, _) or restrictAlertsToExactLocation ( _, _, _, _, _)
88+ }
89+
90+ /**
91+ * Holds if diff information is available, and `filePath` is in the diff
92+ * range.
93+ */
94+ predicate fileIsInDiff ( string filePath ) {
95+ restrictAlertsTo ( filePath , _, _)
96+ or
97+ restrictAlertsToExactLocation ( filePath , _, _, _, _)
98+ }
99+
85100 /**
86101 * Holds if the given location is a match for one of the active filtering
87102 * predicates in this module, or if all filtering predicates are inactive
@@ -92,8 +107,17 @@ module AlertFilteringImpl<LocationSig Location> {
92107 */
93108 bindingset [ location]
94109 predicate filterByLocation ( Location location ) {
95- not restrictAlertsTo ( _ , _ , _ ) and not restrictAlertsToExactLocation ( _ , _ , _ , _ , _ )
110+ not diffInformationAvailable ( )
96111 or
112+ locationIsInDiff ( location )
113+ }
114+
115+ /**
116+ * Like `filterByLocation`, except that if there is no diff range, this
117+ * predicate never holds.
118+ */
119+ bindingset [ location]
120+ predicate locationIsInDiff ( Location location ) {
97121 exists ( string filePath |
98122 restrictAlertsToEntireFile ( filePath ) and
99123 location .hasLocationInfo ( filePath , _, _, _, _)
0 commit comments