1010#define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
1111
1212#include " lldb/Host/StreamFile.h"
13+ #include " lldb/Utility/DiagnosticsRendering.h"
1314#include " lldb/Utility/StreamString.h"
1415#include " lldb/Utility/StreamTee.h"
16+ #include " lldb/Utility/StructuredData.h"
1517#include " lldb/lldb-private.h"
1618
1719#include " llvm/ADT/StringRef.h"
@@ -29,19 +31,23 @@ class CommandReturnObject {
2931
3032 ~CommandReturnObject () = default ;
3133
32- llvm::StringRef GetOutputData () {
34+ // / Format any inline diagnostics with an indentation of \c indent.
35+ std::string GetInlineDiagnosticString (unsigned indent);
36+
37+ llvm::StringRef GetOutputString () {
3338 lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex));
3439 if (stream_sp)
3540 return std::static_pointer_cast<StreamString>(stream_sp)->GetString ();
3641 return llvm::StringRef ();
3742 }
3843
39- llvm::StringRef GetErrorData () {
40- lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex));
41- if (stream_sp)
42- return std::static_pointer_cast<StreamString>(stream_sp)->GetString ();
43- return llvm::StringRef ();
44- }
44+ // / Return the errors as a string.
45+ // /
46+ // / If \c with_diagnostics is true, all diagnostics are also
47+ // / rendered into the string. Otherwise the expectation is that they
48+ // / are fetched with \ref GetInlineDiagnosticString().
49+ std::string GetErrorString (bool with_diagnostics = true );
50+ StructuredData::ObjectSP GetErrorData ();
4551
4652 Stream &GetOutputStream () {
4753 // Make sure we at least have our normal string stream output stream
@@ -131,10 +137,18 @@ class CommandReturnObject {
131137 AppendError (llvm::formatv (format, std::forward<Args>(args)...).str ());
132138 }
133139
134- void SetError (const Status & error, const char *fallback_error_cstr = nullptr );
140+ void SetError (Status error);
135141
136142 void SetError (llvm::Error error);
137143
144+ void SetDiagnosticIndent (std::optional<uint16_t > indent) {
145+ m_diagnostic_indent = indent;
146+ }
147+
148+ std::optional<uint16_t > GetDiagnosticIndent () const {
149+ return m_diagnostic_indent;
150+ }
151+
138152 lldb::ReturnStatus GetStatus () const ;
139153
140154 void SetStatus (lldb::ReturnStatus status);
@@ -160,6 +174,8 @@ class CommandReturnObject {
160174
161175 StreamTee m_out_stream;
162176 StreamTee m_err_stream;
177+ std::vector<DiagnosticDetail> m_diagnostics;
178+ std::optional<uint16_t > m_diagnostic_indent;
163179
164180 lldb::ReturnStatus m_status = lldb::eReturnStatusStarted;
165181
@@ -168,6 +184,7 @@ class CommandReturnObject {
168184
169185 // / If true, then the input handle from the debugger will be hooked up.
170186 bool m_interactive = true ;
187+ bool m_colors;
171188};
172189
173190} // namespace lldb_private
0 commit comments