MCPcopy Create free account
hub / github.com/argotorg/solidity / SourceReferenceFormatter

Class SourceReferenceFormatter

liblangutil/SourceReferenceFormatter.h:40–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38struct SourceLocation;
39
40class SourceReferenceFormatter
41{
42public:
43 SourceReferenceFormatter(
44 std::ostream& _stream,
45 CharStreamProvider const& _charStreamProvider,
46 bool _colored,
47 bool _withErrorIds
48 ):
49 m_stream(_stream),
50 m_charStreamProvider(_charStreamProvider),
51 m_colored(_colored),
52 m_withErrorIds(_withErrorIds)
53 {}
54
55 // WARNING: Use the xyzErrorInformation() variants over xyzExceptionInformation() when you
56 // do have access to an Error instance. Error is implicitly convertible to util::Exception
57 // but the conversion loses the error ID.
58
59 /// Prints source location if it is given.
60 void printSourceLocation(SourceReference const& _ref);
61 void printExceptionInformation(SourceReferenceExtractor::Message const& _msg);
62 void printExceptionInformation(util::Exception const& _exception, Error::Type _type);
63 void printExceptionInformation(util::Exception const& _exception, Error::Severity _severity);
64 void printErrorInformation(langutil::ErrorList const& _errors);
65 void printErrorInformation(Error const& _error);
66
67 static std::string formatExceptionInformation(
68 util::Exception const& _exception,
69 Error::Type _type,
70 CharStreamProvider const& _charStreamProvider,
71 bool _colored = false
72 )
73 {
74 std::ostringstream errorOutput;
75 SourceReferenceFormatter formatter(errorOutput, _charStreamProvider, _colored, false /* _withErrorIds */);
76 formatter.printExceptionInformation(_exception, _type);
77 return errorOutput.str();
78 }
79
80 static std::string formatExceptionInformation(
81 util::Exception const& _exception,
82 Error::Severity _severity,
83 CharStreamProvider const& _charStreamProvider,
84 bool _colored = false
85 )
86 {
87 std::ostringstream errorOutput;
88 SourceReferenceFormatter formatter(errorOutput, _charStreamProvider, _colored, false /* _withErrorIds */);
89 formatter.printExceptionInformation(_exception, _severity);
90 return errorOutput.str();
91 }
92
93 static std::string formatErrorInformation(
94 Error const& _error,
95 CharStreamProvider const& _charStreamProvider,
96 bool _colored = false,
97 bool _withErrorIds = false

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected