logic: Show non-indexed nodes within their parents and their childs
* Added support for access nodes without title
This commit is contained in:
@@ -325,7 +325,7 @@ void GraphController::createDummyGraphForTokenIds(const std::vector<Id>& tokenId
|
||||
{
|
||||
node->hasParent = false;
|
||||
|
||||
if (node->data->isType(Node::NODE_NON_INDEXED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE))
|
||||
if (node->data->isType(Node::NODE_NAMESPACE | Node::NODE_PACKAGE))
|
||||
{
|
||||
node->name = node->data->getFullName();
|
||||
}
|
||||
@@ -380,33 +380,32 @@ std::shared_ptr<DummyNode> GraphController::createDummyNodeTopDown(Node* node, I
|
||||
[node, &parentId, &result, this](Node* child)
|
||||
{
|
||||
DummyNode* parent = nullptr;
|
||||
AccessKind accessKind = ACCESS_NONE;
|
||||
|
||||
TokenComponentAccess* access = child->getComponent<TokenComponentAccess>();
|
||||
|
||||
if (access && access->getAccess() != ACCESS_NONE)
|
||||
if (access)
|
||||
{
|
||||
AccessKind accessKind = access->getAccess();
|
||||
for (std::shared_ptr<DummyNode> dummy : result->subNodes)
|
||||
{
|
||||
if (dummy->accessKind == accessKind)
|
||||
{
|
||||
parent = dummy.get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
accessKind = access->getAccess();
|
||||
}
|
||||
|
||||
if (!parent)
|
||||
for (std::shared_ptr<DummyNode> dummy : result->subNodes)
|
||||
{
|
||||
if (dummy->accessKind == accessKind)
|
||||
{
|
||||
std::shared_ptr<DummyNode> accessNode = std::make_shared<DummyNode>();
|
||||
accessNode->accessKind = accessKind;
|
||||
result->subNodes.push_back(accessNode);
|
||||
parent = accessNode.get();
|
||||
parent = dummy.get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!parent)
|
||||
{
|
||||
parent = result.get();
|
||||
std::shared_ptr<DummyNode> accessNode = std::make_shared<DummyNode>();
|
||||
accessNode->accessKind = accessKind;
|
||||
accessNode->isAccess = true;
|
||||
result->subNodes.push_back(accessNode);
|
||||
parent = accessNode.get();
|
||||
}
|
||||
|
||||
parent->subNodes.push_back(createDummyNodeTopDown(child, parentId));
|
||||
}
|
||||
);
|
||||
@@ -604,7 +603,11 @@ bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode* node, bool n
|
||||
}
|
||||
}
|
||||
|
||||
if (noActive || node->active || node->connected || node->childVisible)
|
||||
if (node->isAccessNode() && node->accessKind == ACCESS_NONE && node->childVisible)
|
||||
{
|
||||
node->visible = true;
|
||||
}
|
||||
else if (noActive || node->active || node->connected || node->childVisible)
|
||||
{
|
||||
setNodeVisibilityRecursiveTopDown(node, false);
|
||||
}
|
||||
@@ -616,9 +619,13 @@ void GraphController::setNodeVisibilityRecursiveTopDown(DummyNode* node, bool pa
|
||||
{
|
||||
node->visible = true;
|
||||
|
||||
if (node->isGraphNode() && node->data->getType() == Node::NODE_ENUM && !node->isExpanded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((node->isGraphNode() && node->isExpanded()) ||
|
||||
(node->isAccessNode() && parentExpanded) ||
|
||||
(node->isGraphNode() && parentExpanded && node->data->isType(Node::NODE_ENUM_CONSTANT)))
|
||||
(node->isAccessNode() && (node->accessKind == ACCESS_NONE || parentExpanded)))
|
||||
{
|
||||
for (std::shared_ptr<DummyNode> subNode : node->subNodes)
|
||||
{
|
||||
@@ -1285,11 +1292,6 @@ void GraphController::addExpandToggleNode(DummyNode* node) const
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
else if (subNode->isGraphNode() && subNode->data->isType(Node::NODE_ENUM_CONSTANT) && !subNode->visible)
|
||||
{
|
||||
expandNode->invisibleSubNodeCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<DummyNode> subSubNode : subNode->subNodes)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
, hasParent(true)
|
||||
, hasQualifier(false)
|
||||
, accessKind(ACCESS_NONE)
|
||||
, isAccess(false)
|
||||
, invisibleSubNodeCount(0)
|
||||
, bundleId(0)
|
||||
, layoutBucket(0, 0)
|
||||
@@ -79,7 +80,7 @@ public:
|
||||
|
||||
bool isAccessNode() const
|
||||
{
|
||||
return accessKind != ACCESS_NONE;
|
||||
return isAccess;
|
||||
}
|
||||
|
||||
bool isExpandToggleNode() const
|
||||
@@ -261,6 +262,7 @@ public:
|
||||
|
||||
// AccessNode
|
||||
AccessKind accessKind;
|
||||
bool isAccess;
|
||||
|
||||
// ExpandToggleNode
|
||||
size_t invisibleSubNodeCount;
|
||||
|
||||
@@ -330,6 +330,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(AccessKind ac
|
||||
switch (access)
|
||||
{
|
||||
case ACCESS_NONE:
|
||||
margins.top = 10;
|
||||
margins.minWidth = 30;
|
||||
break;
|
||||
case ACCESS_PUBLIC:
|
||||
|
||||
@@ -5,6 +5,7 @@ HierarchyCache::HierarchyNode::HierarchyNode(Id nodeId)
|
||||
, m_edgeId(0)
|
||||
, m_parent(nullptr)
|
||||
, m_isVisible(true)
|
||||
, m_isIndexed(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -51,12 +52,21 @@ void HierarchyCache::HierarchyNode::addChildIds(std::vector<Id>* nodeIds) const
|
||||
}
|
||||
}
|
||||
|
||||
void HierarchyCache::HierarchyNode::addChildIdsRecursive(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
||||
void HierarchyCache::HierarchyNode::addChildIds(std::set<Id>* nodeIds, std::set<Id>* edgeIds) const
|
||||
{
|
||||
for (const HierarchyNode* child : m_children)
|
||||
{
|
||||
nodeIds->push_back(child->getNodeId());
|
||||
edgeIds->push_back(child->getEdgeId());
|
||||
nodeIds->insert(child->getNodeId());
|
||||
edgeIds->insert(child->getEdgeId());
|
||||
}
|
||||
}
|
||||
|
||||
void HierarchyCache::HierarchyNode::addChildIdsRecursive(std::set<Id>* nodeIds, std::set<Id>* edgeIds) const
|
||||
{
|
||||
for (const HierarchyNode* child : m_children)
|
||||
{
|
||||
nodeIds->insert(child->getNodeId());
|
||||
edgeIds->insert(child->getEdgeId());
|
||||
|
||||
child->addChildIdsRecursive(nodeIds, edgeIds);
|
||||
}
|
||||
@@ -87,13 +97,23 @@ void HierarchyCache::HierarchyNode::setIsVisible(bool isVisible)
|
||||
m_isVisible = isVisible;
|
||||
}
|
||||
|
||||
bool HierarchyCache::HierarchyNode::isIndexed() const
|
||||
{
|
||||
return m_isIndexed;
|
||||
}
|
||||
|
||||
void HierarchyCache::HierarchyNode::setIsIndexed(bool isIndexed)
|
||||
{
|
||||
m_isIndexed = isIndexed;
|
||||
}
|
||||
|
||||
|
||||
void HierarchyCache::clear()
|
||||
{
|
||||
m_nodes.clear();
|
||||
}
|
||||
|
||||
void HierarchyCache::createConnection(Id edgeId, Id fromId, Id toId, bool fromVisible)
|
||||
void HierarchyCache::createConnection(Id edgeId, Id fromId, Id toId, bool sourceVisible, bool sourceIndexed, bool targetIndexed)
|
||||
{
|
||||
HierarchyNode* from = createNode(fromId);
|
||||
HierarchyNode* to = createNode(toId);
|
||||
@@ -101,8 +121,11 @@ void HierarchyCache::createConnection(Id edgeId, Id fromId, Id toId, bool fromVi
|
||||
from->addChild(to);
|
||||
to->setParent(from);
|
||||
|
||||
from->setIsVisible(sourceVisible);
|
||||
from->setIsIndexed(sourceIndexed);
|
||||
|
||||
to->setEdgeId(edgeId);
|
||||
from->setIsVisible(fromVisible);
|
||||
to->setIsIndexed(targetIndexed);
|
||||
}
|
||||
|
||||
Id HierarchyCache::getLastVisibleParentNodeId(Id nodeId) const
|
||||
@@ -147,7 +170,7 @@ size_t HierarchyCache::getIndexOfLastVisibleParentNode(Id nodeId) const
|
||||
return idx;
|
||||
}
|
||||
|
||||
void HierarchyCache::addAllChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
||||
void HierarchyCache::addAllChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const
|
||||
{
|
||||
HierarchyNode* node = getNode(nodeId);
|
||||
if (node)
|
||||
@@ -156,6 +179,29 @@ void HierarchyCache::addAllChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds
|
||||
}
|
||||
}
|
||||
|
||||
void HierarchyCache::addAllVisibleParentsAndChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const
|
||||
{
|
||||
HierarchyNode* node = getNode(nodeId);
|
||||
if (node)
|
||||
{
|
||||
node->addChildIds(nodeIds, edgeIds);
|
||||
}
|
||||
|
||||
Id edgeId = 0;
|
||||
while (node && node->isVisible())
|
||||
{
|
||||
if (edgeId)
|
||||
{
|
||||
edgeIds->insert(edgeId);
|
||||
}
|
||||
|
||||
nodeIds->insert(node->getNodeId());
|
||||
edgeId = node->getEdgeId();
|
||||
|
||||
node = node->getParent();
|
||||
}
|
||||
}
|
||||
|
||||
void HierarchyCache::addFirstChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds) const
|
||||
{
|
||||
HierarchyNode* node = getNode(nodeId);
|
||||
@@ -203,6 +249,17 @@ bool HierarchyCache::isChildOfVisibleNodeOrInvisible(Id nodeId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HierarchyCache::isIndexed(Id nodeId) const
|
||||
{
|
||||
HierarchyNode* node = getNode(nodeId);
|
||||
if (!node)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return node->isIndexed();
|
||||
}
|
||||
|
||||
bool HierarchyCache::nodeHasChildren(Id nodeId) const
|
||||
{
|
||||
HierarchyNode* node = getNode(nodeId);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "utility/types.h"
|
||||
@@ -12,16 +13,21 @@ class HierarchyCache
|
||||
public:
|
||||
void clear();
|
||||
|
||||
void createConnection(Id edgeId, Id fromId, Id toId, bool fromVisible);
|
||||
void createConnection(Id edgeId, Id fromId, Id toId, bool sourceVisible, bool sourceIndexed, bool targetIndexed);
|
||||
|
||||
Id getLastVisibleParentNodeId(Id nodeId) const;
|
||||
size_t getIndexOfLastVisibleParentNode(Id nodeId) const;
|
||||
|
||||
void addAllChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
||||
void addAllChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||
void addAllVisibleParentsAndChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||
void addAllVisibleParentsRecursive(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||
|
||||
void addFirstChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds) const;
|
||||
void addFirstVisibleChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds) const;
|
||||
|
||||
bool isChildOfVisibleNodeOrInvisible(Id nodeId) const;
|
||||
bool isIndexed(Id nodeId) const;
|
||||
|
||||
bool nodeHasChildren(Id nodeId) const;
|
||||
|
||||
private:
|
||||
@@ -42,12 +48,16 @@ private:
|
||||
const std::vector<HierarchyNode*>& getChildren() const;
|
||||
|
||||
void addChildIds(std::vector<Id>* nodeIds) const;
|
||||
void addChildIdsRecursive(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
||||
void addChildIds(std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||
void addChildIdsRecursive(std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||
void addVisibleNodeIdsRecursive(std::vector<Id>* nodeIds) const;
|
||||
|
||||
bool isVisible() const;
|
||||
void setIsVisible(bool isVisible);
|
||||
|
||||
bool isIndexed() const;
|
||||
void setIsIndexed(bool isIndexed);
|
||||
|
||||
private:
|
||||
const Id m_nodeId;
|
||||
Id m_edgeId;
|
||||
@@ -56,6 +66,7 @@ private:
|
||||
std::vector<HierarchyNode*> m_children;
|
||||
|
||||
bool m_isVisible;
|
||||
bool m_isIndexed;
|
||||
};
|
||||
|
||||
HierarchyNode* getNode(Id nodeId) const;
|
||||
|
||||
@@ -843,11 +843,6 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(const std::v
|
||||
|
||||
if (!isNamespace)
|
||||
{
|
||||
for (const StorageFile& file : m_sqliteStorage.getAllByIds<StorageFile>(ids))
|
||||
{
|
||||
nodeIds.push_back(file.id);
|
||||
}
|
||||
|
||||
if (nodeIds.size() != ids.size())
|
||||
{
|
||||
std::vector<StorageEdge> edges = m_sqliteStorage.getAllByIds<StorageEdge>(ids);
|
||||
@@ -1453,12 +1448,12 @@ Id PersistentStorage::getLastVisibleParentNodeId(const Id nodeId) const
|
||||
|
||||
std::vector<Id> PersistentStorage::getAllChildNodeIds(const Id nodeId) const
|
||||
{
|
||||
std::vector<Id> childNodeIds;
|
||||
std::vector<Id> edgeIds;
|
||||
std::set<Id> childNodeIds;
|
||||
std::set<Id> edgeIds;
|
||||
|
||||
m_hierarchyCache.addAllChildIdsForNodeId(nodeId, &childNodeIds, &edgeIds);
|
||||
|
||||
return childNodeIds;
|
||||
return utility::toVector(childNodeIds);
|
||||
}
|
||||
|
||||
void PersistentStorage::addNodesToGraph(const std::vector<Id>& nodeIds, Graph* graph) const
|
||||
@@ -1563,33 +1558,47 @@ void PersistentStorage::addNodesWithChildrenAndEdgesToGraph(
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::set<Id> parentNodeIds;
|
||||
|
||||
for (Id nodeId : nodeIds)
|
||||
{
|
||||
parentNodeIds.insert(getLastVisibleParentNodeId(nodeId));
|
||||
}
|
||||
|
||||
std::vector<Id> nodeIdsFull = nodeIds;
|
||||
if (edgeIds.size() > 0)
|
||||
{
|
||||
for (const StorageEdge& storageEdge : m_sqliteStorage.getAllByIds<StorageEdge>(edgeIds))
|
||||
{
|
||||
parentNodeIds.insert(getLastVisibleParentNodeId(storageEdge.sourceNodeId));
|
||||
parentNodeIds.insert(getLastVisibleParentNodeId(storageEdge.targetNodeId));
|
||||
nodeIdsFull.push_back(storageEdge.sourceNodeId);
|
||||
nodeIdsFull.push_back(storageEdge.targetNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Id> allNodeIds;
|
||||
std::vector<Id> allEdgeIds = edgeIds;
|
||||
std::set<Id> parentNodeIds;
|
||||
std::set<Id> nonIndexedNodeIds;
|
||||
|
||||
for (Id nodeId : nodeIdsFull)
|
||||
{
|
||||
if (m_hierarchyCache.isIndexed(nodeId))
|
||||
{
|
||||
parentNodeIds.insert(getLastVisibleParentNodeId(nodeId));
|
||||
}
|
||||
else
|
||||
{
|
||||
nonIndexedNodeIds.insert(nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<Id> allNodeIds;
|
||||
std::set<Id> allEdgeIds(edgeIds.begin(), edgeIds.end());
|
||||
|
||||
for (Id parentNodeId : parentNodeIds)
|
||||
{
|
||||
allNodeIds.push_back(parentNodeId);
|
||||
allNodeIds.insert(parentNodeId);
|
||||
m_hierarchyCache.addAllChildIdsForNodeId(parentNodeId, &allNodeIds, &allEdgeIds);
|
||||
}
|
||||
|
||||
addNodesToGraph(allNodeIds, graph);
|
||||
addEdgesToGraph(allEdgeIds, graph);
|
||||
for (Id nonIndexedNodeId : nonIndexedNodeIds)
|
||||
{
|
||||
m_hierarchyCache.addAllVisibleParentsAndChildIdsForNodeId(nonIndexedNodeId, &allNodeIds, &allEdgeIds);
|
||||
}
|
||||
|
||||
addNodesToGraph(utility::toVector(allNodeIds), graph);
|
||||
addEdgesToGraph(utility::toVector(allEdgeIds), graph);
|
||||
}
|
||||
|
||||
void PersistentStorage::addAggregationEdgesToGraph(
|
||||
@@ -1796,10 +1805,23 @@ void PersistentStorage::buildHierarchyCache()
|
||||
return Node::intToType(m_sqliteStorage.getFirstById<StorageNode>(id).type);
|
||||
});
|
||||
|
||||
Cache<Id, bool> indexedNodeCache([this](Id id){
|
||||
StorageSymbol symbol = m_sqliteStorage.getFirstById<StorageSymbol>(id);
|
||||
if (symbol.id > 0)
|
||||
{
|
||||
return intToDefinitionKind(symbol.definitionKind) != DEFINITION_NONE;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
for (const StorageEdge& edge : memberEdges)
|
||||
{
|
||||
bool isVisible = !(nodeTypeCache.getValue(edge.sourceNodeId) & Node::NODE_NOT_VISIBLE);
|
||||
m_hierarchyCache.createConnection(edge.id, edge.sourceNodeId, edge.targetNodeId, isVisible);
|
||||
bool sourceIsIndexed = indexedNodeCache.getValue(edge.sourceNodeId);
|
||||
bool targetIsIndexed = indexedNodeCache.getValue(edge.targetNodeId);
|
||||
|
||||
m_hierarchyCache.createConnection(
|
||||
edge.id, edge.sourceNodeId, edge.targetNodeId, isVisible, sourceIsIndexed, targetIsIndexed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_NON_INDEXED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
|
||||
const Node::NodeTypeMask Node::NODE_USEABLE_TYPE = Node::NODE_NON_INDEXED | Node::NODE_BUILTIN_TYPE |
|
||||
Node::NODE_BUILTIN_TYPE | Node::NODE_STRUCT | Node::NODE_CLASS | Node::NODE_INTERFACE | Node::NODE_TYPEDEF;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user