diff options
author | Christian Parpart <christian@ethereum.org> | 2018-11-30 21:34:08 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-12-06 21:01:01 +0800 |
commit | 073b03d90c8f0648ba135f0b30d8e72fd871478f (patch) | |
tree | b38bf2ef623bb1ac85bf9ca929ba61f76c05bd0d /liblangutil/SourceReferenceFormatter.h | |
parent | 6efe2a526691f42e83b11cf670ec3e7f51927b3e (diff) | |
download | dexon-solidity-073b03d90c8f0648ba135f0b30d8e72fd871478f.tar.gz dexon-solidity-073b03d90c8f0648ba135f0b30d8e72fd871478f.tar.zst dexon-solidity-073b03d90c8f0648ba135f0b30d8e72fd871478f.zip |
liblangutil: refactor SourceReferenceFormatter, splitting out retrieval and making use of new SourceLocation's CharStream knowledge
Diffstat (limited to 'liblangutil/SourceReferenceFormatter.h')
-rw-r--r-- | liblangutil/SourceReferenceFormatter.h | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/liblangutil/SourceReferenceFormatter.h b/liblangutil/SourceReferenceFormatter.h index 0ef3ca00..9f05f430 100644 --- a/liblangutil/SourceReferenceFormatter.h +++ b/liblangutil/SourceReferenceFormatter.h @@ -25,6 +25,7 @@ #include <ostream> #include <sstream> #include <functional> +#include <liblangutil/SourceReferenceExtractor.h> namespace dev { @@ -39,38 +40,33 @@ class Scanner; class SourceReferenceFormatter { public: - using ScannerFromSourceNameFun = std::function<langutil::Scanner const&(std::string const&)>; - - explicit SourceReferenceFormatter( - std::ostream& _stream, - ScannerFromSourceNameFun _scannerFromSourceName - ): - m_stream(_stream), - m_scannerFromSourceName(std::move(_scannerFromSourceName)) + explicit SourceReferenceFormatter(std::ostream& _stream): + m_stream(_stream) {} /// Prints source location if it is given. - void printSourceLocation(langutil::SourceLocation const* _location); - void printExceptionInformation(dev::Exception const& _exception, std::string const& _name); + void printSourceLocation(SourceLocation const* _location); + void printSourceLocation(SourceReference const& _ref); + void printExceptionInformation(dev::Exception const& _error, std::string const& _category); + void printExceptionInformation(SourceReferenceExtractor::Message const& _msg); static std::string formatExceptionInformation( dev::Exception const& _exception, - std::string const& _name, - ScannerFromSourceNameFun const& _scannerFromSourceName + std::string const& _name ) { std::ostringstream errorOutput; - SourceReferenceFormatter formatter(errorOutput, _scannerFromSourceName); + SourceReferenceFormatter formatter(errorOutput); formatter.printExceptionInformation(_exception, _name); return errorOutput.str(); } + private: /// Prints source name if location is given. - void printSourceName(langutil::SourceLocation const* _location); + void printSourceName(SourceReference const& _ref); std::ostream& m_stream; - ScannerFromSourceNameFun m_scannerFromSourceName; }; } |