From b93a5980eddd6f61417fb9714110fda20c49698b Mon Sep 17 00:00:00 2001 From: rivenhk Date: Wed, 18 Oct 2017 01:59:15 +0800 Subject: [PATCH 1/4] added formatting when source snippets is too long --- .../interface/SourceReferenceFormatter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libsolidity/interface/SourceReferenceFormatter.cpp b/libsolidity/interface/SourceReferenceFormatter.cpp index 62d22999f..fc55d328e 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(), From d53c44a066ad70a34a5c7d858e1cb6afa1cbda3a Mon Sep 17 00:00:00 2001 From: rivenhk Date: Wed, 18 Oct 2017 22:03:33 +0800 Subject: [PATCH 2/4] updating formatting when source snippets is too long --- libsolidity/interface/SourceReferenceFormatter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libsolidity/interface/SourceReferenceFormatter.cpp b/libsolidity/interface/SourceReferenceFormatter.cpp index fc55d328e..256adccc7 100644 --- a/libsolidity/interface/SourceReferenceFormatter.cpp +++ b/libsolidity/interface/SourceReferenceFormatter.cpp @@ -53,14 +53,14 @@ void SourceReferenceFormatter::printSourceLocation( 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; + line = line.substr(0, startColumn + 75) + " ... " + line.substr(endColumn); + endColumn = startColumn + 80; + locationLength = 80; } if (line.length() > 150) { - line = "..." + line.substr(startColumn, locationLength) + "..."; - startColumn = 3; + line = " ... " + line.substr(startColumn, locationLength) + " ... "; + startColumn = 5; endColumn = startColumn + locationLength; } From 950f5ae7d762f5878b69043da16e9e27485d4c57 Mon Sep 17 00:00:00 2001 From: rivenhk Date: Thu, 19 Oct 2017 20:20:07 +0800 Subject: [PATCH 3/4] updated formatting when source snippets is too long --- libsolidity/interface/SourceReferenceFormatter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsolidity/interface/SourceReferenceFormatter.cpp b/libsolidity/interface/SourceReferenceFormatter.cpp index 256adccc7..aeafaf2db 100644 --- a/libsolidity/interface/SourceReferenceFormatter.cpp +++ b/libsolidity/interface/SourceReferenceFormatter.cpp @@ -53,9 +53,9 @@ void SourceReferenceFormatter::printSourceLocation( int locationLength = endColumn - startColumn; if (locationLength > 150) { - line = line.substr(0, startColumn + 75) + " ... " + line.substr(endColumn); - endColumn = startColumn + 80; - locationLength = 80; + line = line.substr(0, startColumn + 35) + " ... " + line.substr(endColumn - 35); + endColumn = startColumn + 75; + locationLength = 75; } if (line.length() > 150) { From ccc54c84f3b4df7be615edb10ea1052be9fdd5b9 Mon Sep 17 00:00:00 2001 From: rivenhk Date: Sun, 22 Oct 2017 00:26:46 +0800 Subject: [PATCH 4/4] updated Changelog.md --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index ed3cdfeae..acd9ee5e2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,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.