17#ifndef A11_FLOW_DIAGNOSTIC_H_
18#define A11_FLOW_DIAGNOSTIC_H_
25#include <absl/types/span.h>
145 absl::Span<const Diagnostic> diagnostics);
163 std::string_view
source()
const {
return source_; }
172 [[nodiscard]]
size_t LineCount()
const {
return line_starts_.size(); }
180 std::string_view source_;
182 std::vector<size_t> line_starts_;
Line and column lookup over one source text.
Definition diagnostic.h:158
Range Between(size_t start, size_t end) const
A range from two byte offsets.
Definition diagnostic.cc:454
size_t LineCount() const
How many lines the source has, counting a trailing partial line.
Definition diagnostic.h:172
std::string_view source() const
The borrowed document used to compute positions.
Definition diagnostic.h:163
Position At(size_t offset) const
The position at a byte offset, clamped to the end of the source.
Definition diagnostic.cc:432
size_t LineStart(int line) const
The byte offset the 1-based line starts at, clamped to the source.
Definition diagnostic.cc:461
size_t end
Definition discover.cc:101
size_t start
Definition module.cc:56
Definition catalogue.cc:29
Family
Diagnostic category used by editors and build gates.
Definition diagnostic.h:42
@ kForm
Invalid language form or form in an invalid position.
@ kSyntax
Missing or misplaced Flow syntax.
@ kUnused
Unread status, unused binding, or unused declaration.
@ kSequence
Stage or access sequence with invalid or ineffective behavior.
@ kName
Unresolved name or invalid use of a resolved name.
void SortDiagnostics(std::vector< Diagnostic > &diagnostics)
Sorts diagnostics into the order every frontend presents them in: by position, then by code,...
Definition diagnostic.cc:472
Severity SeverityFromName(std::string_view name)
Severity for a name from the output formats, or kError if unknown.
Definition diagnostic.cc:364
@ kBarrier
A bound wait/close.
Severity
Severity of a Flow diagnostic.
Definition diagnostic.h:30
@ kInformation
Non-blocking information.
@ kWeakWarning
Compilation succeeds, but a source element has no effect.
@ kError
Compilation fails. a11 flow check exits nonzero.
@ kWarning
Compilation succeeds, but behavior may differ from the source's intent.
absl::Span< const CodeInfo > KnownCodes()
Every diagnostic code the language can produce, sorted by code.
Definition diagnostic.cc:406
const CodeInfo *absl_nullable FindCode(std::string_view code)
The entry for a code, or nullptr if nothing publishes it.
Definition diagnostic.cc:410
std::string_view SeverityName(Severity severity)
The spelling of a severity in the output formats.
Definition diagnostic.cc:332
std::string_view FamilyName(Family family)
The spelling of a family in the output formats.
Definition diagnostic.cc:346
Family FamilyFromName(std::string_view name)
Family for a name from the output formats, or kSyntax if unknown.
Definition diagnostic.cc:377
const Diagnostic *absl_nullable FirstError(absl::Span< const Diagnostic > diagnostics)
The first error in diagnostics, or nullptr if none is an error.
Definition diagnostic.cc:396
std::uint32_t offset
Definition runtime_streams.cc:36
Published diagnostic code metadata for documentation and a11 flow codes.
Definition diagnostic.h:132
Family family
Definition diagnostic.h:134
std::string_view summary
One-line summary shown beside the code in catalogue listings.
Definition diagnostic.h:137
Severity severity
Definition diagnostic.h:135
std::string_view code
Definition diagnostic.h:133
Flow problem rendered by the CLI, JSON and SARIF writers, and editors.
Definition diagnostic.h:99
std::vector< RelatedDiagnostic > related
Definition diagnostic.h:113
std::string source
Definition diagnostic.h:100
std::string code
A stable dotted identifier, e.g.
Definition diagnostic.h:104
std::string flow
Enclosing flow name when parsing or resolution identifies one.
Definition diagnostic.h:111
std::vector< Fix > fixes
Definition diagnostic.h:112
Severity severity
Definition diagnostic.h:105
std::string message
One sentence, in the language's own terms, ending in a full stop.
Definition diagnostic.h:109
Family family
Definition diagnostic.h:106
Range range
Definition diagnostic.h:107
One replacement of a span of source. An empty text is a deletion.
Definition diagnostic.h:74
size_t end
Definition diagnostic.h:76
std::string text
Definition diagnostic.h:77
size_t start
Definition diagnostic.h:75
Source edits supplied with a diagnostic.
Definition diagnostic.h:83
std::string label
Definition diagnostic.h:84
std::vector< Edit > edits
Definition diagnostic.h:85
bool automatic
Definition diagnostic.h:86
Source position with a byte offset and 1-based line and column.
Definition diagnostic.h:61
int line
Definition diagnostic.h:63
size_t offset
Definition diagnostic.h:62
int column
Definition diagnostic.h:64
Half-open span of source, [start, end).
Definition diagnostic.h:68
Position start
Definition diagnostic.h:69
Position end
Definition diagnostic.h:70
int line
Definition main.cc:71