|
| 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