diff options
author | chriseth <chris@ethereum.org> | 2018-12-20 01:06:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-20 01:06:13 +0800 |
commit | 1df8f40cd2fd7b47698d847907b8ca7b47eb488d (patch) | |
tree | 5ed5816fe2d1a8a207e750d39884aca7957c8289 /liblangutil/SourceReferenceExtractor.h | |
parent | c8a2cb62832afb2dc09ccee6fd42c1516dfdb981 (diff) | |
parent | ddf54b21d1d002903624f61173ab4af197f50053 (diff) | |
download | dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.gz dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.bz2 dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.lz dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.xz dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.zst dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.zip |
Merge pull request #5697 from ethereum/develop
Merge develop into release for 0.5.2
Diffstat (limited to 'liblangutil/SourceReferenceExtractor.h')
-rw-r--r-- | liblangutil/SourceReferenceExtractor.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h new file mode 100644 index 00000000..bcbc50bc --- /dev/null +++ b/liblangutil/SourceReferenceExtractor.h @@ -0,0 +1,75 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see <http://www.gnu.org/licenses/>. +*/ +#pragma once + +#include <iosfwd> +#include <string> +#include <tuple> +#include <vector> + +namespace dev +{ +struct Exception; +} + +namespace langutil +{ + +struct LineColumn +{ + int line = {-1}; + int column = {-1}; + + LineColumn() = default; + LineColumn(std::tuple<int, int> const& _t): line{std::get<0>(_t)}, column{std::get<1>(_t)} {} +}; + +struct SourceReference +{ + std::string message; ///< A message that relates to this source reference (such as a warning or an error message). + std::string sourceName; ///< Underlying source name (for example the filename). + LineColumn position; ///< Actual (error) position this source reference is surrounding. + bool multiline = {false}; ///< Indicates whether the actual SourceReference is truncated to one line. + std::string text; ///< Extracted source code text (potentially truncated if multiline or too long). + int startColumn = {-1}; ///< Highlighting range-start of text field. + int endColumn = {-1}; ///< Highlighting range-end of text field. + + /// Constructs a SourceReference containing a message only. + static SourceReference MessageOnly(std::string _msg) + { + SourceReference sref; + sref.message = std::move(_msg); + return sref; + } +}; + +struct SourceLocation; + +namespace SourceReferenceExtractor +{ + struct Message + { + SourceReference primary; + std::string category; // "Error", "Warning", ... + std::vector<SourceReference> secondary; + }; + + Message extract(dev::Exception const& _exception, std::string _category); + SourceReference extract(SourceLocation const* _location, std::string message = ""); +} + +} |