Doxygen
Loading...
Searching...
No Matches
groupdef.cpp File Reference
#include "groupdef.h"
#include <algorithm>
#include <cctype>
#include <map>
#include <memory>
#include <vector>
#include "arguments.h"
#include "classdef.h"
#include "classlist.h"
#include "conceptdef.h"
#include "config.h"
#include "definitionimpl.h"
#include "dirdef.h"
#include "docparser.h"
#include "dot.h"
#include "dotgroupcollaboration.h"
#include "doxygen.h"
#include "filedef.h"
#include "language.h"
#include "layout.h"
#include "membergroup.h"
#include "memberlist.h"
#include "membername.h"
#include "message.h"
#include "moduledef.h"
#include "namespacedef.h"
#include "outputlist.h"
#include "pagedef.h"
#include "util.h"
#include "vhdldocgen.h"
Include dependency graph for groupdef.cpp:

Go to the source code of this file.

Classes

class  GroupDefImpl

Functions

std::unique_ptr< GroupDef > createGroupDef (const DString &fileName, int line, const DString &name, const DString &title, const DString &refFileName)
void addClassToGroups (const Entry *root, ClassDef *cd)
void addConceptToGroups (const Entry *root, ConceptDef *cd)
void addModuleToGroups (const Entry *root, ModuleDef *mod)
void addNamespaceToGroups (const Entry *root, NamespaceDef *nd)
void addDirToGroups (const Entry *root, DirDef *dd)
void addGroupToGroups (const Entry *root, GroupDef *subGroup)
void addMemberToGroups (const Entry *root, MemberDef *md)
void addExampleToGroups (const Entry *root, PageDef *eg)
template<class Vec>
static void groupClassesWithSameScope (Vec &vec)
static bool hasNonReferenceNestedGroupRec (const GroupDef *gd, int level)
GroupDef * toGroupDef (Definition *d)
const GroupDef * toGroupDef (const Definition *d)

Function Documentation

◆ addClassToGroups()

void addClassToGroups ( const Entry * root,
ClassDef * cd )

Definition at line 1560 of file groupdef.cpp.

1561{
1562 for (const Grouping &g : root->groups)
1563 {
1564 GroupDef *gd=nullptr;
1566 if (gd && gd->addClass(cd))
1567 {
1569 if (cdm)
1570 {
1571 cdm->makePartOfGroup(gd);
1572 }
1573 //printf("Compound %s: in group %s\n",qPrint(cd->name()),gd->groupTitle());
1574 }
1575 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1576 {
1577 warn(root->fileName, root->startLine,
1578 "Found non-existing group '{}' for the command '{}', ignoring command",
1580 );
1581 }
1582 }
1583}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
virtual void makePartOfGroup(GroupDef *gd)=0
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:107
DString fileName
file this entry was extracted from
Definition entry.h:232
std::vector< Grouping > groups
list of groups this entry belongs to
Definition entry.h:230
int startLine
start line of entry in the source
Definition entry.h:233
A model of a group of symbols.
Definition groupdef.h:48
virtual bool addClass(ClassDef *def)=0
const T * find(const std::string &key) const
Definition linkedmap.h:47
ClassDefMutable * toClassDefMutable(Definition *d)
#define warn(file, line, fmt,...)
Definition message.h:97
Grouping info.
Definition types.h:227
DString groupname
name of the group
Definition types.h:257
static constexpr const char * getGroupPriName(GroupPri_t priority) noexcept
Definition types.h:240
@ GROUPING_INGROUP
membership in group was defined by @ingroup
Definition types.h:236
GroupPri_t pri
priority of this definition
Definition types.h:258

