diff options
author | chriseth <chris@ethereum.org> | 2017-10-23 16:54:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 16:54:52 +0800 |
commit | dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d (patch) | |
tree | 877536971b41590fc7299e1648fc777afdaeaf34 /libsolidity | |
parent | 4f30582db429e0135f9eecbb3ef57cf551d23b63 (diff) | |
parent | ccc54c84f3b4df7be615edb10ea1052be9fdd5b9 (diff) | |
download | dexon-solidity-dc6b1f02bc8b578caa3b3c42e11d9f19a9f4cd6d.tar.gz 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')
-rw-r--r-- | libsolidity/interface/SourceReferenceFormatter.cpp | 15 |
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(), |