Skip to content

Commit df308dc

Browse files
committed
[FOLD] add relates element to named symbol
1 parent 1bf672d commit df308dc

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

include/mrdocs/Metadata/Javadoc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ struct MRDOCS_DECL
10211021
std::vector<doc::See> sees;
10221022

10231023
/// The list of "related" references.
1024-
std::vector<doc::Related> related;
1024+
std::vector<SymbolID> related;
10251025

10261026
/// The list of preconditions.
10271027
std::vector<doc::Precondition> preconditions;

src/lib/Gen/hbs/HandlebarsCorpus.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ domCreate(
100100

101101
dom::Value
102102
domCreate(
103-
doc::Related const& I,
103+
SymbolID const& I,
104104
HandlebarsCorpus const& corpus)
105105
{
106-
return corpus.toStringFn(corpus, I);
106+
return corpus.get(I);
107107
}
108108

109109
dom::Value
@@ -233,7 +233,7 @@ getJavadoc(Javadoc const& jd) const
233233
elements.reserve(nodes.size());
234234
for (value_type const& elem : nodes)
235235
{
236-
if constexpr (requires { !elem; })
236+
if constexpr (requires { *elem; })
237237
{
238238
if (!elem)
239239
{

src/lib/Lib/CorpusImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ lookup(SymbolID const& context, std::string_view name) const
228228
return lookupImpl(*this, context, name);
229229
}
230230

231-
Info const*
231+
Info*
232232
CorpusImpl::
233233
lookup(SymbolID const& context, std::string_view name)
234234
{
235-
return lookupImpl(*this, context, name);
235+
return const_cast<Info*>(lookupImpl(*this, context, name));
236236
}
237237

238238
template <class Self>

src/lib/Lib/CorpusImpl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ class CorpusImpl final : public Corpus
8787
Info const*
8888
find(SymbolID const& id) const noexcept override;
8989

90-
Info const*
91-
lookup(SymbolID const& context, std::string_view name) const override;
90+
Info*
91+
lookup(SymbolID const& context, std::string_view name);
9292

9393
Info const*
94-
lookup(SymbolID const& context, std::string_view name);
94+
lookup(SymbolID const& context, std::string_view name) const override;
9595

9696
/** Build metadata for a set of translation units.
9797

src/lib/Metadata/Finalizers/JavadocFinalizer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,18 @@ void
112112
JavadocFinalizer::
113113
finalize(doc::Reference& ref)
114114
{
115-
Info const* res = corpus_.lookup(current_context_->id, ref.string);
115+
Info* res = corpus_.lookup(current_context_->id, ref.string);
116116
if (res)
117117
{
118118
ref.id = res->id;
119+
if(ref.Kind == doc::NodeKind::related)
120+
{
121+
if(! res->javadoc)
122+
res->javadoc.emplace();
123+
auto& related = res->javadoc->related;
124+
if(std::ranges::find(related, current_context_->id) == related.end())
125+
related.emplace_back(current_context_->id);
126+
}
119127
}
120128
if (res == nullptr &&
121129
// Only warn once per reference
@@ -150,7 +158,8 @@ finalize(doc::Node& node)
150158
finalize(N.children);
151159
}
152160

153-
if constexpr(std::same_as<NodeTy, doc::Reference>)
161+
if constexpr(std::same_as<NodeTy, doc::Reference> ||
162+
std::same_as<NodeTy, doc::Related>)
154163
{
155164
finalize(dynamic_cast<doc::Reference&>(N));
156165
}

0 commit comments

Comments
 (0)