Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for manipulating Diagnostic
s, which represent
diagnostics - warnings, errors, and the like - produced by libclang.
Diagnostic
s are grouped into DiagnosticSet
s. You
usually obtain a DiagnosticSet
from a TranslationUnit
using getDiagnosticSet
, and then analyze it
using the functions in this module.
This module is intended to be imported qualified.
- getElements :: ClangBase m => DiagnosticSet s' -> ClangT s m [Diagnostic s]
- getChildren :: ClangBase m => Diagnostic s' -> ClangT s m (DiagnosticSet s)
- getSeverity :: ClangBase m => Diagnostic s' -> ClangT s m Severity
- data Severity
- getSpelling :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s)
- getOptions :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s, ClangString s)
- getCategoryName :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s)
- getCategoryId :: ClangBase m => Diagnostic s' -> ClangT s m Int
- getRanges :: ClangBase m => Diagnostic s' -> ClangT s m [SourceRange s]
- getFixIts :: ClangBase m => Diagnostic s' -> ClangT s m [(SourceRange s, ClangString s)]
- format :: ClangBase m => Maybe [DisplayOptions] -> Diagnostic s' -> ClangT s m (ClangString s)
- data DisplayOptions
- load :: ClangBase m => FilePath -> ClangT s m (Either (LoadError, ClangString s) (DiagnosticSet s))
- data LoadError
Diagnostic sets
getElements :: ClangBase m => DiagnosticSet s' -> ClangT s m [Diagnostic s] Source
Retrieve the diagnostics contained in the given DiagnosticSet
.
You can obtain a DiagnosticSet
from a TranslationUnit
using getDiagnosticSet
, or by deserializing
it from a file using load
.
Diagnostics
getChildren :: ClangBase m => Diagnostic s' -> ClangT s m (DiagnosticSet s) Source
Get the child diagnostics of the given diagnostic.
getSeverity :: ClangBase m => Diagnostic s' -> ClangT s m Severity Source
Determine the severity of the given diagnostic.
The severity of a diagnostic.
getSpelling :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s) Source
Retrieve the text of the given diagnostic.
:: ClangBase m | |
=> Diagnostic s' | The diagnostic in question. |
-> ClangT s m (ClangString s, ClangString s) | The options controlling this diagnostic. The first member of the pair is the option to enable this diagnostic. The second member is the option to disable it. |
Retrieve the name of the command-line option that enabled this diagnostic.
getCategoryName :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s) Source
Get the name of the diagnostic category for the given diagnostic.
Diagnostics are categorized into groups along with other, related diagnostics (e.g., diagnostics under the same warning flag).
getCategoryId :: ClangBase m => Diagnostic s' -> ClangT s m Int Source
Retrieve the category id for this diagnostic.
For display to the user, use getCategoryName
.
getRanges :: ClangBase m => Diagnostic s' -> ClangT s m [SourceRange s] Source
Retrieve the source ranges associated with this diagnostic.
A diagnostic's source ranges highlight important elements in the source code. On the command line, Clang displays source ranges by underlining them with '~' characters.
:: ClangBase m | |
=> Diagnostic s' | The diagnostic in question. |
-> ClangT s m [(SourceRange s, ClangString s)] | A list of replacement
ranges and strings. Note
that source ranges are
half-open ranges '[a, b)'
so the source code should
be replaced from |
Retrieve the fix-it hints associated with the given diagnostic.
Fix-its are described in terms of a source range whose contents should be replaced by a string. This approach generalizes over three kinds of operations: removal of source code (the range covers the code to be removed and the replacement string is empty), replacement of source code (the range covers the code to be replaced and the replacement string provides the new code), and insertion (both the start and end of the range point at the insertion location, and the replacement string provides the text to insert).
Rendering diagnostics
:: ClangBase m | |
=> Maybe [DisplayOptions] | An optional list of options
for rendering the diagnostic.
If |
-> Diagnostic s' | The diagnostic to format. |
-> ClangT s m (ClangString s) | A formatted rendering of the given diagnostic. |
Format the given diagnostic in a manner that is suitable for display.
data DisplayOptions Source
Options for rendering of Diagnostic
values.
Deserializing diagnostics
load :: ClangBase m => FilePath -> ClangT s m (Either (LoadError, ClangString s) (DiagnosticSet s)) Source
Deserialize a set of diagnostics from a Clang diagnostics bitcode file.
If an error is encountered, a LoadError
and a textual error
message suitable for display to the user are returned.