19 return llvm::WithColor(strm.
AsRawOstream(), llvm::HighlightColor::Error,
20 llvm::ColorMode::Enable)
25 return llvm::WithColor(strm.
AsRawOstream(), llvm::HighlightColor::Warning,
26 llvm::ColorMode::Enable)
31 return llvm::WithColor(strm.
AsRawOstream(), llvm::HighlightColor::Note,
32 llvm::ColorMode::Enable)
37 bool add_newline =
false;
41 strm.
Write(s.c_str(), s.size());
43 const char last_char = *s.rbegin();
44 add_newline = last_char !=
'\n' && last_char !=
'\r';
51 : m_out_stream(colors), m_err_stream(colors), m_colors(colors) {}
59 va_start(args, format);
64 const std::string &s = std::string(sstrm.
GetString());
75 va_start(args, format);
87 va_start(args, format);
99 va_start(args, format);
108 if (in_string.empty())
114 if (in_string.empty())
120 if (in_string.empty())
127 if (in_string.empty())
130 llvm::StringRef msg(in_string.rtrim());
131 msg.consume_front(
"error: ");
162 if (with_diagnostics)
167 stream << std::static_pointer_cast<StreamString>(stream_sp)->GetString();
172 auto make_array = []() {
return std::make_unique<StructuredData::Array>(); };
173 auto make_bool = [](
bool b) {
174 return std::make_unique<StructuredData::Boolean>(b);
176 auto make_dict = []() {
177 return std::make_unique<StructuredData::Dictionary>();
179 auto make_int = [](
unsigned i) {
180 return std::make_unique<StructuredData::UnsignedInteger>(i);
182 auto make_string = [](llvm::StringRef s) {
183 return std::make_unique<StructuredData::String>(s);
185 auto dict_up = make_dict();
186 dict_up->AddItem(
"version", make_int(1));
187 auto array_up = make_array();
189 auto detail_up = make_dict();
190 if (
auto &sloc = diag.source_location) {
191 auto sloc_up = make_dict();
192 sloc_up->AddItem(
"file", make_string(sloc->file.GetPath()));
193 sloc_up->AddItem(
"line", make_int(sloc->line));
194 sloc_up->AddItem(
"length", make_int(sloc->length));
195 sloc_up->AddItem(
"hidden", make_bool(sloc->hidden));
196 sloc_up->AddItem(
"in_user_input", make_bool(sloc->in_user_input));
197 detail_up->AddItem(
"source_location", std::move(sloc_up));
199 llvm::StringRef severity =
"unknown";
200 switch (diag.severity) {
205 severity =
"warning";
211 detail_up->AddItem(
"severity", make_string(severity));
212 detail_up->AddItem(
"message", make_string(diag.message));
213 detail_up->AddItem(
"rendered", make_string(diag.rendered));
214 array_up->AddItem(std::move(detail_up));
216 dict_up->AddItem(
"details", std::move(array_up));
218 auto text = std::static_pointer_cast<StreamString>(stream_sp)->GetString();
220 dict_up->AddItem(
"text", make_string(text));
230 assert(!in_string.empty() &&
"Expected a non-empty error message");
static llvm::raw_ostream & error(Stream &strm)
static llvm::raw_ostream & warning(Stream &strm)
static void DumpStringToStreamWithNewline(Stream &strm, const std::string &s)
static llvm::raw_ostream & note(Stream &strm)
void AppendMessage(llvm::StringRef in_string)
bool GetInteractive() const
void void AppendError(llvm::StringRef in_string)
bool m_suppress_immediate_output
void void AppendNote(llvm::StringRef in_string)
bool m_did_change_process_state
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
bool GetDidChangeProcessState() const
bool m_interactive
If true, then the input handle from the debugger will be hooked up.
void SetSuppressImmediateOutput(bool b)
CommandReturnObject(bool colors)
void SetInteractive(bool b)
void AppendRawError(llvm::StringRef in_string)
Stream & GetErrorStream()
void SetStatus(lldb::ReturnStatus status)
std::string GetErrorString(bool with_diagnostics=true)
Return the errors as a string.
void SetError(Status error)
std::string GetInlineDiagnosticString(unsigned indent)
Format any inline diagnostics with an indentation of indent.
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
void SetDidChangeProcessState(bool b)
lldb::ReturnStatus GetStatus() const
StructuredData::ObjectSP GetErrorData()
std::vector< DiagnosticDetail > m_diagnostics
lldb::ReturnStatus m_status
bool GetSuppressImmediateOutput() const
void void AppendWarning(llvm::StringRef in_string)
void AppendNoteWithFormat(const char *format,...) __attribute__((format(printf
Stream & GetOutputStream()
llvm::StringRef GetString() const
lldb::StreamSP GetStreamAtIndex(uint32_t idx)
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t size_t PrintfVarArg(const char *format, va_list args)
size_t EOL()
Output and End of Line character to the stream.
std::shared_ptr< Object > ObjectSP
A class that represents a running process on the host machine.
void RenderDiagnosticDetails(Stream &stream, std::optional< uint16_t > offset_in_command, bool show_inline, llvm::ArrayRef< DiagnosticDetail > details)
std::shared_ptr< lldb_private::Stream > StreamSP
ReturnStatus
Command Return Status Types.
@ eReturnStatusSuccessContinuingResult
@ eReturnStatusSuccessFinishResult
A compiler-independent representation of an lldb_private::Diagnostic.