@@ -226,15 +226,20 @@ class DeviationAttribute extends StdAttribute {
226
226
227
227
DeviationRecord getADeviationRecord ( ) { result = record }
228
228
229
- pragma [ nomagic ]
230
- Element getASuppressedElement ( ) {
229
+ /** Gets the element to which this attribute was applied. */
230
+ Element getPrimarySuppressedElement ( ) {
231
231
result .( Type ) .getAnAttribute ( ) = this
232
232
or
233
233
result .( Stmt ) .getAnAttribute ( ) = this
234
234
or
235
235
result .( Variable ) .getAnAttribute ( ) = this
236
236
or
237
237
result .( Function ) .getAnAttribute ( ) = this
238
+ }
239
+
240
+ pragma [ nomagic]
241
+ Element getASuppressedElement ( ) {
242
+ result = this .getPrimarySuppressedElement ( )
238
243
or
239
244
result .( Expr ) .getEnclosingStmt ( ) = this .getASuppressedElement ( )
240
245
or
@@ -336,26 +341,60 @@ class CodeIdentifierDeviation extends TCodeIndentifierDeviation {
336
341
)
337
342
}
338
343
344
+ predicate hasLocationInfo (
345
+ string filepath , int suppressedLine , int suppressedColumn , int endline , int endcolumn
346
+ ) {
347
+ exists ( Comment commentMarker |
348
+ this = TSingleLineDeviation ( _, commentMarker , filepath , suppressedLine ) and
349
+ suppressedColumn = 1 and
350
+ endline = suppressedLine
351
+ |
352
+ if commentMarker instanceof DeviationEndOfLineMarker
353
+ then endcolumn = commentMarker .( DeviationEndOfLineMarker ) .getLocation ( ) .getEndColumn ( )
354
+ else
355
+ // Find the last column for a location on the next line
356
+ endcolumn =
357
+ max ( Location l |
358
+ l .hasLocationInfo ( filepath , _, _, _, _) and
359
+ l .getEndLine ( ) = suppressedLine
360
+ |
361
+ l .getEndColumn ( )
362
+ )
363
+ )
364
+ or
365
+ this = TMultiLineDeviation ( _, _, _, filepath , suppressedLine , endline ) and
366
+ suppressedColumn = 1 and
367
+ endcolumn = 1
368
+ or
369
+ exists ( DeviationAttribute attribute |
370
+ this = TCodeIdentifierDeviation ( _, attribute ) and
371
+ attribute
372
+ .getPrimarySuppressedElement ( )
373
+ .getLocation ( )
374
+ .hasLocationInfo ( filepath , suppressedLine , suppressedColumn , endline , endcolumn )
375
+ )
376
+ }
377
+
339
378
string toString ( ) {
340
379
exists ( string filepath |
341
380
exists ( int suppressedLine |
342
381
this = TSingleLineDeviation ( _, _, filepath , suppressedLine ) and
343
382
result =
344
- "Deviation record " + getADeviationRecord ( ) + " applied to " + filepath + " Line " +
383
+ "Deviation of " + getADeviationRecord ( ) . getQuery ( ) + " applied to " + filepath + " Line " +
345
384
suppressedLine
346
385
)
347
386
or
348
387
exists ( int suppressedStartLine , int suppressedEndLine |
349
388
this = TMultiLineDeviation ( _, _, _, filepath , suppressedStartLine , suppressedEndLine ) and
350
389
result =
351
- "Deviation record " + getADeviationRecord ( ) + " applied to " + filepath + " Line" +
390
+ "Deviation of " + getADeviationRecord ( ) . getQuery ( ) + " applied to " + filepath + " Line " +
352
391
suppressedStartLine + ":" + suppressedEndLine
353
392
)
354
393
)
355
394
or
356
395
exists ( DeviationAttribute attribute |
357
396
this = TCodeIdentifierDeviation ( _, attribute ) and
358
- result = "Deviation record " + getADeviationRecord ( ) + " applied to " + attribute
397
+ result = "Deviation of " + getADeviationRecord ( ) . getQuery ( ) + " applied to " + attribute
359
398
)
360
399
}
361
400
}
0 commit comments