aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorrivenhk <adamsau@hotmail.com.hk>2017-10-18 01:59:15 +0800
committerrivenhk <adamsau@hotmail.com.hk>2017-10-18 01:59:15 +0800
commitb93a5980eddd6f61417fb9714110fda20c49698b (patch)
treee2dae0ee0f372d9031f7038b91c62a0b4116ba70 /libsolidity
parent846b43479dc2991fbbab8b497a622fd58204e08e (diff)
downloaddexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.tar
dexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.tar.gz
dexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.tar.bz2
dexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.tar.lz
dexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.tar.xz
dexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.tar.zst
dexon-solidity-b93a5980eddd6f61417fb9714110fda20c49698b.zip
added formatting when source snippets is too long
Diffstat (limited to 'libsolidity')
-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..fc55d328 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) + line.substr(startColumn, 15) + "..." + line.substr(endColumn - 15, 15) + line.substr(endColumn, line.length() - endColumn);
+ endColumn = startColumn + 33;
+ locationLength = 33;
+ }
+ if (line.length() > 150)
+ {
+ line = "..." + line.substr(startColumn, locationLength) + "...";
+ startColumn = 3;
+ endColumn = startColumn + locationLength;
+ }
+
_stream << line << endl;
for_each(
line.cbegin(),