|
|
@ -313,24 +313,47 @@ void CodeModel::runCompilationJob(int _jobId) |
|
|
|
} |
|
|
|
catch (dev::Exception const& _exception) |
|
|
|
{ |
|
|
|
std::ostringstream error; |
|
|
|
std::stringstream error; |
|
|
|
solidity::SourceReferenceFormatter::printExceptionInformation(error, _exception, "Error", cs); |
|
|
|
QString message = QString::fromStdString(error.str()); |
|
|
|
QString sourceName; |
|
|
|
if (SourceLocation const* location = boost::get_error_info<solidity::errinfo_sourceLocation>(_exception)) |
|
|
|
QVariantMap firstLocation; |
|
|
|
QVariantList secondLocations; |
|
|
|
if (SourceLocation const* first = boost::get_error_info<solidity::errinfo_sourceLocation>(_exception)) |
|
|
|
firstLocation = resolveCompilationErrorLocation(cs, *first); |
|
|
|
if (SecondarySourceLocation const* second = boost::get_error_info<solidity::errinfo_secondarySourceLocation>(_exception)) |
|
|
|
{ |
|
|
|
if (location->sourceName) |
|
|
|
sourceName = QString::fromStdString(*location->sourceName); |
|
|
|
if (!sourceName.isEmpty()) |
|
|
|
if (CompiledContract* contract = contractByDocumentId(sourceName)) |
|
|
|
message = message.replace(sourceName, contract->contract()->name()); //substitute the location to match our contract names
|
|
|
|
for (auto const& c: second->infos) |
|
|
|
secondLocations.push_back(resolveCompilationErrorLocation(cs, c.second)); |
|
|
|
} |
|
|
|
compilationError(message, sourceName); |
|
|
|
compilationError(message, firstLocation, secondLocations); |
|
|
|
} |
|
|
|
m_compiling = false; |
|
|
|
emit stateChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
QVariantMap CodeModel::resolveCompilationErrorLocation(CompilerStack const& _compiler, SourceLocation const& _location) |
|
|
|
{ |
|
|
|
std::tuple<int, int, int, int> pos = _compiler.positionFromSourceLocation(_location); |
|
|
|
QVariantMap startError; |
|
|
|
startError.insert("line", std::get<0>(pos) > 1 ? (std::get<0>(pos) - 1) : 1); |
|
|
|
startError.insert("column", std::get<1>(pos) > 1 ? (std::get<1>(pos) - 1) : 1); |
|
|
|
QVariantMap endError; |
|
|
|
endError.insert("line", std::get<2>(pos) > 1 ? (std::get<2>(pos) - 1) : 1); |
|
|
|
endError.insert("column", std::get<3>(pos) > 1 ? (std::get<3>(pos) - 1) : 1); |
|
|
|
QVariantMap error; |
|
|
|
error.insert("start", startError); |
|
|
|
error.insert("end", endError); |
|
|
|
QString sourceName; |
|
|
|
if (_location.sourceName) |
|
|
|
sourceName = QString::fromStdString(*_location.sourceName); |
|
|
|
error.insert("source", sourceName); |
|
|
|
if (!sourceName.isEmpty()) |
|
|
|
if (CompiledContract* contract = contractByDocumentId(sourceName)) |
|
|
|
sourceName = contract->contract()->name(); //substitute the location to match our contract names
|
|
|
|
error.insert("contractName", sourceName); |
|
|
|
return error; |
|
|
|
} |
|
|
|
|
|
|
|
void CodeModel::gasEstimation(solidity::CompilerStack const& _cs) |
|
|
|
{ |
|
|
|
if (m_gasCostsMaps) |
|
|
|