Skip to content

Commit

Permalink
Merge pull request ethereum#3092 from rivenhk/b_2885
Browse files Browse the repository at this point in the history
added formatting when source snippets is too long
  • Loading branch information
chriseth authored Oct 23, 2017
2 parents 4f30582 + ccc54c8 commit dc6b1f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Features:
* Type Checker: Do not add members of ``address`` to contracts as experimental 0.5.0 feature.
* Type Checker: Force interface functions to be external as experimental 0.5.0 feature.
* Type Checker: Require ``storage`` or ``memory`` keyword for local variables as experimental 0.5.0 feature.
* Compiler Interface: Better formatted error message for long source snippets

Bugfixes:
* Code Generator: Allocate one byte per memory byte array element instead of 32.
Expand Down
15 changes: 15 additions & 0 deletions libsolidity/interface/SourceReferenceFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit dc6b1f0

Please sign in to comment.