mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Handle empty source strings in SourceReferenceExtractor
This commit is contained in:
parent
17158995b5
commit
03c70f45d6
@ -46,6 +46,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio
|
|||||||
if (!_location || !_location->source.get()) // Nothing we can extract here
|
if (!_location || !_location->source.get()) // Nothing we can extract here
|
||||||
return SourceReference::MessageOnly(std::move(message));
|
return SourceReference::MessageOnly(std::move(message));
|
||||||
|
|
||||||
|
if (_location->source->source().empty()) // No source text, so we can only extract the source name
|
||||||
|
return SourceReference::MessageOnly(std::move(message), _location->source->name());
|
||||||
|
|
||||||
shared_ptr<CharStream> const& source = _location->source;
|
shared_ptr<CharStream> const& source = _location->source;
|
||||||
|
|
||||||
LineColumn const interest = source->translatePositionToLineColumn(_location->start);
|
LineColumn const interest = source->translatePositionToLineColumn(_location->start);
|
||||||
|
@ -49,10 +49,11 @@ struct SourceReference
|
|||||||
int endColumn = {-1}; ///< Highlighting range-end of text field.
|
int endColumn = {-1}; ///< Highlighting range-end of text field.
|
||||||
|
|
||||||
/// Constructs a SourceReference containing a message only.
|
/// Constructs a SourceReference containing a message only.
|
||||||
static SourceReference MessageOnly(std::string _msg)
|
static SourceReference MessageOnly(std::string _msg, std::string _sourceName = {})
|
||||||
{
|
{
|
||||||
SourceReference sref;
|
SourceReference sref;
|
||||||
sref.message = std::move(_msg);
|
sref.message = std::move(_msg);
|
||||||
|
sref.sourceName = std::move(_sourceName);
|
||||||
return sref;
|
return sref;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user