Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion java/ql/consistency-queries/diags.ql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ string diagnosticMessage(Diagnostic d) {
// something is fixed.
query predicate unusedDiagnosticException(DiagnosticException de) { not exists(de.getException()) }

query predicate unexpectedDiagnostic(Diagnostic d, string s) {
query predicate unexpectedDiagnostic(Compilation c, int f, int i, Diagnostic d, string s) {
d.getCompilationInfo(c, f, i) and
s = diagnosticMessage(d) and
not d = any(DiagnosticException de).getException()
}
4 changes: 4 additions & 0 deletions java/ql/lib/change-notes/2023-07-14-getCompilationInfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: feature
---
* A `Diagnostic.getCompilationInfo()` predicate has been added.
5 changes: 5 additions & 0 deletions java/ql/lib/semmle/code/java/Diagnostics.qll
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class Diagnostic extends @diagnostic {
/** Gets the compilation that generated this diagnostic. */
Compilation getCompilation() { diagnostic_for(this, result, _, _) }

/** Gets the compilation information for this diagnostic. */
predicate getCompilationInfo(Compilation c, int fileNumber, int diagnosticNumber) {
diagnostic_for(this, c, fileNumber, diagnosticNumber)
}

/**
* Gets the program that generated this diagnostic.
*/
Expand Down