diff --git a/liblangutil/SourceReferenceExtractor.cpp b/liblangutil/SourceReferenceExtractor.cpp index ff045a198..44f1540ca 100644 --- a/liblangutil/SourceReferenceExtractor.cpp +++ b/liblangutil/SourceReferenceExtractor.cpp @@ -46,6 +46,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio if (!_location || !_location->source.get()) // Nothing we can extract here 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 const& source = _location->source; LineColumn const interest = source->translatePositionToLineColumn(_location->start); diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h index 12f608409..6aa0ab34a 100644 --- a/liblangutil/SourceReferenceExtractor.h +++ b/liblangutil/SourceReferenceExtractor.h @@ -49,10 +49,11 @@ struct SourceReference int endColumn = {-1}; ///< Highlighting range-end of text field. /// Constructs a SourceReference containing a message only. - static SourceReference MessageOnly(std::string _msg) + static SourceReference MessageOnly(std::string _msg, std::string _sourceName = {}) { SourceReference sref; sref.message = std::move(_msg); + sref.sourceName = std::move(_sourceName); return sref; } };