References GroupDef::addClass(), DString::empty(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Grouping::pri, Entry::startLine, toClassDefMutable(), and warn.

Referenced by addClassToContext().

◆ addConceptToGroups()

void addConceptToGroups ( const Entry * root,
ConceptDef * cd )

Definition at line 1585 of file groupdef.cpp.

1586{
1587 for (const Grouping &g : root->groups)
1588 {
1590 if (gd && gd->addConcept(cd))
1591 {
1593 if (cdm)
1594 {
1595 cdm->makePartOfGroup(gd);
1596 }
1597 //printf("Compound %s: in group %s\n",qPrint(cd->name()),gd->groupTitle());
1598 }
1599 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1600 {
1601 warn(root->fileName, root->startLine,
1602 "Found non-existing group '{}' for the command '{}', ignoring command",
1604 );
1605 }
1606 }
1607}
virtual bool addConcept(ConceptDef *def)=0
ConceptDefMutable * toConceptDefMutable(Definition *d)

References GroupDef::addConcept(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Grouping::pri, Entry::startLine, toConceptDefMutable(), and warn.

Referenced by addConceptToContext().

◆ addDirToGroups()

void addDirToGroups ( const Entry * root,
DirDef * dd )

Definition at line 1657 of file groupdef.cpp.

1658{
1659 //printf("*** root->groups.size()=%d\n",root->groups.size());
1660 for (const Grouping &g : root->groups)
1661 {
1663 //printf("group '%s'\n",qPrint(g->groupname));
1664 if (gd)
1665 {
1666 gd->addDir(dd);
1667 dd->makePartOfGroup(gd);
1668 //printf("Dir %s: in group %s\n",qPrint(dd->name()),qPrint(g->groupname));
1669 }
1670 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1671 {
1672 warn(root->fileName, root->startLine,
1673 "Found non-existing group '{}' for the command '{}', ignoring command",
1675 );
1676 }
1677 }
1678}
virtual void addDir(DirDef *dd)=0

References GroupDef::addDir(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Grouping::pri, Entry::startLine, and warn.

Referenced by findDirDocumentation().

◆ addExampleToGroups()

void addExampleToGroups ( const Entry * root,
PageDef * eg )

Definition at line 1840 of file groupdef.cpp.

1841{
1842 for (const Grouping &g : root->groups)
1843 {
1845 if (gd)
1846 {
1847 gd->addExample(eg);
1848 eg->makePartOfGroup(gd);
1849 //printf("Example %s: in group %s\n",qPrint(eg->name()),s->data());
1850 }
1851 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1852 {
1853 warn(root->fileName, root->startLine,
1854 "Found non-existing group '{}' for the command '{}', ignoring command",
1856 );
1857 }
1858 }
1859}
virtual void addExample(PageDef *def)=0

References GroupDef::addExample(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Grouping::pri, Entry::startLine, and warn.

◆ addGroupToGroups()

void addGroupToGroups ( const Entry * root,
GroupDef * subGroup )

Definition at line 1680 of file groupdef.cpp.

1681{
1682 //printf("addGroupToGroups for %s groups=%d\n",qPrint(root->name),root->groups.size());
1683 for (const Grouping &g : root->groups)
1684 {
1686 if (gd)
1687 {
1688 if (gd==subGroup)
1689 {
1690 warn(root->fileName,root->startLine,"Refusing to add group {} to itself",
1691 gd->name());
1692 }
1693 else if (subGroup->findGroup(gd))
1694 {
1695 warn(root->fileName,root->startLine,"Refusing to add group {} to group {}, since the latter is already a "
1696 "subgroup of the former", subGroup->name(),gd->name());
1697 }
1698 else if (!gd->findGroup(subGroup))
1699 {
1700 gd->addGroup(subGroup);
1701 subGroup->makePartOfGroup(gd);
1702 }
1703 }
1704 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1705 {
1706 warn(root->fileName, root->startLine,
1707 "Found non-existing group '{}' for the command '{}', ignoring command",
1709 );
1710 }
1711 }
1712}
virtual const DString & name() const =0
virtual void addGroup(GroupDef *def)=0
virtual bool findGroup(const GroupDef *def) const =0

References GroupDef::addGroup(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), GroupDef::findGroup(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Definition::name(), Grouping::pri, Entry::startLine, and warn.

Referenced by organizeSubGroupsFiltered().

◆ addMemberToGroups()

void addMemberToGroups ( const Entry * root,
MemberDef * md )

Add a member to the group with the highest priority

Definition at line 1715 of file groupdef.cpp.

1716{
1717 //printf("addMemberToGroups: Root %p = %s, md %p=%s groups=%zu\n",
1718 // root, qPrint(root->name), md, qPrint(md->name()), root->groups.size() );
1719
1720 // Search entry's group list for group with highest pri.
1722 GroupDef *fgd=nullptr;
1723 for (const Grouping &g : root->groups)
1724 {
1725 GroupDef *gd=nullptr;
1727 if (gd && g.pri >= pri)
1728 {
1729 if (fgd && gd!=fgd && g.pri==pri)
1730 {
1731 warn(root->fileName, root->startLine,
1732 "Member {} found in multiple {} groups! "
1733 "The member will be put in group {}, and not in group {}",
1734 md->name(), Grouping::getGroupPriName( pri ),
1735 gd->name(), fgd->name()
1736 );
1737 }
1738
1739 fgd = gd;
1740 pri = g.pri;
1741 }
1742 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1743 {
1744 warn(root->fileName, root->startLine,
1745 "Found non-existing group '{}' for the command '{}', ignoring command",
1747 );
1748 }
1749 }
1750 //printf("fgd=%p\n",fgd);
1751
1752 // put member into group defined by this entry?
1753 if (fgd)
1754 {
1755 GroupDef *mgd = md->getGroupDef();
1756 //printf("mgd=%p\n",mgd);
1757 bool insertit = false;
1758 if (mgd==nullptr)
1759 {
1760 insertit = true;
1761 }
1762 else if (mgd!=fgd)
1763 {
1764 bool moveit = false;
1765
1766 // move member from one group to another if
1767 // - the new one has a higher priority
1768 // - the new entry has the same priority, but with docs where the old one had no docs
1769 if (md->getGroupPri()<pri)
1770 {
1771 moveit = true;
1772 }
1773 else
1774 {
1775 if (md->getGroupPri()==pri)
1776 {
1777 if (!root->doc.empty() && !md->getGroupHasDocs())
1778 {
1779 moveit = true;
1780 }
1781 else if (!root->doc.empty() && md->getGroupHasDocs())
1782 {
1784 "Member documentation for {} found several times in {} groups!\n"
1785 "{}:{}: The member will remain in group {}, and won't be put into group {}",
1786 md->name(), Grouping::getGroupPriName( pri ),
1787 root->fileName, root->startLine,
1788 mgd->name(), fgd->name()
1789 );
1790 }
1791 }
1792 }
1793
1794 if (moveit)
1795 {
1796 //printf("removeMember\n");
1797 mgd->removeMember(md);
1798 insertit = true;
1799 }
1800 }
1801
1802 if (insertit)
1803 {
1804 //printf("insertMember found at %s line %d: %s: related %s\n",
1805 // qPrint(md->getDefFileName()),md->getDefLine(),
1806 // qPrint(md->name()),qPrint(root->relates));
1807 bool success = fgd->insertMember(md);
1808 if (success)
1809 {
1811 if (mdm)
1812 {
1813 //printf("insertMember successful\n");
1814 mdm->setGroupDef(fgd,pri,root->fileName,root->startLine,!root->doc.empty());
1816 if (cdm)
1817 {
1818 cdm->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0);
1819 }
1820 if (mdm->isEnumerate() && mdm->getGroupDef() && md->isStrong())
1821 {
1822 for (const auto &emd : mdm->enumFieldList())
1823 {
1825 if (emdm && emdm->getGroupDef()==nullptr)
1826 {
1827 emdm->setGroupDef(mdm->getGroupDef(),mdm->getGroupPri(),
1828 mdm->getGroupFileName(),mdm->getGroupStartLine(),
1829 mdm->getGroupHasDocs());
1830 }
1831 }
1832 }
1833 }
1834 }
1835 }
1836 }
1837}
A abstract class representing of a compound symbol.
Definition classdef.h:100
virtual void setGroupDefForAllMembers(GroupDef *g, Grouping::GroupPri_t pri, const DString &fileName, int startLine, bool hasDocs)=0
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
DString doc
documentation block (partly parsed)
Definition entry.h:208
virtual void removeMember(MemberDef *md)=0
virtual bool insertMember(MemberDef *def, bool docOnly=false)=0
virtual bool getGroupHasDocs() const =0
virtual GroupDef * getGroupDef()=0
virtual const MemberVector & enumFieldList() const =0
virtual int getGroupStartLine() const =0
virtual Grouping::GroupPri_t getGroupPri() const =0
virtual const ClassDef * getClassDefOfAnonymousType() const =0
virtual bool isEnumerate() const =0
virtual DString getGroupFileName() const =0
virtual bool isStrong() const =0
virtual void setGroupDef(GroupDef *gd, Grouping::GroupPri_t pri, const DString &fileName, int startLine, bool hasDocs, MemberDef *member=nullptr)=0
MemberDefMutable * toMemberDefMutable(Definition *d)
GroupPri_t
Grouping priority.
Definition types.h:230
@ GROUPING_LOWEST
Definition types.h:231

References Entry::doc, DString::empty(), MemberDef::enumFieldList(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), MemberDef::getClassDefOfAnonymousType(), MemberDef::getGroupDef(), MemberDef::getGroupFileName(), MemberDef::getGroupHasDocs(), MemberDef::getGroupPri(), Grouping::getGroupPriName(), MemberDef::getGroupStartLine(), Grouping::GROUPING_INGROUP, Grouping::GROUPING_LOWEST, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, GroupDef::insertMember(), MemberDef::isEnumerate(), MemberDef::isStrong(), DString::length(), Definition::name(), Grouping::pri, GroupDef::removeMember(), MemberDefMutable::setGroupDef(), ClassDefMutable::setGroupDefForAllMembers(), Entry::startLine, toClassDefMutable(), toMemberDefMutable(), and warn.

Referenced by addDefineDoc(), addEnumDocs(), addGlobalFunction(), addInterfaceOrServiceToServiceOrSingleton(), addMemberDocs(), addMethodToClass(), addVariableToClass(), addVariableToFile(), buildFunctionList(), buildTypedefList(), findEnums(), and findMember().

◆ addModuleToGroups()

void addModuleToGroups ( const Entry * root,
ModuleDef * mod )

Definition at line 1609 of file groupdef.cpp.

1610{
1611 for (const Grouping &g : root->groups)
1612 {
1614 if (gd && gd->addModule(mod))
1615 {
1616 mod->makePartOfGroup(gd);
1617 //printf("Module %s: in group %s\n",qPrint(mod->name()),gd->groupTitle());
1618 }
1619 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1620 {
1621 warn(root->fileName, root->startLine,
1622 "Found non-existing group '{}' for the command '{}', ignoring command",
1624 );
1625 }
1626 }
1627}
virtual bool addModule(ModuleDef *def)=0

References GroupDef::addModule(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Grouping::pri, Entry::startLine, and warn.

Referenced by ModuleManager::addDocs().

◆ addNamespaceToGroups()

void addNamespaceToGroups ( const Entry * root,
NamespaceDef * nd )

Definition at line 1630 of file groupdef.cpp.

1631{
1632 //printf("root->groups.size()=%zu\n",root->groups.size());
1633 for (const Grouping &g : root->groups)
1634 {
1635 GroupDef *gd=nullptr;
1637 //printf("group '%s' gd=%p\n",qPrint(g.groupname),(void*)gd);
1638 if (gd && gd->addNamespace(nd))
1639 {
1641 if (ndm)
1642 {
1643 ndm->makePartOfGroup(gd);
1644 }
1645 //printf("Namespace %s: in group %s\n",qPrint(nd->name()),qPrint(gd->name()));
1646 }
1647 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1648 {
1649 warn(root->fileName, root->startLine,
1650 "Found non-existing group '{}' for the command '{}', ignoring command",
1652 );
1653 }
1654 }
1655}
virtual bool addNamespace(NamespaceDef *def)=0
NamespaceDefMutable * toNamespaceDefMutable(Definition *d)

References GroupDef::addNamespace(), DString::empty(), Entry::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find(), Grouping::getGroupPriName(), Grouping::GROUPING_INGROUP, Doxygen::groupLinkedMap, Grouping::groupname, Entry::groups, DefinitionMutable::makePartOfGroup(), Grouping::pri, Entry::startLine, toNamespaceDefMutable(), and warn.

Referenced by buildNamespaceList().

◆ createGroupDef()

std::unique_ptr< GroupDef > createGroupDef ( const DString & fileName,
int line,
const DString & name,
const DString & title,
const DString & refFileName )

Definition at line 184 of file groupdef.cpp.

186{
187 return std::make_unique<GroupDefImpl>(fileName,line,name,title,refFileName);
188}

Referenced by buildGroupListFiltered(), and GroupDef::overrideGroupGraph().

◆ groupClassesWithSameScope()

template<class Vec>
void groupClassesWithSameScope ( Vec & vec)
static

Definition at line 1917 of file groupdef.cpp.

1918{
1919 bool done=false;
1920 while (!done) // for each iteration
1921 {
1922 done=true;
1923 for (size_t i=0; i<vec.size(); i++) // go through all items
1924 {
1925 std::string qni = vec[i]->name().str();
1926 size_t posi = qni.rfind("::");
1927 if (posi!=std::string::npos)
1928 {
1929 std::string scope = qni.substr(0,posi);
1930 auto it = std::find_if( vec.begin(), vec.end(),
1931 [&](typename Vec::Ptr &cd)
1932 { return cd->name().str()==scope; });
1933 if (it!=vec.end())
1934 {
1935 size_t idx = std::distance(vec.begin(),it);
1936 if (i<idx) // parent scope located after child scope
1937 {
1938 // to avoid reordering elements with the same parent
1939 // we skip to the last one with the same scope
1940 size_t k = idx;
1941 while (k<vec.size() && vec[k]->name().str().substr(0,posi)==scope)
1942 {
1943 idx = k;
1944 k++;
1945 }
1946 // swap the items such that i is inserted after idx
1947 for (size_t j=i; j<idx; j++)
1948 {
1949 std::swap(vec[j],vec[j+1]);
1950 }
1951 done=false;
1952 }
1953 else if (idx<i && vec[i-1]->name().str().substr(0,posi)!=scope)
1954 {
1955 // parent scope is found before the item, and the item
1956 // has some other item with a different scope in front of it
1957 // move idx to the end of range with the same scope
1958 while (idx<i && vec[idx]->name().str().substr(0,posi)==scope)
1959 {
1960 idx++;
1961 }
1962 // swap the items such that i is just after idx
1963 for (size_t j=idx; j<i; j++)
1964 {
1965 std::swap(vec[j],vec[j+1]);
1966 }
1967 done=false;
1968 }
1969 }
1970 }
1971 }
1972 }
1973}
const char * name(int level)
Definition latexgen.h:368

Referenced by GroupDefImpl::sortMemberLists().

◆ hasNonReferenceNestedGroupRec()

bool hasNonReferenceNestedGroupRec ( const GroupDef * gd,
int level )
static

Definition at line 2073 of file groupdef.cpp.

2074{
2075 if (level>30)
2076 {
2077 err("Possible recursive group relation while inside {}\n",gd->name());
2078 return false;
2079 }
2080 bool found=gd->isLinkableInProject();
2081 if (found)
2082 {
2083 return true;
2084 }
2085 else
2086 {
2087 for (const auto &igd : gd->getSubGroups())
2088 {
2089 found = found || hasNonReferenceNestedGroupRec(igd,level+1);
2090 if (found) break;
2091 }
2092 }
2093 return found;
2094}
virtual bool isLinkableInProject() const =0
virtual const GroupList & getSubGroups() const =0
static bool hasNonReferenceNestedGroupRec(const GroupDef *gd, int level)
#define err(fmt,...)
Definition message.h:127

References err, GroupDef::getSubGroups(), hasNonReferenceNestedGroupRec(), Definition::isLinkableInProject(), and Definition::name().

Referenced by hasNonReferenceNestedGroupRec(), and GroupDefImpl::isVisibleInHierarchy().

◆ toGroupDef() [1/2]

const GroupDef * toGroupDef ( const Definition * d)

Definition at line 2156 of file groupdef.cpp.

2157{
2158 if (d==nullptr) return nullptr;
2159 if (d && typeid(*d)==typeid(GroupDefImpl))
2160 {
2161 return static_cast<const GroupDef*>(d);
2162 }
2163 else
2164 {
2165 return nullptr;
2166 }
2167}

◆ toGroupDef() [2/2]

GroupDef * toGroupDef ( Definition * d)

Definition at line 2143 of file groupdef.cpp.

2144{
2145 if (d==nullptr) return nullptr;
2146 if (d && typeid(*d)==typeid(GroupDefImpl))
2147 {
2148 return static_cast<GroupDef*>(d);
2149 }
2150 else
2151 {
2152 return nullptr;
2153 }
2154}

Referenced by DocRef::DocRef(), DocParser::handleLinkedWord(), SearchTerm::makeTitle(), DefinitionImpl::navigationPathAsString(), GroupDef::overrideGroupGraph(), DefinitionImpl::pathFragment(), SearchIndex::setCurrentDoc(), SearchIndexExternal::setCurrentDoc(), validatingParseDoc(), MemberDefImpl::writeDocumentation(), and writeJavasScriptSearchDataPage().