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 1558 of file groupdef.cpp.

1559{
1560 for (const Grouping &g : root->groups)
1561 {
1562 GroupDef *gd=nullptr;
1564 if (gd && gd->addClass(cd))
1565 {
1567 if (cdm)
1568 {
1569 cdm->makePartOfGroup(gd);
1570 }
1571 //printf("Compound %s: in group %s\n",qPrint(cd->name()),gd->groupTitle());
1572 }
1573 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1574 {
1575 warn(root->fileName, root->startLine,
1576 "Found non-existing group '{}' for the command '{}', ignoring command",
1578 );
1579 }
1580 }
1581}
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:223
std::vector< Grouping > groups
list of groups this entry belongs to
Definition entry.h:221
int startLine
start line of entry in the source
Definition entry.h:224
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 1583 of file groupdef.cpp.

1584{
1585 for (const Grouping &g : root->groups)
1586 {
1588 if (gd && gd->addConcept(cd))
1589 {
1591 if (cdm)
1592 {
1593 cdm->makePartOfGroup(gd);
1594 }
1595 //printf("Compound %s: in group %s\n",qPrint(cd->name()),gd->groupTitle());
1596 }
1597 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1598 {
1599 warn(root->fileName, root->startLine,
1600 "Found non-existing group '{}' for the command '{}', ignoring command",
1602 );
1603 }
1604 }
1605}
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 1655 of file groupdef.cpp.

1656{
1657 //printf("*** root->groups.size()=%d\n",root->groups.size());
1658 for (const Grouping &g : root->groups)
1659 {
1661 //printf("group '%s'\n",qPrint(g->groupname));
1662 if (gd)
1663 {
1664 gd->addDir(dd);
1665 dd->makePartOfGroup(gd);
1666 //printf("Dir %s: in group %s\n",qPrint(dd->name()),qPrint(g->groupname));
1667 }
1668 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1669 {
1670 warn(root->fileName, root->startLine,
1671 "Found non-existing group '{}' for the command '{}', ignoring command",
1673 );
1674 }
1675 }
1676}
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 1838 of file groupdef.cpp.

1839{
1840 for (const Grouping &g : root->groups)
1841 {
1843 if (gd)
1844 {
1845 gd->addExample(eg);
1846 eg->makePartOfGroup(gd);
1847 //printf("Example %s: in group %s\n",qPrint(eg->name()),s->data());
1848 }
1849 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1850 {
1851 warn(root->fileName, root->startLine,
1852 "Found non-existing group '{}' for the command '{}', ignoring command",
1854 );
1855 }
1856 }
1857}
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 1678 of file groupdef.cpp.

1679{
1680 //printf("addGroupToGroups for %s groups=%d\n",qPrint(root->name),root->groups.size());
1681 for (const Grouping &g : root->groups)
1682 {
1684 if (gd)
1685 {
1686 if (gd==subGroup)
1687 {
1688 warn(root->fileName,root->startLine,"Refusing to add group {} to itself",
1689 gd->name());
1690 }
1691 else if (subGroup->findGroup(gd))
1692 {
1693 warn(root->fileName,root->startLine,"Refusing to add group {} to group {}, since the latter is already a "
1694 "subgroup of the former", subGroup->name(),gd->name());
1695 }
1696 else if (!gd->findGroup(subGroup))
1697 {
1698 gd->addGroup(subGroup);
1699 subGroup->makePartOfGroup(gd);
1700 }
1701 }
1702 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1703 {
1704 warn(root->fileName, root->startLine,
1705 "Found non-existing group '{}' for the command '{}', ignoring command",
1707 );
1708 }
1709 }
1710}
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 1713 of file groupdef.cpp.

