Merge pull request #3092 from rivenhk/b_2885

added formatting when source snippets is too long
This commit is contained in:
chriseth authored and GitHub committed 2017-10-23 10:54:52 +02:00
commit dc6b1f02bc
2 files changed
+16

No files matched your search

+1
View File
@@ -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.
@@ -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(),