diff --git a/language/duchain/duchainutils.cpp b/language/duchain/duchainutils.cpp --- a/language/duchain/duchainutils.cpp +++ b/language/duchain/duchainutils.cpp @@ -477,8 +477,7 @@ return ret; } -///For a class, returns all classes that inherit it -QList DUChainUtils::getInheriters(const Declaration* decl, uint& maxAllowedSteps, bool collectVersions) +static QList getInheritersInternal(const Declaration* decl, uint& maxAllowedSteps, bool collectVersions) { QList ret; @@ -516,7 +515,7 @@ ++maxAllowedSteps; if(allDeclarations[a].data() && allDeclarations[a].data() != decl) { - ret += getInheriters(allDeclarations[a].data(), maxAllowedSteps, false); + ret += getInheritersInternal(allDeclarations[a].data(), maxAllowedSteps, false); } if(maxAllowedSteps == 0) @@ -527,6 +526,17 @@ return ret; } +QList DUChainUtils::getInheriters(const Declaration* decl, uint& maxAllowedSteps, bool collectVersions) +{ + auto inheriters = getInheritersInternal(decl, maxAllowedSteps, collectVersions); + + // remove duplicates + std::sort(inheriters.begin(), inheriters.end()); + inheriters.erase(std::unique(inheriters.begin(), inheriters.end()), inheriters.end()); + + return inheriters; +} + QList DUChainUtils::getOverriders(const Declaration* currentClass, const Declaration* overriddenDeclaration, uint& maxAllowedSteps) { QList ret;