diff --git a/include/mrdocs/Metadata/Javadoc.hpp b/include/mrdocs/Metadata/Javadoc.hpp index fe81182e1..0f01ae0c3 100644 --- a/include/mrdocs/Metadata/Javadoc.hpp +++ b/include/mrdocs/Metadata/Javadoc.hpp @@ -308,13 +308,22 @@ struct Link : Text struct Reference : Text { SymbolID id = SymbolID::invalid; + std::string fileName; + int line; + int column; static constexpr Kind static_kind = Kind::reference; explicit Reference( - String string_ = String()) noexcept + String string_ = String(), + String fileName_ = String(), + uint32_t line_ = 0, + uint32_t column_ = 0) noexcept : Text(std::move(string_), Kind::reference) + , fileName(std::move(fileName_)) + , line(line_) + , column(column_) { } @@ -328,8 +337,14 @@ struct Reference : Text protected: Reference( String string_, - Kind kind_) noexcept + Kind kind_, + String fileName_, + uint32_t line_, + uint32_t column_) noexcept : Text(std::move(string_), kind_) + , fileName(std::move(fileName_)) + , line(line_) + , column(column_) { } }; @@ -344,8 +359,11 @@ struct Copied : Reference Copied( String string_ = String(), + String fileName_ = String(), + uint32_t line_ = 0, + uint32_t column_ = 0, Parts parts_ = Parts::all) noexcept - : Reference(std::move(string_), Kind::copied) + : Reference(std::move(string_), Kind::copied, std::move(fileName_), line_, column_) , parts(parts_) { } diff --git a/src/lib/AST/ParseJavadoc.cpp b/src/lib/AST/ParseJavadoc.cpp index 94032e5c8..18d0b8015 100644 --- a/src/lib/AST/ParseJavadoc.cpp +++ b/src/lib/AST/ParseJavadoc.cpp @@ -834,9 +834,16 @@ visitInlineCommandComment( close = std::ranges::count(ref, ')'); } } + PresumedLoc const loc = sm_.getPresumedLoc(C->getBeginLoc()); + auto filename = loc.getFilename(); + auto line = loc.getLine(); + auto column = loc.getColumn(); emplaceText( C->hasTrailingNewline(), ref, + filename, + line, + column, convertCopydoc(ID)); return; } @@ -855,11 +862,18 @@ visitInlineCommandComment( bool const hasExtraText = ref.size() != s.size(); if (!ref.empty()) { + PresumedLoc const loc = sm_.getPresumedLoc(C->getBeginLoc()); + auto filename = loc.getFilename(); + auto line = loc.getLine(); + auto column = loc.getColumn(); // the referenced symbol will be resolved during // the finalization step once all symbols are extracted emplaceText( C->hasTrailingNewline() && !hasExtraText, - std::string(ref)); + std::string(ref), + std::string(filename), + line, + column); } // Emplace the rest of the string as doc::Text if(hasExtraText) diff --git a/src/lib/Metadata/Finalize.cpp b/src/lib/Metadata/Finalize.cpp index 1036e6705..1fc64a6f7 100644 --- a/src/lib/Metadata/Finalize.cpp +++ b/src/lib/Metadata/Finalize.cpp @@ -190,17 +190,13 @@ class Finalizer if constexpr(std::derived_from) { -#if 0 // This warning shouldn't be triggered if the symbol has // been explicitly marked excluded in mrdocs.yml if(! resolveReference(N)) { - report::warn("Failed to resolve reference to '{}' from '{}'", - N.string, current_->Name); + report::warn("Failed to resolve reference to '{}' from '{}' at file '{}' line {} column {}", + N.string, current_->Name, N.fileName, N.line, N.column); } -#else - resolveReference(N); -#endif } }); }