-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
143 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// | ||
// Copyright (c) 2023 Vinnie Falco ([email protected]) | ||
// Copyright (c) 2023 Krystian Stasiowski ([email protected]) | ||
// Copyright (c) 2024 Alan de Freitas ([email protected]) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdocs | ||
// | ||
|
@@ -160,6 +161,32 @@ class MRDOCS_VISIBLE | |
} | ||
} | ||
|
||
/** Visit the members of specified Info in a stable order. | ||
@param I The Info to visit. | ||
@param info The Info to visit. | ||
@param f The function to invoke. | ||
@param args The arguments to pass to the function. | ||
*/ | ||
template <InfoParent T, class F, class... Args> | ||
void | ||
orderedTraverse( | ||
T const& I, F&& f, Args&&... args) const | ||
{ | ||
std::vector<SymbolID> members(I.Members.begin(), I.Members.end()); | ||
std::stable_sort(members.begin(), members.end(), [this](SymbolID const& lhs, SymbolID const& rhs) | ||
{ | ||
auto const& lhsInfo = get(lhs); | ||
auto const& rhsInfo = get(rhs); | ||
return lhsInfo < rhsInfo; | ||
}); | ||
for (auto const& id : members) | ||
{ | ||
visit(get(id), std::forward<F>(f), | ||
std::forward<Args>(args)...); | ||
} | ||
} | ||
|
||
/** Visit the member overloads of specified ScopeInfo. | ||
This function iterates the members of the | ||
|
@@ -184,6 +211,14 @@ class MRDOCS_VISIBLE | |
F&& f, | ||
Args&&... args) const; | ||
|
||
/** Visit the member overloads of specified ScopeInfo in stable order | ||
*/ | ||
template <class F, class... Args> | ||
void orderedTraverseOverloads( | ||
ScopeInfo const& S, | ||
F&& f, | ||
Args&&... args) const; | ||
|
||
//-------------------------------------------- | ||
|
||
/** Return the fully qualified name of the specified Info. | ||
|
@@ -238,25 +273,20 @@ get( | |
|
||
template <class F, class... Args> | ||
void | ||
Corpus:: | ||
traverseOverloads( | ||
traverseOverloadsImpl( | ||
Corpus const& c, | ||
std::vector<SymbolID> const& members0, | ||
ScopeInfo const& S, | ||
F&& f, Args&&... args) const | ||
F&& f, Args&&... args) | ||
{ | ||
MRDOCS_ASSERT(S.Members.empty() == S.Lookups.empty()); | ||
for(const SymbolID& id : S.Members) | ||
for(const SymbolID& id : members0) | ||
{ | ||
const Info& member = get(id); | ||
const Info& member = c.get(id); | ||
const auto& members = S.Lookups.at(member.Name); | ||
auto first_func = std::ranges::find_if( | ||
members, [this](const SymbolID& elem) | ||
members, [&c](const SymbolID& elem) | ||
{ | ||
#if 0 | ||
const Info& I = get(elem); | ||
return I.isFunction() || I.isGuide(); | ||
#else | ||
return get(elem).isFunction(); | ||
#endif | ||
return c.get(elem).isFunction(); | ||
}); | ||
bool const nonOverloadedFunction = members.size() == 1; | ||
bool const notFunction = first_func == members.end(); | ||
|
@@ -278,6 +308,40 @@ traverseOverloads( | |
} | ||
} | ||
|
||
template <class F, class... Args> | ||
void | ||
Corpus:: | ||
traverseOverloads( | ||
ScopeInfo const& S, | ||
F&& f, Args&&... args) const | ||
{ | ||
MRDOCS_ASSERT(S.Members.empty() == S.Lookups.empty()); | ||
return traverseOverloadsImpl( | ||
*this, S.Members, S, std::forward<F>(f), std::forward<Args>(args)...); | ||
|
||
} | ||
|
||
template <class F, class... Args> | ||
void | ||
Corpus:: | ||
orderedTraverseOverloads( | ||
ScopeInfo const& S, | ||
F&& f, | ||
Args&&... args) const | ||
{ | ||
MRDOCS_ASSERT(S.Members.empty() == S.Lookups.empty()); | ||
std::vector<SymbolID> members(S.Members.begin(), S.Members.end()); | ||
std::stable_sort(members.begin(), members.end(), [this](SymbolID const& lhs, SymbolID const& rhs) | ||
{ | ||
auto const& lhsInfo = get(lhs); | ||
auto const& rhsInfo = get(rhs); | ||
return lhsInfo < rhsInfo; | ||
}); | ||
return traverseOverloadsImpl( | ||
*this, members, S, std::forward<F>(f), std::forward<Args>(args)...); | ||
} | ||
|
||
|
||
class Corpus::iterator | ||
{ | ||
const Corpus* corpus_; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// | ||
// Copyright (c) 2023 Vinnie Falco ([email protected]) | ||
// Copyright (c) 2023 Krystian Stasiowski ([email protected]) | ||
// Copyright (c) 2024 Alan de Freitas ([email protected]) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdocs | ||
// | ||
|
@@ -18,7 +19,7 @@ | |
#include "lib/Support/Chrono.hpp" | ||
#include <mrdocs/Metadata.hpp> | ||
#include <mrdocs/Support/Error.hpp> | ||
#include <llvm/ADT/STLExtras.h> | ||
#include <mrdocs/Support/ThreadPool.hpp> | ||
#include <chrono> | ||
|
||
namespace clang { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters