Skip to content

Commit bdb4d89

Browse files
committed
Rust: add Diagnostics.qll
1 parent b04abc0 commit bdb4d89

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

config/identical-files.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,9 @@
355355
"Python model summaries test extension": [
356356
"python/ql/test/library-tests/dataflow/model-summaries/InlineTaintTest.ext.yml",
357357
"python/ql/test/library-tests/dataflow/model-summaries/NormalDataflowTest.ext.yml"
358+
],
359+
"Diagnostics.qll": [
360+
"ruby/ql/lib/codeql/ruby/Diagnostics.qll",
361+
"rust/ql/lib/codeql/rust/Diagnostics.qll"
358362
]
359363
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
private import codeql.Locations
2+
3+
/** A diagnostic emitted during extraction, such as a parse error */
4+
class Diagnostic extends @diagnostic {
5+
int severity;
6+
string tag;
7+
string message;
8+
string fullMessage;
9+
Location location;
10+
11+
Diagnostic() { diagnostics(this, severity, tag, message, fullMessage, location) }
12+
13+
/**
14+
* Gets the numerical severity level associated with this diagnostic.
15+
*/
16+
int getSeverity() { result = severity }
17+
18+
/** Gets a string representation of the severity of this diagnostic. */
19+
string getSeverityText() {
20+
severity = 10 and result = "Debug"
21+
or
22+
severity = 20 and result = "Info"
23+
or
24+
severity = 30 and result = "Warning"
25+
or
26+
severity = 40 and result = "Error"
27+
}
28+
29+
/** Gets the error code associated with this diagnostic, e.g. parse_error. */
30+
string getTag() { result = tag }
31+
32+
/**
33+
* Gets the error message text associated with this diagnostic.
34+
*/
35+
string getMessage() { result = message }
36+
37+
/**
38+
* Gets the full error message text associated with this diagnostic.
39+
*/
40+
string getFullMessage() { result = fullMessage }
41+
42+
/** Gets the source location of this diagnostic. */
43+
Location getLocation() { result = location }
44+
45+
/** Gets a textual representation of this diagnostic. */
46+
string toString() { result = this.getMessage() }
47+
}
48+
49+
/** A diagnostic relating to a particular error in extracting a file. */
50+
class ExtractionError extends Diagnostic {
51+
ExtractionError() { this.getTag() = "parse_error" }
52+
}

0 commit comments

Comments
 (0)