33 */
44
55import java
6+ import semmle.code.java.Diagnostics
67
78/** Gets the SARIF severity level that indicates an error. */
89private int getErrorSeverity ( ) { result = 2 }
910
1011/** Gets the SARIF severity level that indicates a warning. */
1112private int getWarnSeverity ( ) { result = 1 }
1213
13- private predicate knownWarnings ( @diagnostic d , string msg , int sev ) {
14+ private predicate knownWarnings ( Diagnostic d , string msg , int sev ) {
1415 exists ( string filename |
15- diagnostics ( d , _, 2 , _, "Skipping Lombok-ed source file: " + filename , _, _) and
16+ d .getSeverity ( ) = 2 and
17+ d .getMessage ( ) = "Skipping Lombok-ed source file: " + filename and
1618 msg = "Use of Lombok detected. Skipping file: " + filename and
1719 sev = getWarnSeverity ( )
1820 )
1921}
2022
21- private predicate knownErrors ( @diagnostic d , string msg , int sev ) {
23+ private predicate knownErrors ( Diagnostic d , string msg , int sev ) {
2224 exists ( string numErr , Location l |
23- diagnostics ( d , _, 6 , _, numErr , _, l ) and
25+ d .getSeverity ( ) = 6 and
26+ d .getMessage ( ) = numErr and
27+ d .getLocation ( ) = l and
2428 msg = "Frontend errors in file: " + l .getFile ( ) .getAbsolutePath ( ) + " (" + numErr + ")" and
2529 sev = getErrorSeverity ( )
2630 )
2731 or
28- exists ( string filename , Location l |
29- diagnostics ( d , _, 7 , _, "Exception compiling file " + filename , _, l ) and
32+ exists ( string filename |
33+ d .getSeverity ( ) = 7 and
34+ d .getMessage ( ) = "Exception compiling file " + filename and
3035 msg = "Extraction incomplete in file: " + filename and
3136 sev = getErrorSeverity ( )
3237 )
3338 or
34- exists ( string errMsg , Location l |
35- diagnostics ( d , _, 8 , _, errMsg , _, l ) and
39+ exists ( string errMsg |
40+ d .getSeverity ( ) = 8 and
41+ d .getMessage ( ) = errMsg and
3642 msg = "Severe error: " + errMsg and
3743 sev = getErrorSeverity ( )
3844 )
3945}
4046
41- private predicate unknownErrors ( @diagnostic d , string msg , int sev ) {
47+ private predicate unknownErrors ( Diagnostic d , string msg , int sev ) {
4248 not knownErrors ( d , _, _) and
43- exists ( Location l , File f , int diagSev |
44- diagnostics ( d , _, diagSev , _, _, _, l ) and l .getFile ( ) = f and diagSev > 3
49+ exists ( File f , int diagSev |
50+ d .getSeverity ( ) = diagSev and
51+ d .getLocation ( ) .getFile ( ) = f and diagSev > 3
4552 |
4653 exists ( f .getRelativePath ( ) ) and
4754 msg = "Unknown errors in file: " + f .getAbsolutePath ( ) + " (" + diagSev + ")" and
@@ -53,31 +60,31 @@ private predicate unknownErrors(@diagnostic d, string msg, int sev) {
5360 * Holds if an extraction error or warning occurred that should be reported to end users,
5461 * with the message `msg` and SARIF severity `sev`.
5562 */
56- predicate reportableDiagnostics ( @diagnostic d , string msg , int sev ) {
63+ predicate reportableDiagnostics ( Diagnostic d , string msg , int sev ) {
5764 reportableWarnings ( d , msg , sev ) or reportableErrors ( d , msg , sev )
5865}
5966
6067/**
6168 * Holds if an extraction error occurred that should be reported to end users,
6269 * with the message `msg` and SARIF severity `sev`.
6370 */
64- predicate reportableErrors ( @diagnostic d , string msg , int sev ) {
71+ predicate reportableErrors ( Diagnostic d , string msg , int sev ) {
6572 knownErrors ( d , msg , sev ) or unknownErrors ( d , msg , sev )
6673}
6774
6875/**
6976 * Holds if an extraction warning occurred that should be reported to end users,
7077 * with the message `msg` and SARIF severity `sev`.
7178 */
72- predicate reportableWarnings ( @diagnostic d , string msg , int sev ) { knownWarnings ( d , msg , sev ) }
79+ predicate reportableWarnings ( Diagnostic d , string msg , int sev ) { knownWarnings ( d , msg , sev ) }
7380
7481/**
7582 * Holds if compilation unit `f` is a source file that has
7683 * no relevant extraction diagnostics associated with it.
7784 */
7885predicate successfullyExtracted ( CompilationUnit f ) {
79- not exists ( @diagnostic d , Location l |
80- reportableDiagnostics ( d , _, _) and diagnostics ( d , _ , _ , _ , _ , _ , l ) and l .getFile ( ) = f
86+ not exists ( Diagnostic d |
87+ reportableDiagnostics ( d , _, _) and d . getLocation ( ) .getFile ( ) = f
8188 ) and
8289 exists ( f .getRelativePath ( ) ) and
8390 f .fromSource ( )
0 commit comments