1714{
1715 //printf("addMemberToGroups: Root %p = %s, md %p=%s groups=%zu\n",
1716 // root, qPrint(root->name), md, qPrint(md->name()), root->groups.size() );
1717
1718 // Search entry's group list for group with highest pri.
1720 GroupDef *fgd=nullptr;
1721 for (const Grouping &g : root->groups)
1722 {
1723 GroupDef *gd=nullptr;
1725 if (gd && g.pri >= pri)
1726 {
1727 if (fgd && gd!=fgd && g.pri==pri)
1728 {
1729 warn(root->fileName, root->startLine,
1730 "Member {} found in multiple {} groups! "
1731 "The member will be put in group {}, and not in group {}",
1732 md->name(), Grouping::getGroupPriName( pri ),
1733 gd->name(), fgd->name()
1734 );
1735 }
1736
1737 fgd = gd;
1738 pri = g.pri;
1739 }
1740 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1741 {
1742 warn(root->fileName, root->startLine,
1743 "Found non-existing group '{}' for the command '{}', ignoring command",
1745 );
1746 }
1747 }
1748 //printf("fgd=%p\n",fgd);
1749
1750 // put member into group defined by this entry?
1751 if (fgd)
1752 {
1753 GroupDef *mgd = md->getGroupDef();
1754 //printf("mgd=%p\n",mgd);
1755 bool insertit = false;
1756 if (mgd==nullptr)
1757 {
1758 insertit = true;
1759 }
1760 else if (mgd!=fgd)
1761 {
1762 bool moveit = false;
1763
1764 // move member from one group to another if
1765 // - the new one has a higher priority
1766 // - the new entry has the same priority, but with docs where the old one had no docs
1767 if (md->getGroupPri()<pri)
1768 {
1769 moveit = true;
1770 }
1771 else
1772 {
1773 if (md->getGroupPri()==pri)
1774 {
1775 if (!root->doc.empty() && !md->getGroupHasDocs())
1776 {
1777 moveit = true;
1778 }
1779 else if (!root->doc.empty() && md->getGroupHasDocs())
1780 {
1782 "Member documentation for {} found several times in {} groups!\n"
1783 "{}:{}: The member will remain in group {}, and won't be put into group {}",
1784 md->name(), Grouping::getGroupPriName( pri ),
1785 root->fileName, root->startLine,
1786 mgd->name(), fgd->name()
1787 );
1788 }
1789 }
1790 }
1791
1792 if (moveit)
1793 {
1794 //printf("removeMember\n");
1795 mgd->removeMember(md);
1796 insertit = true;
1797 }
1798 }
1799
1800 if (insertit)
1801 {
1802 //printf("insertMember found at %s line %d: %s: related %s\n",
1803 // qPrint(md->getDefFileName()),md->getDefLine(),
1804 // qPrint(md->name()),qPrint(root->relates));
1805 bool success = fgd->insertMember(md);
1806 if (success)
1807 {
1809 if (mdm)
1810 {
1811 //printf("insertMember successful\n");
1812 mdm->setGroupDef(fgd,pri,root->fileName,root->startLine,!root->doc.empty());
1814 if (cdm)
1815 {
1816 cdm->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0);
1817 }
1818 if (mdm->isEnumerate() && mdm->getGroupDef() && md->isStrong())
1819 {
1820 for (const auto &emd : mdm->enumFieldList())
1821 {
1823 if (emdm && emdm->getGroupDef()==nullptr)
1824 {
1825 emdm->setGroupDef(mdm->getGroupDef(),mdm->getGroupPri(),
1826 mdm->getGroupFileName(),mdm->getGroupStartLine(),
1827 mdm->getGroupHasDocs());
1828 }
1829 }
1830 }
1831 }
1832 }
1833 }
1834 }
1835}
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:200
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 1607 of file groupdef.cpp.

1608{
1609 for (const Grouping &g : root->groups)
1610 {
1612 if (gd && gd->addModule(mod))
1613 {
1614 mod->makePartOfGroup(gd);
1615 //printf("Module %s: in group %s\n",qPrint(mod->name()),gd->groupTitle());
1616 }
1617 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1618 {
1619 warn(root->fileName, root->startLine,
1620 "Found non-existing group '{}' for the command '{}', ignoring command",
1622 );
1623 }
1624 }
1625}
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 1628 of file groupdef.cpp.

1629{
1630 //printf("root->groups.size()=%zu\n",root->groups.size());
1631 for (const Grouping &g : root->groups)
1632 {
1633 GroupDef *gd=nullptr;
1635 //printf("group '%s' gd=%p\n",qPrint(g.groupname),(void*)gd);
1636 if (gd && gd->addNamespace(nd))
1637 {
1639 if (ndm)
1640 {
1641 ndm->makePartOfGroup(gd);
1642 }
1643 //printf("Namespace %s: in group %s\n",qPrint(nd->name()),qPrint(gd->name()));
1644 }
1645 else if (!gd && g.pri == Grouping::GROUPING_INGROUP)
1646 {
1647 warn(root->fileName, root->startLine,
1648 "Found non-existing group '{}' for the command '{}', ignoring command",
1650 );
1651 }
1652 }
1653}
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 1915 of file groupdef.cpp.

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

Referenced by GroupDefImpl::sortMemberLists().

◆ hasNonReferenceNestedGroupRec()

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

Definition at line 2071 of file groupdef.cpp.

2072{
2073 if (level>30)
2074 {
2075 err("Possible recursive group relation while inside {}\n",gd->name());
2076 return false;
2077 }
2078 bool found=gd->isLinkableInProject();
2079 if (found)
2080 {
2081 return true;
2082 }
2083 else
2084 {
2085 for (const auto &igd : gd->getSubGroups())
2086 {
2087 found = found || hasNonReferenceNestedGroupRec(igd,level+1);
2088 if (found) break;
2089 }
2090 }
2091 return found;
2092}
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 2154 of file groupdef.cpp.

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

◆ toGroupDef() [2/2]

GroupDef * toGroupDef ( Definition * d)

Definition at line 2141 of file groupdef.cpp.

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

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