aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-10-23 16:54:52 +0800
committerGitHub <noreply@github.com>2017-10-23 16:54:52 +0800
commitdc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d (patch)
tree877536971b41590fc7299e1648fc777afdaeaf34 /libsolidity/interface
parent4f30582db429e0135f9eecbb3ef57cf551d23b63 (diff)
parentccc54c84f3b4df7be615edb10ea1052be9fdd5b9 (diff)
downloaddexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar
dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar.gz
dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar.bz2
dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar.lz
dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar.xz
dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar.zst
dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.zip
Merge pull request #3092 from rivenhk/b_2885
added formatting when source snippets is too long
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/SourceReferenceFormatter.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/libsolidity/interface/SourceReferenceFormatter.cpp b/libsolidity/interface/SourceReferenceFormatter.cpp
index 62d22999..aeafaf2d 100644
--- a/libsolidity/interface/SourceReferenceFormatter.cpp
+++ b/libsolidity/interface/SourceReferenceFormatter.cpp
@@ -49,6 +49,21 @@ void SourceReferenceFormatter::printSourceLocation(
if (startLine == endLine)
{
string line = scanner.lineAtPosition(_location->start);
+
+ int locationLength = endColumn - startColumn;
+ if (locationLength > 150)
+ {
+ line = line.substr(0, startColumn + 35) + " ... " + line.substr(endColumn - 35);
+ endColumn = startColumn + 75;
+ locationLength = 75;
+ }
+ if (line.length() > 150)
+ {
+ line = " ... " + line.substr(startColumn, locationLength) + " ... ";
+ startColumn = 5;
+ endColumn = startColumn + locationLength;
+ }
+
_stream << line << endl;
for_each(
line.cbegin(),