logic: Show parameters for functions/methods with same name within same parent (issue #259)
This commit is contained in:
@@ -1750,6 +1750,8 @@ void GraphController::layoutNesting()
|
||||
{
|
||||
TRACE();
|
||||
|
||||
extendEqualFunctionNames(m_dummyNodes);
|
||||
|
||||
for (const std::shared_ptr<DummyNode>& node : m_dummyNodes)
|
||||
{
|
||||
layoutNestingRecursive(node.get());
|
||||
@@ -1761,6 +1763,40 @@ void GraphController::layoutNesting()
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::extendEqualFunctionNames(const std::vector<std::shared_ptr<DummyNode>>& nodes) const
|
||||
{
|
||||
std::multimap<std::wstring, std::shared_ptr<DummyNode>> functionNames;
|
||||
for (auto& node : nodes)
|
||||
{
|
||||
if (node->visible && node->isGraphNode() && node->data->isType(NodeType::NODE_FUNCTION | NodeType::NODE_METHOD))
|
||||
{
|
||||
functionNames.emplace(node->name, node);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it : functionNames)
|
||||
{
|
||||
if (functionNames.count(it.first) < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto ret = functionNames.equal_range(it.first);
|
||||
for (auto it2 = ret.first; it2 != ret.second; it2++)
|
||||
{
|
||||
it2->second->name = it2->second->data->getNameHierarchy().getRawNameWithSignatureParameters();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& node : nodes)
|
||||
{
|
||||
if (node->subNodes.size())
|
||||
{
|
||||
extendEqualFunctionNames(node->subNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::layoutNestingRecursive(DummyNode* node) const
|
||||
{
|
||||
if (!node->visible)
|
||||
@@ -1813,10 +1849,9 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
|
||||
|
||||
if (node->isGraphNode())
|
||||
{
|
||||
size_t maxNameSize = 50;
|
||||
if (!node->active && node->name.size() > maxNameSize)
|
||||
if (!node->active)
|
||||
{
|
||||
node->name = node->name.substr(0, maxNameSize - 3) + L"...";
|
||||
node->name = utility::elide(node->name, utility::ELIDE_RIGHT, 50);
|
||||
}
|
||||
|
||||
width = margins.charWidth * node->name.size();
|
||||
|
||||
@@ -114,6 +114,7 @@ private:
|
||||
void groupTrailNodes(GroupType groupType);
|
||||
|
||||
void layoutNesting();
|
||||
void extendEqualFunctionNames(const std::vector<std::shared_ptr<DummyNode>>& nodes) const;
|
||||
void layoutNestingRecursive(DummyNode* node) const;
|
||||
void addExpandToggleNode(DummyNode* node) const;
|
||||
void layoutToGrid(DummyNode* node) const;
|
||||
|
||||
@@ -64,7 +64,7 @@ std::wstring Node::getFullName() const
|
||||
return m_nameHierarchy.getQualifiedName();
|
||||
}
|
||||
|
||||
NameHierarchy Node::getNameHierarchy() const
|
||||
const NameHierarchy& Node::getNameHierarchy() const
|
||||
{
|
||||
return m_nameHierarchy;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
std::wstring getName() const;
|
||||
std::wstring getFullName() const;
|
||||
NameHierarchy getNameHierarchy() const;
|
||||
const NameHierarchy& getNameHierarchy() const;
|
||||
|
||||
bool isDefined() const;
|
||||
bool isImplicit() const;
|
||||
|
||||
@@ -71,6 +71,11 @@ const std::wstring& NameElement::Signature::getPostfix() const
|
||||
return m_postfix;
|
||||
}
|
||||
|
||||
std::wstring NameElement::Signature::getParameterString() const
|
||||
{
|
||||
return utility::substrBeforeLast(m_postfix, L')') + L')';
|
||||
}
|
||||
|
||||
NameElement::NameElement(const std::wstring& name)
|
||||
: m_name(name)
|
||||
{
|
||||
@@ -96,6 +101,11 @@ std::wstring NameElement::getNameWithSignature() const
|
||||
return m_signature.qualifyName(m_name);
|
||||
}
|
||||
|
||||
std::wstring NameElement::getNameWithSignatureParameters() const
|
||||
{
|
||||
return m_name + m_signature.getParameterString();
|
||||
}
|
||||
|
||||
bool NameElement::hasSignature() const
|
||||
{
|
||||
return m_signature.isValid();
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
|
||||
const std::wstring& getPrefix() const;
|
||||
const std::wstring& getPostfix() const;
|
||||
std::wstring getParameterString() const;
|
||||
|
||||
private:
|
||||
std::wstring m_prefix;
|
||||
@@ -35,6 +36,7 @@ public:
|
||||
|
||||
std::wstring getName() const;
|
||||
std::wstring getNameWithSignature() const;
|
||||
std::wstring getNameWithSignatureParameters() const;
|
||||
bool hasSignature() const;
|
||||
Signature getSignature();
|
||||
|
||||
|
||||
@@ -188,6 +188,15 @@ std::wstring NameHierarchy::getRawNameWithSignature() const
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring NameHierarchy::getRawNameWithSignatureParameters() const
|
||||
{
|
||||
if (m_elements.size())
|
||||
{
|
||||
return m_elements.back()->getNameWithSignatureParameters();
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
bool NameHierarchy::hasSignature() const
|
||||
{
|
||||
if (m_elements.size())
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
std::wstring getQualifiedNameWithSignature() const;
|
||||
std::wstring getRawName() const;
|
||||
std::wstring getRawNameWithSignature() const;
|
||||
std::wstring getRawNameWithSignatureParameters() const;
|
||||
|
||||
bool hasSignature() const;
|
||||
NameElement::Signature getSignature() const;
|
||||
|
||||
@@ -217,12 +217,22 @@ namespace utility
|
||||
return str;
|
||||
}
|
||||
|
||||
std::wstring substrAfterLast(const std::wstring& str, wchar_t delimiter)
|
||||
{
|
||||
size_t pos = str.rfind(delimiter);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
return str.substr(pos + 1, std::wstring::npos);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string substrAfter(const std::string& str, char delimiter)
|
||||
{
|
||||
size_t pos = str.find(delimiter);
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
return str.substr(pos + 1, str.size());
|
||||
return str.substr(pos + 1, std::wstring::npos);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace utility
|
||||
std::string substrBeforeFirst(const std::string& str, const std::string& delimiter);
|
||||
std::string substrBeforeLast(const std::string& str, char delimiter);
|
||||
std::wstring substrBeforeLast(const std::wstring& str, wchar_t delimiter);
|
||||
std::wstring substrAfterLast(const std::wstring& str, wchar_t delimiter);
|
||||
std::string substrAfter(const std::string& str, char delimiter);
|
||||
std::string substrAfter(const std::string& str, const std::string& delimiter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user