17#ifndef A11_FLOW_DIAGNOSTIC_H_
18#define A11_FLOW_DIAGNOSTIC_H_
25#include <absl/types/span.h>
154 absl::Span<const Diagnostic> diagnostics);
169 explicit LineIndex(std::string_view source);
178 [[nodiscard]]
size_t LineCount()
const {
return line_starts_.size(); }
186 std::string_view source_;
188 std::vector<size_t> line_starts_;
Line and column lookup over one source text.
Definition diagnostic.h:167
Range Between(size_t start, size_t end) const
A range from two byte offsets.
Definition diagnostic.cc:398
size_t LineCount() const
How many lines the source has, counting a trailing partial line.
Definition diagnostic.h:178
Position At(size_t offset) const
The position at a byte offset, clamped to the end of the source.
Definition diagnostic.cc:376
size_t LineStart(int line) const
The byte offset the 1-based line starts at, clamped to the source.
Definition diagnostic.cc:405
size_t end
Definition discover.cc:115
Definition boundary.cc:32
Family
The kind of problem, which is the grouping a reader thinks in.
Definition diagnostic.h:50
@ kForm
A form the language does not have, or does not have there.
@ kSyntax
The text is not a flow: something is missing or in the wrong place.
@ kUnused
A status, wait or declaration nothing uses.
@ kSequence
A sequence of operations that cannot do what it appears to.
@ kName
A name that cannot be resolved, or is used as the wrong thing.
void SortDiagnostics(std::vector< Diagnostic > &diagnostics)
Sorts diagnostics into the order every frontend presents them in: by position, then by code,...
Definition diagnostic.cc:416
Severity SeverityFromName(std::string_view name)
Severity for a name from the output formats, or kError if unknown.
Definition diagnostic.cc:308
@ kBarrier
A bound wait/drain.
Severity
How much a diagnostic matters.
Definition diagnostic.h:34
@ kInformation
Non-blocking information.
@ kWeakWarning
The flow works, and part of it is doing nothing.
@ kError
The compiler refuses the flow. a11 flow check exits non-zero.
@ kWarning
The flow compiles and does something other than what it says.
absl::Span< const CodeInfo > KnownCodes()
Every diagnostic code the language can produce, sorted by code.
Definition diagnostic.cc:350
const CodeInfo *absl_nullable FindCode(std::string_view code)
The entry for a code, or nullptr if nothing publishes it.
Definition diagnostic.cc:354
std::string_view SeverityName(Severity severity)
The spelling of a severity in the output formats.
Definition diagnostic.cc:276
std::string_view FamilyName(Family family)
The spelling of a family in the output formats.
Definition diagnostic.cc:290
Family FamilyFromName(std::string_view name)
Family for a name from the output formats, or kSyntax if unknown.
Definition diagnostic.cc:321
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:340
What a diagnostic code means, for documentation and for a11 flow codes.
Definition diagnostic.h:140
Family family
Definition diagnostic.h:142
std::string_view summary
One line, in the imperative-free "what is wrong" voice: this is what a --help-style listing shows nex...
Definition diagnostic.h:146
Severity severity
Definition diagnostic.h:143
std::string_view code
Definition diagnostic.h:141
One problem found in a flow.
Definition diagnostic.h:108
std::string code
A stable dotted identifier, e.g.
Definition diagnostic.h:112
std::string flow
The flow the problem is in, where the text got far enough to say.
Definition diagnostic.h:119
std::vector< Fix > fixes
Definition diagnostic.h:120
Severity severity
Definition diagnostic.h:113
std::string message
One sentence, in the language's own terms, ending in a full stop.
Definition diagnostic.h:117
Family family
Definition diagnostic.h:114
Range range
Definition diagnostic.h:115
One replacement of a span of source. An empty text is a deletion.
Definition diagnostic.h:85
size_t end
Definition diagnostic.h:87
std::string text
Definition diagnostic.h:88
size_t start
Definition diagnostic.h:86
An edit, or set of edits, that would fix a diagnostic.
Definition diagnostic.h:97
std::string label
Definition diagnostic.h:98
std::vector< Edit > edits
Definition diagnostic.h:99
One place in the source: the byte offset, and the line and column at it.
Definition diagnostic.h:72
int line
Definition diagnostic.h:74
size_t offset
Definition diagnostic.h:73
int column
Definition diagnostic.h:75
Half-open span of source, [start, end).
Definition diagnostic.h:79
Position start
Definition diagnostic.h:80
Position end
Definition diagnostic.h:81
int line
Definition main.cc:70
long long offset
Definition main.cc:69